Not really sure what I did ... but some sort of improvement.
This commit is contained in:
parent
42610349b7
commit
8490b2cbfe
|
@ -84,30 +84,32 @@ class Player(worldobject.WorldObject):
|
||||||
def update(self, e, t, dt):
|
def update(self, e, t, dt):
|
||||||
for event in e:
|
for event in e:
|
||||||
if event.type == pygame.KEYDOWN:
|
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:
|
if event.key == pygame.K_SPACE:
|
||||||
self.touch(*self.direction)
|
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
|
# Update the animation
|
||||||
self.frame = ((self.frame + self.anim_speed * dt) %
|
self.frame = ((self.frame + self.anim_speed * dt) %
|
||||||
len(self.imgs[self.anim]))
|
len(self.imgs[self.anim]))
|
||||||
|
|
|
@ -29,7 +29,7 @@ import numpy
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
class WorldObject(object):
|
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,
|
tile_x=64, tile_y=48,
|
||||||
movable=False):
|
movable=False):
|
||||||
self.__dict__.update(locals())
|
self.__dict__.update(locals())
|
||||||
|
|
Loading…
Reference in New Issue