Ejemplo n.º 1
0
def run():
    # 初始化设置选项
    ai_settings = Settings()
    func.clean_img(ai_settings)

    # 初始化小车
    car = Car(ai_settings)

    # 初始化深度学习模型
    dlmodel = DLmodel(ai_settings)

    # 初始化算法控制系统
    algo = AlgoControl(ai_settings, car)

    # 创建一个状态类, 用以储存标志物状态
    markstats = MarkStatus()

    # 开始任务的主循环
    while True:
        func.get_image(ai_settings, car, dlmodel)

        algo.angle_prep = func.predict_angle(ai_settings, dlmodel)
        car.angle = ai_settings.angle_formula(algo.angle_prep)

        func.get_label_para(ai_settings, dlmodel, markstats)
        func.algorithmal_control(ai_settings, car, markstats, algo)
Ejemplo n.º 2
0
 def __init__(self, x, y):
     self.x = x
     self.y = y
     self.pos = (x*16, y*16)
     self.rect = pygame.Rect(self.pos, (16,16))
     self.image = functions.get_image(os.path.join('resources','map_tiles','map_mountain.bmp'), (255,0,255))
     Entity.__init__(self, globals.group_tiles, globals.group_unwalkable)
Ejemplo n.º 3
0
def run_line():
    # 初始化设置选项
    ai_settings = Settings()
    func.clean_img(ai_settings)

    # 初始化小车
    car = Car(ai_settings)

    # 初始化深度学习模型
    dlmodel = DLmodel(ai_settings)

    # 开始任务的主循环
    while True:
        func.get_image(ai_settings, car, dlmodel)
        angle_prep = func.predict_angle(ai_settings, dlmodel)
        angle = ai_settings.angle_formula(angle_prep)
        car.update(angle=angle)
Ejemplo n.º 4
0
 def __init__(self, x, y):
     self.x = x
     self.y = y
     self.pos = (x * 16, y * 16)
     self.rect = pygame.Rect(self.pos, (16, 16))
     self.image = functions.get_image(
         os.path.join('resources', 'map_tiles', 'map_mountain.bmp'),
         (255, 0, 255))
     Entity.__init__(self, globals.group_tiles, globals.group_unwalkable)
Ejemplo n.º 5
0
def follow():
    # 初始化设置选项
    ai_settings = Settings()
    func.clean_img(ai_settings)

    # 初始化小车
    car = Car(ai_settings)

    # 初始化深度学习模型
    dlmodel = DLmodel(ai_settings, follow_flag=True)

    # 创建一个状态类, 用以储存标志物状态
    markstats = MarkStatus()

    # 开始任务的主循环
    while True:
        func.get_image(ai_settings, car, dlmodel)
        func.get_follow_para(ai_settings, dlmodel, markstats)
        func.update_follow_para(ai_settings, car, dlmodel, markstats)
Ejemplo n.º 6
0
 def __init__(self, x, y):
     Entity.__init__(self, globals.group_player)
     globals.player_map = self
     self.currenttile = (x/16, y/16)
     self.desttile = (0,0)
     self.x = x*16.0
     self.y = y*16.0
     self.xvel = 0.0
     self.yvel = 0.0
     self.keydown = {'LEFT':False, 'RIGHT':False, 'UP':False, 'DOWN':False}
     self.key_pressed = False
     self.image = functions.get_image(os.path.join('resources', 'player_map','player_map.bmp'), (255,0,255))
     self.pos = (x,y)
     self.moving = False
     self.rect = pygame.Rect(x, y, 16, 16)
Ejemplo n.º 7
0
 def __init__(self, x, y):
     Entity.__init__(self, globals.group_player)
     globals.player_map = self
     self.currenttile = (x / 16, y / 16)
     self.desttile = (0, 0)
     self.x = x * 16.0
     self.y = y * 16.0
     self.xvel = 0.0
     self.yvel = 0.0
     self.keydown = {
         'LEFT': False,
         'RIGHT': False,
         'UP': False,
         'DOWN': False
     }
     self.key_pressed = False
     self.image = functions.get_image(
         os.path.join('resources', 'player_map', 'player_map.bmp'),
         (255, 0, 255))
     self.pos = (x, y)
     self.moving = False
     self.rect = pygame.Rect(x, y, 16, 16)
Ejemplo n.º 8
0
def start_game(fps, starting_scene):
    # set clock
    clock = pygame.time.Clock()

    # set frame itself, title and icon of the frame
    pygame.display.set_icon(functions.get_image('img/logo-32.png'))
    pygame.display.set_caption("Space Bottle")

    # set default volume
    pygame.mixer.music.set_volume(scenes_and_characters.music_volume / 100)
    for sound in scenes_and_characters.sounds:
        sound.set_volume(scenes_and_characters.sounds_volume / 100)

    # set active scene
    active_scene = starting_scene

    while active_scene is not None:
        pressed_keys = pygame.key.get_pressed()
        filtered_events = []

        for event in pygame.event.get():
            quit_attempt = False
            if event.type == pygame.QUIT:
                quit_attempt = True
            if quit_attempt:
                active_scene.terminate()
            else:
                filtered_events.append(event)

        active_scene.event_handling(filtered_events)
        active_scene.render()
        active_scene.update(pressed_keys)

        active_scene = active_scene.next
        clock.tick(fps)

        pygame.display.update()
Ejemplo n.º 9
0
def load_title():
        bg = Entities.Menu_BG(functions.get_image(os.path.join('Resources','General Resources','TitleScreenFinal.png'), (0,0,0)))
        playbutt = Entities.Menu_PlayButt(359,330)
        quitbutt = Entities.Menu_QuitButt(359,450)