Exemplo n.º 1
0
 def create_check(self, a, b, loading = False):
   self.history.append("check")
   if loading == False:
     self.manager.create_check(a, b)
   new_road = Road(a, b, (0, 255, 0))
   self.checks_obj.append(new_road)
   gamestate.create(new_road)
Exemplo n.º 2
0
 def set_start(self, a, b):
     if self.start_obj != None:
         gamestate.delete(self.start_obj)
         self.start_obj = None
     new_road = Road(a, b, (0, 0, 255))
     self.start_obj = new_road
     gamestate.create(new_road)
Exemplo n.º 3
0
 def create_road(self, a, b, loading = False):
   self.history.append("road")
   if loading == False:
     self.manager.create_road(a, b)
   new_road = Road(a, b, (255, 255, 255))
   self.roads_obj.append(new_road)
   gamestate.create(new_road)
Exemplo n.º 4
0
 def set_start(self, a, b, loading = False):
   if self.start_obj != None:
     gamestate.delete(self.start_obj)
     self.start_obj = None
   new_road = Road(a, b, (0, 0, 255))
   if loading == False:
     self.manager.set_start(a, b)
   self.start_obj = new_road
   gamestate.create(new_road)
Exemplo n.º 5
0
 def start(self):
     super().start()
     self.manager = RoadIO()
     self.start_obj = None
     self.roads_obj = []
     self.checks_obj = []
     if len(sys.argv) == 2:
         self.manager.load(sys.argv[1])
     for r in self.manager.roads:
         self.create_road(r[0], r[1])
     for r in self.manager.checks:
         self.create_check(r[0], r[1])
     self.set_start(self.manager.start_pos[0], self.manager.start_pos[1])
     car = Car(self.manager)
     pos = ((self.manager.start_pos[0].x + self.manager.start_pos[1].x) / 2,
            (self.manager.start_pos[0].y + self.manager.start_pos[1].y) / 2)
     angle = 90 + math.degrees(
         math.atan2(
             self.manager.start_pos[1].y - self.manager.start_pos[0].y,
             self.manager.start_pos[1].x - self.manager.start_pos[0].x))
     car.local_position = pygame.Vector2(pos)
     car.rotation = angle
     gamestate.create(car)
Exemplo n.º 6
0
 def update(self):
   super().update()
   for s in self.saves:
     if inputs.is_key_clicked(s[0]):
       self.save(s[1])
   if inputs.is_key_clicked(K_z):
     self.undo()
   if inputs.is_mouse_clicked(1):
     if self.tracing == None:
       self.tracing = "road"
       tmp_road = TmpRoad((255, 255, 255))
       self.current_road = tmp_road
       gamestate.create(tmp_road)
     elif self.tracing == "road":
       self.tracing = None
       mouse_pos = inputs.get_mouse()
       self.create_road(self.current_road.start_pos, mouse_pos)
       gamestate.delete(self.current_road)
   if inputs.is_mouse_clicked(2):
     if self.tracing == None:
       self.tracing = "start"
       tmp_road = TmpRoad((0, 0, 255))
       self.current_road = tmp_road
       gamestate.create(tmp_road)
     elif self.tracing == "start":
       self.tracing = None
       mouse_pos = inputs.get_mouse()
       self.set_start(self.current_road.start_pos, mouse_pos)
       gamestate.delete(self.current_road)
   if inputs.is_mouse_clicked(3):
     if self.tracing == None:
       self.tracing = "check"
       tmp_road = TmpRoad((0, 255, 0))
       self.current_road = tmp_road
       gamestate.create(tmp_road)
     elif self.tracing == "check":
       self.tracing = None
       mouse_pos = inputs.get_mouse()
       self.create_check(self.current_road.start_pos, mouse_pos)
       gamestate.delete(self.current_road)
Exemplo n.º 7
0
import os, sys, inspect
current_dir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)

from engine import gamestate, entry
from game.car import Car
from editor.road_manager import RoadManager

rm = RoadManager()
gamestate.create(rm)

entry.launch()
Exemplo n.º 8
0
 def add_child(self, obj):
     obj.parent = self
     self.children.append(obj)
     gamestate.create(obj)
Exemplo n.º 9
0
 def create_check(self, a, b):
     new_road = Road(a, b, (0, 255, 0))
     self.checks_obj.append(new_road)
     gamestate.create(new_road)
Exemplo n.º 10
0
 def create_road(self, a, b):
     new_road = Road(a, b, (255, 255, 255))
     self.roads_obj.append(new_road)
     gamestate.create(new_road)
Exemplo n.º 11
0
import os, sys, inspect

current_dir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)

from engine import gamestate, entry
from game.car import Car
from game.road_manager import RoadManager
from game.map_runner import MapRunner
from game.point import Point
import pygame

rm = RoadManager()
gamestate.create(rm)
runner = MapRunner()
gamestate.create(runner)
# gamestate.create(Car())
entry.launch()