def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
    player.handle_event(e)
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
        gfw.quit()

    global player
    player.handle_event(e)
Exemple #3
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
        elif e.key == SDLK_RETURN:  #엔터 게임시작
            start_game()
        elif e.key == SDLK_SPACE:  #스페이스바 다음스테이지
            gfw.push(howtostage2)

    player.handle_event(e)
Exemple #4
0
def handle_event(e):
    if e.type == SDL_QUIT:
        gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            gfw.pop()
        elif e.key == SDLK_RETURN:
            start_game()
    elif e.type == SDL_MOUSEBUTTONDOWN:
        start_game()

    player.handle_event(e)
Exemple #5
0
def main():
    pygame.init()
    pygame.display.set_mode(graphics.screen_size)
    pygame.display.set_caption("Dungeon Crawler")
    pygame.mouse.set_visible(1)
    pygame.key.set_repeat(1, 30)
    
    clock = pygame.time.Clock()
    
    player = animation.Animation((32, 32))
  #  player1 = player.Player("player1",fist,none,100,50,1000,[])
    
    
    tile.init()
    map = room.load(os.path.join("data", "level1.txt"))
    screen = pygame.display.get_surface()
    
    running = True
    while running:
    
        clock.tick(30)
        screen.fill((0, 0, 0))
        
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
               
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    pygame.event.post(pygame.event.Event(pygame.QUIT))
                    
        
        
        map.draw(screen)
        player.handle_event(event)  
        screen.blit(player.image, player.rect)
        
        pygame.display.flip()
        clock.tick(30)
Exemple #6
0
#Create our screen, set caption, initiate clock
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("Python/Pygame Animation")
clock = pygame.time.Clock()
'''Here we create our player object. The (200, 200) values are passed to the
position parameter in our Player class. This means the top-left corner of our
character will be drawn at x-y position (200, 200) on the screen. We similary
pass our sprite sheet to the constructor, where all the methods we wrote
previously do their work and transform this into a single frame on the screen.'''
player = player.Player((200, 200), 'serge_walk.png')

#Create main loop
game_over = False
while game_over == False:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game_over = True

    #Call our event handler, fill the screen, and blit (draw) player to the screen
    player.handle_event(event)
    screen.fill(pygame.Color('black'))
    screen.blit(player.image, player.rect)

    pygame.display.flip()

    #The clock is an easy way to control our animation speed
    clock.tick(15)

pygame.quit()
#Create our screen, set caption, initiate clock
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("Python/Pygame Animation")
clock = pygame.time.Clock()

'''Here we create our player object. The (200, 200) values are passed to the
position parameter in our Player class. This means the top-left corner of our
character will be drawn at x-y position (200, 200) on the screen. We similary
pass our sprite sheet to the constructor, where all the methods we wrote
previously do their work and transform this into a single frame on the screen.'''
player = player.Player((200, 200), 'serge_walk.png')

#Create main loop
game_over = False
while game_over == False:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game_over = True
    
    #Call our event handler, fill the screen, and blit (draw) player to the screen
    player.handle_event(event)
    screen.fill(pygame.Color('black'))
    screen.blit(player.image, player.rect)
    
    pygame.display.flip()
    
    #The clock is an easy way to control our animation speed
    clock.tick(15)

pygame.quit ()