Created
August 17, 2011 23:28
-
-
Save djanatyn/1152910 to your computer and use it in GitHub Desktop.
getting some experience with pygame :D
This file contains 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 sys, pygame | |
pygame.init() | |
class player: | |
def __init__(self,posx,posy): | |
self.position = [posx,posy] | |
def jump(self): | |
self.jumping = True | |
self.velocity = 0 | |
clock = pygame.time.Clock() | |
size = width, height = 640, 480 | |
speed = [0,0] | |
black = 0, 0, 0 | |
quitting_time = 0 | |
screen = pygame.display.set_mode(size) | |
wizard = pygame.image.load("wizard.png") | |
new_player = player(32,32) | |
while not quitting_time: | |
clock.tick(60) | |
for event in pygame.event.get(): | |
if event.type == pygame.KEYDOWN: | |
if event.key == pygame.K_LEFT: new_player.position[0] += -32 | |
elif event.key == pygame.K_RIGHT: new_player.position[0] += 32 | |
elif event.key == pygame.K_UP: new_player.position[1] += -32 | |
elif event.key == pygame.K_DOWN: new_player.position[1] += 32 | |
elif event.key == pygame.K_q: quitting_time = 1 | |
screen.fill(black) | |
screen.blit(wizard, new_player.position) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment