Exemplo n.º 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())
Exemplo n.º 2
0
    def update(self, dt):
        State.update(self, dt)

        if time.time() > self.started + 3000:
            self.ended = True
        else:
            self.sprite.update(dt)
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 5
0
    def update(self, dt):
        State.update(self, dt)

        if time.time() > self.started + 3000:
            self.ended = True
        else:
            self.sprite.update(dt)
Exemplo n.º 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)
Exemplo n.º 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)
        ]
Exemplo n.º 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)
        ]
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 17
0
    def update(self, dt):
        State.update(self, dt)

        for character in self.characters:
            character.update(dt)
Exemplo n.º 18
0
    def draw(self, rgb):
        State.draw(self, rgb)

        self.sprite.draw(rgb)
Exemplo n.º 19
0
    def draw(self, rgb):
        State.draw(self, rgb)

        self.sprite.draw(rgb)
Exemplo n.º 20
0
 def onClampedAxisChanged(self, player, x, y):
     State.onClampedAxisChanged(self, player, x, y)
     self.ship.position.x += x
Exemplo n.º 21
0
    def __init__(self):
        State.__init__(self, "GameOver")

        self.started = time.time()
        self.sprite = FullscreenSprite(RED)
Exemplo n.º 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)
Exemplo n.º 23
0
 def onEnter(self, old_state):
     State.onEnter(self, old_state)
     print old_state
     self.reset()
Exemplo n.º 24
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)
Exemplo n.º 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')
Exemplo n.º 26
0
    def update(self, dt):
        State.update(self, dt)

        for character in self.characters:
            character.update(dt)
Exemplo n.º 27
0
 def onClampedAxisChanged(self, player, x, y):
     State.onClampedAxisChanged(self, player, x, y)
     self.ship.position.x += x
Exemplo n.º 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)
Exemplo n.º 29
0
 def onEnter(self, old_state):
     State.onEnter(self, old_state)
     print old_state
     self.reset()
Exemplo n.º 30
0
    def draw(self, rgb):
        State.draw(self, rgb)

        for character in self.characters:
            character.draw(rgb)
Exemplo n.º 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')
Exemplo n.º 32
0
    def __init__(self):
        State.__init__(self, "GameOver")

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