Beispiel #1
0
import pygame
from Engine.Engine import Engine

class ExampleGame(object):
    def __init__(self):
        self.box = [32, 32]
        self.move_step = 8
    
    def draw(self, canvas):
        pygame.draw.rect(canvas, (100, 0, 100), (self.box[0], self.box[1], 25, 25))

    def update(self, dt):
        pass
    
    def handle_event(self, event):
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP:
                self.box[1] -= self.move_step
            elif event.key == pygame.K_DOWN:
                self.box[1] += self.move_step
            elif event.key == pygame.K_LEFT:
                self.box[0] -= self.move_step
            elif event.key == pygame.K_RIGHT:
                self.box[0] += self.move_step

if __name__ == "__main__":
    e = Engine(ExampleGame)
    e.game_loop()
Beispiel #2
0
from Engine.Engine import Engine
from GameManager import GameManager

if __name__ == "__main__":
    e = Engine(GameManager)
    e.game_loop()
Beispiel #3
0
def main():
    set_base_folder("assets/images/")
    e = Engine(Game)
    e.game_loop()