Not really sure what I did ... but some sort of improvement.

This commit is contained in:
Sakse Dalum 2012-08-08 15:22:27 +02:00
parent 42610349b7
commit 8490b2cbfe
2 changed files with 24 additions and 22 deletions

View File

@ -84,30 +84,32 @@ class Player(worldobject.WorldObject):
def update(self, e, t, dt):
for event in e:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
if not self.holding:
self.direction = (0, -1)
self.anim = 'idle_up'
self.move(0, -1)
if event.key == pygame.K_DOWN:
if not self.holding:
self.direction = (0, 1)
self.anim = 'idle_down'
self.move(0, 1)
if event.key == pygame.K_RIGHT:
if not self.holding:
self.direction = (1, 0)
self.anim = 'idle_right'
self.move(1, 0)
if event.key == pygame.K_LEFT:
if not self.holding:
self.direction = (-1, 0)
self.anim = 'idle_left'
self.move(-1, 0)
if event.key == pygame.K_SPACE:
self.touch(*self.direction)
keys = pygame.key.get_pressed()
if keys[pygame.K_UP]:
if not self.holding:
self.direction = (0, -1)
self.anim = 'idle_up'
self.move(0, -1)
if keys[pygame.K_DOWN]:
if not self.holding:
self.direction = (0, 1)
self.anim = 'idle_down'
self.move(0, 1)
if keys[pygame.K_RIGHT]:
if not self.holding:
self.direction = (1, 0)
self.anim = 'idle_right'
self.move(1, 0)
if keys[pygame.K_LEFT]:
if not self.holding:
self.direction = (-1, 0)
self.anim = 'idle_left'
self.move(-1, 0)
# Update the animation
self.frame = ((self.frame + self.anim_speed * dt) %
len(self.imgs[self.anim]))

View File

@ -29,7 +29,7 @@ import numpy
import copy
class WorldObject(object):
def __init__(self, level, x, y, z=0, direction=(1, 0), speed=5,
def __init__(self, level, x, y, z=0, direction=(1, 0), speed=4,
tile_x=64, tile_y=48,
movable=False):
self.__dict__.update(locals())