2013-01-07 22:04:37 -04:30
|
|
|
# Miguel Angel Astor Romero. Created on 7-1-2013. #
|
2013-01-07 20:22:23 -04:30
|
|
|
###################################################
|
2013-01-08 08:30:30 -04:30
|
|
|
import pygame
|
2013-01-07 20:22:23 -04:30
|
|
|
|
|
|
|
|
# Valid game states.
|
|
|
|
|
VALID_STATES = { 'INTRO':0, 'MENU':1, 'IN_GAME':2, 'SCORE':3, 'STAY':4, 'QUIT':89}
|
|
|
|
|
|
|
|
|
|
# Parent class for game states.
|
|
|
|
|
class BaseState:
|
2013-01-09 22:34:15 -04:30
|
|
|
def __init__(self):
|
|
|
|
|
self.background_color = (139, 210, 228)
|
2013-01-19 10:07:01 -04:30
|
|
|
self.screen_center = (pygame.display.Info().current_w / 2, pygame.display.Info().current_h / 2)
|
2013-01-09 22:34:15 -04:30
|
|
|
|
2013-01-07 20:22:23 -04:30
|
|
|
def input(self):
|
|
|
|
|
""" Empty. Should handle PyGame input. """
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
|
""" Empty. Should update the state. Returns a state to transition to. """
|
|
|
|
|
return VALID_STATES['STAY']
|
|
|
|
|
|
|
|
|
|
def render(self, canvas):
|
|
|
|
|
""" Empty. Should render this state on the canvas. """
|
2013-01-09 22:34:15 -04:30
|
|
|
canvas.fill(self.background_color)
|
2013-01-08 08:30:30 -04:30
|
|
|
|
|
|
|
|
def get_screen_center(self):
|
2013-01-19 10:07:01 -04:30
|
|
|
return self.screen_center
|