Exemplo n.º 1
0
 def __init__(self):
     self.screen = pygame.display.set_mode([Game.WIDTH, Game.HEIGHT])
     pygame.display.set_caption('the orange box')
     self.clock = pygame.time.Clock()
     self.state_manager = StateManager(
         [MenuState(), GameState(), DeathState()], 1)
     self.start()
Exemplo n.º 2
0
 def __init__(self, verbose=True):
     self.curr_state = GameState()
     self.agents = [
         RandomPieceGenerator(PIECE_GENERATOR_AGENT_INDEX),
         ExpectimaxAgent(PLAYER_AGENT_INDEX, 3, 2)
     ]
     self.agent_index = 0
     self.verbose = verbose
Exemplo n.º 3
0
import pygame
from constants import *
import utils
from states import GameState

# TODO: add an animation module for pygame surfaces

running = True if pygame.display.get_surface() is not None else False

# set up clock for limiting framerate and getting dt
clock = pygame.time.Clock()

states = utils.StateStack()  # Stack that holds all the States
state_data = dict(screen=screen, states=states)
states.push(GameState(state_data))

# ====== Main Game Loop ======

while running:
    clock.tick(FPS)
    dt = clock.get_time() / 1000

    # Update
    if states.isEmpty() is not True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            states.top().update_events(dt, event)

        states.top().update(dt)
        if states.top().get_quit():