forked from Hidgik/pygame_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAITrainer.py
70 lines (57 loc) · 2.06 KB
/
AITrainer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import sys
from Boat.AIController import AIController
from Boat.BaseBoat import BaseBoat
from Boat.KeyboardController import KeyboardController
from Boat.SimpleController import SimpleController
from Game import Game
import pygame as pg
import pymunk
from Boat.RadarManager import RadarManager
import Config
class Main:
def __init__(self, w, h, GAME_FPS):
self.w, self.h, self.FPS = w, h, GAME_FPS
self.size = self.w, self.h
def run_game(self, is_debug=False):
pg.font.init()
Config.Screen.DEBUG = True
pymunk.pygame_util.positive_y_is_up = False
space = pymunk.Space()
radarManager = RadarManager(space, Config.Collisiontypes.SENSOR)
surface = pg.display.set_mode((self.w, self.h))
level = Config.Tracks.get_track(-1)
level.build(space)
boats = [
BaseBoat(space, radarManager, (Config.Specifications.BOATS[0]), level),
BaseBoat(space, radarManager, (Config.Specifications.BOATS[2]), level),
BaseBoat(space, radarManager, (Config.Specifications.BOATS[3]), level),
]
controllers = [
SimpleController(
boats[0], level), AIController(
boats[1], level), SimpleController(
boats[2], level), KeyboardController(
boats[0], level, pg.K_LEFT, pg.K_RIGHT, pg.K_UP, pg.K_DOWN), ]
radarManager.register_collision_type(Config.Collisiontypes.BOAT)
radarManager.register_collision_type(Config.Collisiontypes.SHORE)
radarManager.register_collision_type(Config.Collisiontypes.CHECKPOINT)
game = Game(
space,
surface,
radarManager,
boats,
controllers,
self.FPS,
level,
is_debug)
exit_code = game.run()
pg.quit()
return exit_code
if __name__ == '__main__':
FPS = 60
DEBUG = False
SIZE = WIGHT, HEIGHT = 920, 700
app = Main(WIGHT, HEIGHT, FPS)
code = app.run_game(DEBUG)
# some actions here
sys.exit(code)