Ejemplo n.º 1
0
    def __init__(self):

        self.objects = gameobject.Group()
        self.coins = gameobject.Group()
        self.baddies = gameobject.Group()
        self.dead = gameobject.Group()
        self.springs = gameobject.Group()

        Player.groups = [self.objects]
        Platform.groups = [self.objects]
        Coin.groups = [self.objects, self.coins]
        Points.groups = [self.objects]
        Poof.groups = [self.objects]
        Baddie.groups = [self.objects, self.baddies]
        Death.groups = [self.objects, self.dead]
        Spring.groups = [self.objects, self.springs]

        self.font = font.Font(GAMEBOY_FONT, (50, 50, 50))
        self.background = load_image("data/background.png")
        self.lifeicon = load_image("data/head.png")

        self.score = 0
        self.level = 1
        self.lives = 5
        self.show_win_screen = False

        self.engine = TileEngine()
        self.camera = pygame.Rect(0, 0, GBRES[0], GBRES[1])
Ejemplo n.º 2
0
class Sprite(object):
    #shadow image is static
    shadow_image=pygame.image.load("data/shadow2.png")
    shadow_mi_image=pygame.image.load("data/shadow_mi2.png")
    shadow_mini_image=pygame.image.load("data/shadow_mini2.png")
    font=font.Font(NES_FONT, (255, 255, 255))
    def __init__(self):
        self.image=0
        self.pos = [0, 0, 0]
        
    def draw(self,surface,camera,is_shadow=True): #pb : wrong if ground_z != 0 !
        if (is_shadow):
            if (self.pos[2]>8):
                surface.blit(Sprite.shadow_mini_image, camera.proj([self.pos[0],self.pos[1],0],Sprite.shadow_image.get_width(),Sprite.shadow_image.get_height()-3))
            elif (self.pos[2]>4):
                surface.blit(Sprite.shadow_mi_image, camera.proj([self.pos[0],self.pos[1],0],Sprite.shadow_image.get_width(),Sprite.shadow_image.get_height()-3))
            else:
                surface.blit(Sprite.shadow_image, camera.proj([self.pos[0],self.pos[1],0],Sprite.shadow_image.get_width(),Sprite.shadow_image.get_height()-3))
            surface.blit(self.image, camera.proj(self.pos,self.image.get_width(),self.image.get_height()))
        else:
            surface.blit(self.image, camera.proj(self.pos,self.image.get_width(),self.image.get_height()))
Ejemplo n.º 3
0
    def __init__(self):

        # Create some groups to hold the game objects.
        self.objects = gameobject.Group()
        self.coins = gameobject.Group()
        self.baddies = gameobject.Group()
        self.dead = gameobject.Group()
        self.springs = gameobject.Group()
        self.punches = gameobject.Group()

        # Preset the classes' groups so that they're added automatically
        # each time you create one. No hassle, very clean.
        Player.groups = [self.objects]
        Platform.groups = [self.objects]
        Coin.groups = [self.objects, self.coins]
        Points.groups = [self.objects]
        Poof.groups = [self.objects]
        Baddie.groups = [self.objects, self.baddies]
        Death.groups = [self.objects, self.dead]
        Spring.groups = [self.objects, self.springs]
        Punch.groups = [self.objects, self.punches]
        BaddieDeath.groups = [self.objects]

        # Create a Gameboy-style font
        self.font = font.Font(GAMEBOY_FONT, (50, 50, 50))

        # Preload some of the game images
        self.background = load_image("data/background.png")
        self.lifeicon = load_image("data/head.png")

        self.score = 0
        self.level = 1
        self.lives = 5
        self.show_win_screen = False

        self.engine = TileEngine()
        self.camera = pygame.Rect(0, 0, GBRES[0], GBRES[1])
Ejemplo n.º 4
0
            self.pos[1] = 192
            self.jump_speed = 0

        # Keep the player in-bounds
        if self.pos[0] < 0:
            self.pos[0] = 0
        if self.pos[0] > 240:
            self.pos[0] = 240


# Initalise the display
display.init(scale=2.0, caption="NES Demo", res=NESRES)
player = Player()  # Create the player

# Create a font
nesfont = font.Font(NES_FONT, (255, 255, 255))

dialogbox = dialog.DialogBox((240, 51), (0, 0, 0), (255, 255, 255), nesfont)
dialogbox.set_dialog([
    "This is a dialog box! Press the a button to go to the next page.",
    "Press it again and this box will close."
])
menu = dialog.Menu(nesfont, ["Close", "Pause", "Exit"])
# dialogbox.close()

while 1:

    # Tick, tock, at 30 frames per second
    clock.tick()

    # Handle button and key input
Ejemplo n.º 5
0
def run_menu():
    timer = 0
    play_music("data/title.ogg")
    game = Game()
    set_global_sound_volume(0.75)

    while 1:
        clock.tick()
        button.handle_input()

        # If we pressed start, begin the game
        if button.is_pressed(START):

            play_music("data/algar-orka.xm", -1)
            whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
            box = dialog.DialogBox((152, 46), (50, 50, 50), GB_SCREEN_COLOR,
                                   whitefont)
            box.set_dialog([
                "bubbman was on his way to oliland,",
                "when his car broke down in the dododu mountains!",
                "can bubbman cross the monster-infested mountain range?"
            ])
            box.set_scrolldelay(2)
            while not box.over():
                clock.tick()
                button.handle_input()
                if button.is_pressed(A_BUTTON):
                    box.progress()
                screen = display.get_surface()
                screen.fill(GB_SCREEN_COLOR)
                screen.blit(game.background, (0, 0))
                box.draw(screen, (4, 4))
                display.update()

            game.won = True
            game.level = 1
            game.lives = 5
            game.score = 0

            # Play each level
            for lvl in LEVELS:
                game.start_level(lvl)
                game.level += 1
                game.loop()
                if not game.player.alive():
                    break

            # If we got to the end of the game, display credits
            if game.won:
                pos = 144
                credits = [
                    "Credits", "", "", "Programmers", "pymike", "saluk", "",
                    "", "Sound Mixing", "pymike", "", "", "Music",
                    "ModArchive.org", "DrPetter", "", "", "Special Thanks To",
                    "SFXR by DrPetter", "The Gimp 2", "Geany", "", "", "", "",
                    "", "", "", "", "", "", "", "", "", " Thanks for playing!!"
                ]
                while pos > -144 - (len(credits) * 7):
                    button.handle_input()
                    if button.is_pressed(START):
                        break
                    screen = display.get_surface()
                    screen.fill(GB_SCREEN_COLOR)
                    screen.blit(game.background, (0, 0))

                    clock.tick()
                    pos -= 0.5
                    y = 0
                    for c in credits:
                        ren = game.font.render(c)
                        screen.blit(ren, (80 - ren.get_width() / 2, pos + y))
                        y += 10
                    display.update()

            play_music("data/title.ogg")

        # Draw the main menu
        screen = display.get_surface()
        screen.fill(GB_SCREEN_COLOR)
        screen.blit(load_image("data/bubbman-menu.png"), (0, 0))
        ren = game.font.render("Press Start")
        timer += 1
        timer = timer % 30
        if timer < 15:
            screen.blit(ren,
                        (80 - ren.get_width() / 2, 104 - ren.get_height() / 2))
        display.update()