Not really sure what I did ... but some sort of improvement.
This commit is contained in:
parent
42610349b7
commit
8490b2cbfe
|
@ -84,29 +84,31 @@ 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 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 event.key == pygame.K_DOWN:
|
||||
if keys[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 keys[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 keys[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)
|
||||
|
||||
# Update the animation
|
||||
self.frame = ((self.frame + self.anim_speed * dt) %
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue