Created
August 9, 2012 02:42
-
-
Save meyer9/3300438 to your computer and use it in GitHub Desktop.
player.py
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 | |
class Player(pygame.sprite.Sprite): | |
def __init__(self, img_filename, init_position, speed=5): | |
self.speed=speed | |
self.position=init_position | |
self.image = pygame.image.load(img_filename) | |
def update(self): | |
#TODO: physics implementation | |
pass | |
def move(self, w, a, s, d): | |
if w: | |
self.position[1]-=self.speed | |
elif s: | |
self.position[1]+=self.speed | |
if a: | |
self.position[0]-=self.speed | |
elif d: | |
self.position[0]+=self.speed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment