コード例 #1
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     
     panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
     nb = wx.Notebook(panel)
     
     cd = CharacterData(nb)
     cs = CharacterSprites(nb)
     ht = HitBox(nb)
     an = Animations(nb)
     sc = SparksCharacter(nb)
     co = Commands(nb)
     hc = HitStatesCharacter(nb)
     fm = FSM(nb)
     ai = AI(nb)
     
     nb.AddPage(cd, "Data")
     nb.AddPage(cs, "Sprites")
     nb.AddPage(ht, "Hitbox")
     nb.AddPage(an, "Animations")
     nb.AddPage(sc, "Sparks")
     nb.AddPage(co, "Commands")
     nb.AddPage(hc, "HitStates")
     nb.AddPage(fm, "FSM")
     nb.AddPage(ai, "AI")
     
     sizer = wx.BoxSizer()
     sizer.Add(nb, 1, wx.EXPAND)
     
     self.SetSizer(sizer)
コード例 #2
0
    def update(self):
        screen.fill(BLACK)
        screen.blit(self.moving_background.image, self.moving_background.rect)
        screen.blit(self.moving_background_2.image,
                    self.moving_background_2.rect)
        self.obstacles.draw(screen)
        self.draw_instruction_panel()
        screen.blit(self.playerShip.image, self.playerShip.rect)
        if self.moving_background.rect.right <= 0:
            self.moving_background.rect.left = self.moving_background_2.rect.right - back_overlap
        if self.moving_background_2.rect.right <= 0:
            self.moving_background_2.rect.left = self.moving_background.rect.right - back_overlap
        self.obstacles.move(WIDTH)
        self.moving_background_2.move()
        self.moving_background.move()
        pygame.draw.line(screen, WHITE, (WIDTH / 2, self.visual_screen[1] + 1),
                         (WIDTH / 2, HEIGHT), 5)
        self.draw_score_and_health()
        if self.playerShip.fuel > 0:
            keys = pygame.key.get_pressed()
            self.playerShip.input(keys)
        self.playerShip.move(self.speed, self.visual_screen[1])
        damage_and_point = self.obstacles.check_collision(self.playerShip)
        if damage_and_point[0]:
            if self.collision_ended:
                point = damage_and_point[1][
                    0] - size_of_explosion + 28, damage_and_point[1][
                        1] - size_of_explosion
                # 28 is the only hard coded variable we have x_x, but we have no choice.
                self.explosion = Animations(
                    (size_of_explosion, size_of_explosion), explosion_image,
                    point)
                self.playerShip.damage(damage_and_point[0])
                if self.sfx_on:
                    self.crash_sound.play()
                self.collision_ended = False
                if self.playerShip.fuel >= collision_fuel_punishment:
                    self.playerShip.fuel -= collision_fuel_punishment
                else:
                    self.playerShip.fuel = 0

            if self.explosion != 0:
                self.explosion.update_animation(self.timer)
        else:
            self.collision_ended = True
        pygame.display.update()