Created
August 13, 2012 14:39
-
-
Save meyer9/3341311 to your computer and use it in GitHub Desktop.
Main.py 3rd revision
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame import * | |
from player import Player | |
controls=[False, False, False, False] | |
screen = pygame.display.set_mode((640, 400)) | |
running = 1 | |
player=Player("player.png", [100,150]) | |
while running: | |
player.update() | |
events = pygame.event.get() | |
for event in events: | |
if event.type == pygame.QUIT: | |
running = 0 | |
if event.type == KEYDOWN: | |
if event.key==K_a: | |
controls[1]=True | |
if event.key==K_d: | |
controls[3]=True | |
if event.key==K_s: | |
controls[2]=True | |
if event.type == KEYUP: | |
if event.key==K_a: | |
controls[1]=False | |
if event.key==K_d: | |
controls[3]=False | |
if event.key==K_s: | |
controls[2]=False | |
player.move(False, controls[1], controls[2], controls[3]) | |
screen.fill((100, 127, 180)) | |
screen.blit(player.image, player.position) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment