Пример #1
0
    def __init__(self):
        State.__init__(self, "Game")

        self.characterPosition = Vector(5, 7)

        self.character_colors = [RED, BLUE, WHITE, ORANGE, PURPLE]
        self.background_color = BLACK
        self.wall_color = Color.multiply(GREEN, 0.5)

        self.map = []
        self.offset = 0.0
        self.initial_scroll_speed = self.scroll_speed = 0.5
        self.scroll_speed_increment = 0.1
        self.sharpness = 1.1

        self.ship_steer_speed = 0.1

        self.ship = Ship(Vector(6, 1), self.character_colors[0],
                         Color.multiply(self.character_colors[0], 0.8))

        self.simulationPause = False

        self.sprites = []

        for y in range(PIXEL_DIM_Y * 2 + 1):
            self.map.append(self.generate_map_slice())
Пример #2
0
    def update(self, dt):
        State.update(self, dt)

        if time.time() > self.started + 3000:
            self.ended = True
        else:
            self.sprite.update(dt)
Пример #3
0
    def __init__(self):
        State.__init__(self, "Game")

        self.characterPosition = Vector(5, 7)

        self.character_colors = [RED, BLUE, WHITE, ORANGE, PURPLE]
        self.background_color = BLACK
        self.wall_color = Color.multiply(GREEN, 0.5)

        self.map = []
        self.offset = 0.0
        self.initial_scroll_speed = self.scroll_speed = 0.5
        self.scroll_speed_increment = 0.1
        self.sharpness = 1.1

        self.ship_steer_speed = 0.1

        self.ship = Ship(Vector(6, 1), self.character_colors[0], Color.multiply(self.character_colors[0], 0.8))

        self.simulationPause = False

        self.sprites = []

        for y in range(PIXEL_DIM_Y*2 + 1):
            self.map.append(self.generate_map_slice())
Пример #4
0
    def update(self, dt):
        State.update(self, dt)

        self.lastJump += dt
        if self.lastJump > 2:
            self.point = Vector.random([PIXEL_DIM_X-1, PIXEL_DIM_Y-1])
            self.lastJump = 0

        if self.explosion:
            self.explosion.update(dt)

        for character in self.characters:
            character.update(dt)

            if character.position.toInt() == self.point.toInt():
                character.score += 1
                character.animation.duration = 1.0/character.score 

                self.point = Vector.random([PIXEL_DIM_X-1, PIXEL_DIM_Y-1])

                if character.score > 5:
                    character.score = 0
                    character.animation.duration = 1.0

                    self.explosion = Explosion(character.position)
Пример #5
0
    def update(self, dt):
        State.update(self, dt)

        if time.time() > self.started + 3000:
            self.ended = True
        else:
            self.sprite.update(dt)
Пример #6
0
    def update(self, dt):
        State.update(self, dt)

        self.lastJump += dt
        if self.lastJump > 2:
            self.point = Vector.random([PIXEL_DIM_X - 1, PIXEL_DIM_Y - 1])
            self.lastJump = 0

        if self.explosion:
            self.explosion.update(dt)

        for character in self.characters:
            character.update(dt)

            if character.position.toInt() == self.point.toInt():
                character.score += 1
                character.animation.duration = 1.0 / character.score

                self.point = Vector.random([PIXEL_DIM_X - 1, PIXEL_DIM_Y - 1])

                if character.score > 5:
                    character.score = 0
                    character.animation.duration = 1.0

                    self.explosion = Explosion(character.position)
Пример #7
0
    def __init__(self):
        State.__init__(self, "Main")

        w = PIXEL_DIM_X - 1
        h = PIXEL_DIM_Y - 1

        self.characters = [
            AnimatedGameObject(Vector(0, 0), RED),
            AnimatedGameObject(Vector(w, 0), BLUE),
            AnimatedGameObject(Vector(0, h), GREEN),
            AnimatedGameObject(Vector(w, h), YELLOW)
        ]
Пример #8
0
    def __init__(self):
        State.__init__(self, "Main")

        w = PIXEL_DIM_X - 1
        h = PIXEL_DIM_Y - 1

        self.characters = [
            AnimatedGameObject(Vector(0, 0), RED),
            AnimatedGameObject(Vector(w, 0), BLUE),
            AnimatedGameObject(Vector(0, h), GREEN),
            AnimatedGameObject(Vector(w, h), YELLOW)
        ]
Пример #9
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)

        if self.explosion:
            self.explosion.draw(rgb)

            if self.explosion.ended:
                self.explosion = None

        if self.point:
            rgb.setPixel(self.point, TURQUE)
Пример #10
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)

        if self.explosion:
            self.explosion.draw(rgb)

            if self.explosion.ended:
                self.explosion = None

        if self.point:
            rgb.setPixel(self.point, TURQUE)
Пример #11
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for y in range(PIXEL_DIM_Y):
            left, right = self.map[y][0], self.map[y][1]

            for lx in range(left):
                pixel = Vector(lx, y)
                rgb.setPixel(pixel, self.wall_color)
            for rx in range(right):
                pixel = Vector(PIXEL_DIM_X - 1 - rx, y)
                rgb.setPixel(pixel, self.wall_color)

        self.ship.draw(rgb)

        for sprite in self.sprites:
            sprite.draw(rgb)
Пример #12
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for y in range(PIXEL_DIM_Y):
            left, right = self.map[y][0], self.map[y][1]

            for lx in range(left):
                pixel = Vector(lx, y)
                rgb.setPixel(pixel, self.wall_color)
            for rx in range(right):
                pixel = Vector(PIXEL_DIM_X - 1 - rx, y)
                rgb.setPixel(pixel, self.wall_color)

        self.ship.draw(rgb)

        for sprite in self.sprites:
            sprite.draw(rgb)
Пример #13
0
    def update(self, dt):
        State.update(self, dt)

        self.offset += self.scroll_speed * dt
        self.scroll_speed += self.scroll_speed_increment * dt

        if self.offset >= 1.0:
            while self.offset >= 1.0:
                self.offset -= 1.0

            self.check_collision()

            del self.map[0]
            self.map.append(self.generate_map_slice())

        self.ship.update(dt)
        self.ship.animation.duration = 1.0 / self.scroll_speed

        self.sprites = [sprite for sprite in self.sprites if not sprite.ended]
        for sprite in self.sprites:
            sprite.update(dt)
Пример #14
0
    def update(self, dt):
        State.update(self, dt)

        self.offset += self.scroll_speed * dt
        self.scroll_speed += self.scroll_speed_increment * dt

        if self.offset >= 1.0:
            while self.offset >= 1.0:
                self.offset -= 1.0

            self.check_collision()

            del self.map[0]
            self.map.append(self.generate_map_slice())

        self.ship.update(dt)
        self.ship.animation.duration = 1.0/self.scroll_speed

        self.sprites = [sprite for sprite in self.sprites if not sprite.ended]
        for sprite in self.sprites:
            sprite.update(dt)
Пример #15
0
    def __init__(self):
        State.__init__(self, "Main")

        w = PIXEL_DIM_X - 1
        h = PIXEL_DIM_Y - 1

        self.point = Vector(6, 4)

        self.characters = [
            AnimatedGameObject(Vector(0, 0), RED, BLUE),
            AnimatedGameObject(Vector(w, 0), BLUE, RED),
            AnimatedGameObject(Vector(0, h), GREEN, BLUE),
            AnimatedGameObject(Vector(w, h), YELLOW, BLUE)
        ]

        self.explosion = None

        for character in self.characters:
            character.score = 0

        self.lastJump = 0
Пример #16
0
    def __init__(self):
        State.__init__(self, "Main")


        w = PIXEL_DIM_X - 1
        h = PIXEL_DIM_Y - 1

        self.point = Vector(6, 4)

        self.characters = [
            AnimatedGameObject(Vector(0, 0), RED, BLUE),
            AnimatedGameObject(Vector(w, 0), BLUE, RED),
            AnimatedGameObject(Vector(0, h), GREEN, BLUE),
            AnimatedGameObject(Vector(w, h), YELLOW, BLUE)
        ]

        self.explosion = None

        for character in self.characters:
            character.score = 0

        self.lastJump = 0
Пример #17
0
    def update(self, dt):
        State.update(self, dt)

        for character in self.characters:
            character.update(dt)
Пример #18
0
    def draw(self, rgb):
        State.draw(self, rgb)

        self.sprite.draw(rgb)
Пример #19
0
    def draw(self, rgb):
        State.draw(self, rgb)

        self.sprite.draw(rgb)
Пример #20
0
 def onClampedAxisChanged(self, player, x, y):
     State.onClampedAxisChanged(self, player, x, y)
     self.ship.position.x += x
Пример #21
0
    def __init__(self):
        State.__init__(self, "GameOver")

        self.started = time.time()
        self.sprite = FullscreenSprite(RED)
Пример #22
0
 def onButtonChanged(self, player, a_button, b_button, previous_a_button, previous_b_button):
     State.onButtonChanged(self, player, a_button, b_button, previous_a_button, previous_b_button)
Пример #23
0
 def onEnter(self, old_state):
     State.onEnter(self, old_state)
     print old_state
     self.reset()
Пример #24
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)
Пример #25
0
    def onAxisChanged(self, player, x, y, px, py):
        State.onAxisChanged(self, player, x, y, px, py)

        self.characters[player].velocity = Vector(x, y)

        self.game.playSound('tock')
Пример #26
0
    def update(self, dt):
        State.update(self, dt)

        for character in self.characters:
            character.update(dt)
Пример #27
0
 def onClampedAxisChanged(self, player, x, y):
     State.onClampedAxisChanged(self, player, x, y)
     self.ship.position.x += x
Пример #28
0
 def onButtonChanged(self, player, a_button, b_button, previous_a_button,
                     previous_b_button):
     State.onButtonChanged(self, player, a_button, b_button,
                           previous_a_button, previous_b_button)
Пример #29
0
 def onEnter(self, old_state):
     State.onEnter(self, old_state)
     print old_state
     self.reset()
Пример #30
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)
Пример #31
0
    def onAxisChanged(self, player, x, y, px, py):
        State.onAxisChanged(self, player, x, y, px, py)

        self.characters[player].velocity = Vector(x, y)

        self.game.playSound('tock')
Пример #32
0
    def __init__(self):
        State.__init__(self, "GameOver")

        self.started = time.time()
        self.sprite = FullscreenSprite(RED)