for k in key_states:
if k.key == pygame.K_UP:
dy = -1 * MOVESPEEDY * dt
#etc for all the movement keys
# Lets get to savin peeps
import pygame, sys
import constants
import os.path
from pygame.locals import *
pygame.init()
class Player(object):
def __init__(self):
self.color = constants.WHITE
self.position = None
#Can't remember why I put this here.
def place(self, position):
self.position = position
def draw(self, surface):
(ix, iy) = (int(self.position[0]), int(self.position[1]))
pygame.draw.circle(surface, self.color, (ix, iy,), 15)
def movementPlayer(self, dt, key_states, key_pressed):
#Heres our controls
dx = 0
dy = 0
# key_states is a variable in main.py that reads
# key_states = pygame.event.get(pygame.KEYDOWN)
if key_states[pygame.K_DOWN]:
dy = 1 * constants.MOVESPEEDY * dt
if key_states[pygame.K_UP]:
dy = -1 * constants.MOVESPEEDY * dt
if key_states[pygame.K_LEFT]:
dx = -1 * constants.MOVESPEEDY * dt
if key_states[pygame.K_RIGHT]:
dx = 1 * constants.MOVESPEEDY * dt
(x, y) = self.position
self.position = (x + dx, y + dy)