Esempio n. 1
0
    def __init__(self, scene):
        self.scene = scene

        self.walking_left = mindu.Animation(directory='animations/pig-walking',
                                            redraw=5)

        self.walking_right = self.walking_left.flip(True, False)

        self.aiming_left = mindu.Image(file='images/pig-aiming.png',
                                       midbottom=(mindu.screen.centerx,
                                                  mindu.screen.bottom - 10))

        self.aiming_right = self.aiming_left.flip(True, False)
        self.aiming_up = mindu.Image('images/pig-aiming-up.png')

        self.explosion = mindu.Animation(directory='animations/pig-explosion',
                                         redraw=2,
                                         repeat=False)

        self.sprite = self.aiming_left

        self.alive = True
        self.shooting = False
        self.walking = False
        self.aiming = 'left'
        self.side = 'left'
        self.speed = 3
Esempio n. 2
0
    def __init__(self):
        self.music_channel = mindu.channels[0]
        self.effects_channel = mindu.channels[1]

        self.pig_ok_sound = mindu.Sound('sounds/pig-ok!.ogg')
        self.choir_sound = mindu.Sound('sounds/choir.ogg')
        self.music_sound = mindu.Sound('sounds/title-music.ogg')

        title_sprite = mindu.Label(text='Fire, Pig, Fire!',
                                   font='fonts/biting.ttf',
                                   size=40,
                                   color=(1.0, 0.7, 0.7, 1.0),
                                   centerx=mindu.screen.centerx,
                                   top=mindu.screen.top + 20)

        logo_sprite = mindu.Image(file='images/logo.png',
                                  alpha=False,
                                  centerx=title_sprite.centerx,
                                  top=title_sprite.bottom + 20)

        message_sprite = mindu.Label(text='Press return to play',
                                     font='fonts/biting.ttf',
                                     size=20,
                                     color=(1.0, 0.7, 0.7, 1.0),
                                     centerx=logo_sprite.centerx,
                                     top=logo_sprite.bottom + 20)

        self.sprites = (title_sprite, logo_sprite, message_sprite)

        self.music_channel.play(self.music_sound, -1, 0, 2000)
        self.effects_channel.play(self.choir_sound)

        mindu.screen.bright = 0.0
        mindu.loop.on_iterate(self.fadein)
Esempio n. 3
0
    def set_cursor(self, cursor):
        """
        set_cursor(cursor) -> None

        Define o cursor do mouse.

        O argumento "cursor" é um objeto Image. Também pode ser None, para que o
        cursor padrão seja utilizado.
        """

        if (cursor is not None) and (not isinstance(cursor, mindu.Image)):
            raise TypeError(
                'set_cursor(): o argumento "cursor" precisa ser um objeto Image ou None'
            )

        if cursor is None:
            cursor = os.path.dirname(os.path.abspath(__file__))
            cursor = os.path.join(cursor, 'cursor.png')
            cursor = mindu.Image(cursor, True)

        self._cursor = cursor
Esempio n. 4
0
    def set_icon(self, image):
        """
        set_icon(image) -> None

        Define o ícone utilizado quando a tela está em modo janela.

        O argumento "image" é um objeto Image. Também pode ser None para
        restaurar o ícone padrão.
        """

        if (image is not None) and (not isinstance(image, mindu.Image)):
            raise TypeError(
                'set_icon(): o argumento "image" precisa ser um objeto Image ou None'
            )

        if image is None:
            image = os.path.dirname(os.path.abspath(__file__))
            image = os.path.join(image, 'icon.png')
            image = mindu.Image(image, True)

        self._icon = image
        pygame.display.set_icon(image._surf)
Esempio n. 5
0
    def __init__(self):
        self.music_channel = mindu.channels[0]
        self.explosion_channel = mindu.channels[1]
        self.fire_channel = mindu.channels[2]
        self.pig_channel = mindu.channels[3]

        self.music_sound = mindu.Sound('sounds/main-music.ogg')
        self.explosion_sound = mindu.Sound('sounds/explosion.ogg')
        self.fire_sound = mindu.Sound('sounds/fire.ogg')
        self.fire_echo_sound = mindu.Sound('sounds/fire-echo.ogg')
        self.pig_ok_sound = mindu.Sound('sounds/pig-ok!.ogg')
        self.pig_ah_sound = mindu.Sound('sounds/pig-ah!.ogg')

        self.background_sprite = mindu.Image(file='images/background.png',
                                             alpha=False)

        self.game_over_sprite = mindu.Label(text='Game over',
                                            font='fonts/biting.ttf',
                                            size=40,
                                            color=(1.0, 0.0, 0.0, 1.0),
                                            centerx=mindu.screen.centerx,
                                            bottom=mindu.screen.centery - 10,
                                            osd=True)

        self.message_sprite = mindu.Label(
            text='Press return to continue',
            font='fonts/biting.ttf',
            size=20,
            color=(1.0, 0.0, 0.0, 1.0),
            centerx=self.game_over_sprite.centerx,
            top=self.game_over_sprite.bottom + 20,
            osd=True)

        self.ship_sprite = mindu.Image(file='images/ship.png',
                                       right=mindu.screen.left,
                                       top=mindu.screen.top + 10)

        self.sparks_sprite = mindu.Animation(directory='animations/sparks',
                                             osd=True,
                                             redraw=5,
                                             anchor='center')

        self.bomb_sprite = mindu.Image('images/bomb.png')

        self.explosion_sprite = mindu.Animation(
            directory='animations/explosion',
            osd=True,
            redraw=2,
            repeat=False,
            anchor='center')

        self.score_sprite = mindu.Label(text='Score: 0',
                                        font='fonts/biting.ttf',
                                        size=20,
                                        color=(1.0, 0.0, 0.0, 1.0),
                                        osd=True,
                                        left=mindu.screen.left + 10,
                                        bottom=mindu.screen.bottom - 10)

        self.ships = []
        self.bombs = []
        self.explosions = []

        self.ship_reload = 15
        self.ship_reload_control = self.ship_reload
        self.score = 0

        self.pig = Pig(self)
        self.fire = Fire(self)

        self.music_channel.play(self.music_sound, -1)
        mindu.loop.on_iterate(self.fadein)
Esempio n. 6
0
import random
import mindu

mindu.screen.set_size((640, 400))
mindu.screen.set_title('Fire, Pig, Fire!')
mindu.screen.set_icon(mindu.Image('images/icon.png', True))
mindu.mouse.toggle_visible()


@mindu.keyboard.on_ding
def on_keyboard_ding(symbol):

    if symbol == 'escape':
        mindu.screen.toggle_full()


class Pig(object):
    def __init__(self, scene):
        self.scene = scene

        self.walking_left = mindu.Animation(directory='animations/pig-walking',
                                            redraw=5)

        self.walking_right = self.walking_left.flip(True, False)

        self.aiming_left = mindu.Image(file='images/pig-aiming.png',
                                       midbottom=(mindu.screen.centerx,
                                                  mindu.screen.bottom - 10))

        self.aiming_right = self.aiming_left.flip(True, False)
        self.aiming_up = mindu.Image('images/pig-aiming-up.png')