Exemple #1
0
 def updateVelAndIntrvl(self):
     # TODO: adjast the coefs
     dif = (Score.getScore()//100)
     vel_x = self.INIT_VELOCITY_X - dif
     self.velocity = Vec(vel_x, 0)
     self.MIN_INTERVAL = 85 + 15*dif
     self.MAX_INTERVAL = 150 + 15*dif
Exemple #2
0
    def draw(self):
        global WINDOW_HEIGHT, WINDOW_WIDTH, DEBUG
        pyxel.cls(ColPal.gray_dark)
        self.backgnd.blt()
        self.enemy.blt()
        self.player.blt()

        # show score
        pyxel.text(WINDOW_WIDTH - 50, 5,
                   "HI {}  {}".format(Score.getHighScore(),
                                      Score.getScore()), ColPal.white)
        # if gameover, show restart button
        if Player.getState() == "IDLE":
            pyxel.text(WINDOW_WIDTH // 2 - 5, WINDOW_HEIGHT // 2 - 5,
                       "GAME OVER\n[SPACE] TO CONTINUE", ColPal.white)
            pyxel.blt(WINDOW_WIDTH // 2 - 48, WINDOW_HEIGHT // 2 - 16,
                      App.IMG_ID, *App.BTN_RESTART.getRect())

        if DEBUG:
            pyxel.text(0, 20, "Frame: {}".format(pyxel.frame_count),
                       ColPal.orange)
Exemple #3
0
        def iteration_run(vehicles, dummy_run: bool):
            solution_dict = {}
            nr_vecs = len(vehicles)  # +1 ADDS THE DUMMY THICC VEHICLE

            if not dummy_run:
                for vehicle in vehicles:
                    solution_dict[vehicle] = []
            else:
                vehicles = [0]
                solution_dict[0] = []

            # Go through each call
            for call in self.calls:
                # Select vehicle
                vehicle = choice(vehicles)
                if solution_dict[vehicle]:
                    solution_dict[vehicle].insert(
                        randint(0,
                                len(solution_dict[vehicle]) - 1), call)
                    solution_dict[vehicle].insert(
                        randint(0,
                                len(solution_dict[vehicle]) - 1), call)
                else:
                    solution_dict[vehicle] = [call, call]

            # # Make dict into vector
            # solution_vector = []
            # for curr_v, curr_calls in solution_dict.items():
            #     solution_vector.extend(curr_calls)
            #     solution_vector.append(0)
            #
            # # Remove last 0
            # solution_vector = solution_vector[:-1]
            solution_vector = self.dict_to_sol(solution_dict)

            ## Final
            ## Only include feasible.

            if dummy_run:  # Add zeroes to start of the only vector.
                new_sol_vector = [0 for _ in range(1, nr_vecs)]
                new_sol_vector.extend(solution_vector)
                solution_vector = new_sol_vector

            feasibility, log = feasibility_check(solution_vector, prob)
            if feasibility:
                cost = cost_function(solution_vector, prob)
                return Score(solution_vector, cost)
Exemple #4
0
    def update(self):
        self.backgnd.update()  # execution order: back layer to front layer
        self.enemy.update()
        self.player.update()

        # score update
        if Player.getState() != "IDLE":
            Score.update()

        # === Restart ===
        if Player.getState() == "IDLE":
            if pyxel.btnp(pyxel.KEY_SPACE):
                Score.saveHighScore()
                # initialize state
                Score.initialize()
                self.backgnd.initialize()
                self.enemy.initialize()
                self.player.initialize()
                music.start_music()
Exemple #5
0
 def updateVel(self):
     # TODO: adjast the coefs
     dif = (Score.getScore()//100)
     vel_x = self.INIT_VELOCITY_X - dif
     self.velocity = Vec(vel_x, 0)