pytron/play.py

30 lines
628 B
Python
Raw Normal View History

2018-10-23 16:27:27 +02:00
#!/usr/bin/env python3
2018-12-13 10:57:22 +01:00
import contextlib
with contextlib.redirect_stdout(None):
import pygame
2018-10-23 16:27:27 +02:00
2019-03-13 18:21:04 +01:00
from tron.map import Map
from tron.game import Game, PositionPlayer
from tron.window import Window
from tron.player import Player, Direction, ConstantPlayer, KeyboardPlayer
2018-10-23 16:27:27 +02:00
def main():
pygame.init()
width = 40
height = 40
game = Game(width, height, [
2019-03-13 17:27:56 +01:00
PositionPlayer(1, KeyboardPlayer(Direction.RIGHT), [0, 0]),
PositionPlayer(2, ConstantPlayer(Direction.LEFT), [width - 1, height - 1]),
2018-10-23 16:27:27 +02:00
])
2018-12-13 11:27:41 +01:00
window = Window(game, 20)
2018-10-23 16:27:27 +02:00
game.main_loop(window)
if __name__ == '__main__':
main()