コード例 #1
0
from rail import Rail, LeftRail, RightRail, StraightRail

cars = []
rails = []
for rotation in range(0, 4):
    leftrail = LeftRail(rotation)
    rightrail = RightRail(rotation)
    straightrail = StraightRail(rotation)
    rails.extend([leftrail, rightrail, straightrail])
#     #rails.append(leftrail)
#     cars.append(Car(1.0, leftrail, "CAR0",start_time=5))
#     #cars.append(Car(1.0, rightrail, "CAR1"))
#     cars.append(Car(1.0, straightrail, "CAR2"))
intersection1 = Intersection(cars, rails)
print(intersection1.rails)
intersection1.update()
# print("Cf", intersection.cars)

#rails2 = [LeftRail(0), LeftRail(1), LeftRail(2)]

# intersection2 = Intersection([
#   Car(1.0, rails2[0], 0, [(133, 1.0), (163, 0.1), (184, 0.1), (318, 0.1)]),
#   Car(1.0, rails2[1], 0, [(155, 0.1), (163, 0.1), (318, 0.1)]),
#   Car(1.0, rails2[2], 0, [(134, 0.2), (155, 0.1), (184, 0.1), (318, 0.1)]),], rails2)

# setup_view = SetupView(intersection=intersection,
#                        window_size=(800, 600),
#                        x_lanes=2,
#                        y_lanes=2)
# while not setup_view.done:
#     setup_view.tick()
コード例 #2
0
import sys

from car import Car
from gui import ZipperView, SetupView
from intersection import Intersection
from rail import Rail, LeftRail, RightRail, StraightRail

rails = []
for rotation in range(4):
    leftrail = LeftRail(rotation)
    rightrail = RightRail(rotation)
    straightrail = StraightRail(rotation)
    rails.extend([leftrail, rightrail, straightrail])

intersection = Intersection([], rails)
intersection.update()

setup_view = SetupView(intersection=intersection,
                       window_size=(800, 600),
                       x_lanes=2,
                       y_lanes=2)
while not setup_view.done:
    setup_view.tick()
    if setup_view.quitting:
        sys.exit()

kars = setup_view.cars
print("Loading")
intersection2 = Intersection(kars, rails)
intersection2.update()
print(setup_view.lane_cars)