コード例 #1
0
ファイル: Main.py プロジェクト: Hillsdej/Projects
def gameLoop():
    pygame.init()
    pygame.font.init()
    #pygame.mixer.init()

    #pygame.mixer.music.load("audio/halo_themes.wav")
    #pygame.mixer.music.play(-1)

    invalids = tuple(invalids_func())

    for y in range(0, screen.get_height(), 32):
        for x in range(0, screen.get_width(), 32):
            if Tile.total_tiles in invalids:
                Tile(x, y, 'solid')
            else:
                Tile(x, y, 'empty')

    #set time
    #clock = pygame.time.Clock()
    FPS = 24
    total_frames = 0

    background = pygame.image.load('images/Background.png')
    player = Player(64, 128)

    while player.health > 1:

        screen.blit(background, (0, 0))

        Enemy.spawn(total_frames, FPS)
        Enemy.update(screen, player)

        player.movement()

        Bullet.super_massive_jumbo_loop(screen)

        A_Star(screen, player, total_frames, FPS)
        interaction(screen, player)
        player.draw(screen)

        Func.text_to_screen(screen, "Health {0}".format(player.health), 0, 0)

        pygame.display.flip()
        clock.tick(FPS)
        total_frames += 1

        if player.health <= 0:
            sleep(2)
            screen.blit(pygame.image.load("images/End.png"), (0, 0))
            pygame.display.update()
            break

    sleep(4)
コード例 #2
0
ファイル: main.py プロジェクト: amaurilopez90/Alienz
pygame.init()
pygame.font.init() #initialize font module
pygame.mixer.init() #initialize mixer for music

pygame.mixer.music.load("../Audio/gameMusicHighAlert.ogg")   #set up the game's background music
pygame.mixer.music.set_volume(0.06)
pygame.mixer.music.play(-1)                               #keep the music playing on replay    

print(pygame.mixer.music.get_volume())

screen = pygame.display.set_mode((800, 608))
for y in range(0, screen.get_height(), 32): 
	for x in range(0, screen.get_width(), 32):
		if Tile.total_tiles in Tile.invalidTiles:         #total_tiles also keeps track of current tile number. So if the tile is in fact an invalid tile,
			Tile(x, y, "solid")                           #then make the tile a solid type (aka walkable = False)
		else:
			Tile(x, y, "empty")                           #if not then make the tile an empty type (aka walkable = True)


clock = pygame.time.Clock()
FPS = 32
total_frames = 0

gamemap = pygame.image.load("../Images/techbackground.jpg")

player = Player(64, 288)
healthUPS.spawn()
ammoPacks.spawn()
prev_enemies_killed = 0
healthUPS_respawn = False
コード例 #3
0
ファイル: Main.py プロジェクト: Hillsdej/Projects
from object_classes import *
from interaction import interaction
from invalidsFunc import *
from A_Star import A_Star

pygame.init()
pygame.font.init()

invalids = tuple(invalids_func())

screen = pygame.display.set_mode((960, 640))

for y in range(0, screen.get_height(), 32):
    for x in range(0, screen.get_width(), 32):
        if Tile.total_tiles in invalids:
            Tile(x, y, 'solid')
        else:
            Tile(x, y, 'empty')

#set time
clock = pygame.time.Clock()
FPS = 24
total_frames = 0

background = pygame.image.load('images/Background.png')
player = Player(64, 128)

while True:

    screen.blit(background, (0, 0))