Example #1
0
def run_menu():
    timer = 0
    play_music("data/title.ogg")
    game = Game()
    set_global_sound_volume(0.75)
    while True:
        clock.tick()
        button.handle_input()

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

            play_music("data/algar-orka.xm", -1)
            # Creates text box
            whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
            box = dialog.DialogBox((152, 46), (50, 50, 50),
                GB_SCREEN_COLOR, whitefont)
            box.set_dialog([
                "Spin to \
                win.",
                "- Garen 2008"
            ])
            # Updates box when Z is pressed
            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 = 3
            game.score = 0

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

        screen = display.get_surface()
        screen.fill(GB_SCREEN_COLOR)
        screen.blit(load_image("data/bg.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()
Example #2
0
 def pause(self):
     pygame.mixer.music.pause()
     button.handle_input()
     play_sound("data/pause.ogg")
     while not button.is_pressed(START):
         button.handle_input()
         ren = self.font.render("PAUSED")
         screen = display.get_surface()
         screen.blit(ren, (80 - ren.get_width() / 2, 74 - ren.get_height() / 2))
         display.update()
     play_sound("data/pause.ogg")
     pygame.mixer.music.unpause()
Example #3
0
 def pause(self):
     pygame.mixer.music.pause()
     button.handle_input()
     play_sound("data/pause.ogg")
     while not button.is_pressed(START):
         button.handle_input()
         ren = self.font.render("PAUSED")
         screen = display.get_surface()
         screen.blit(ren,
                     (80 - ren.get_width() / 2, 74 - ren.get_height() / 2))
         display.update()
     play_sound("data/pause.ogg")
     pygame.mixer.music.unpause()
 def win(self):
     splash = display.get_surface().copy()
     pos = 0
     time = 50
     while 1:
         button.handle_input()
         clock.tick()
         if pos < 74:
             pos += 2
         else:
             time -= 1
             if time <= 0:
                 break
         screen = display.get_surface()
         screen.blit(splash, (0, 0))
         ren = self.font.render("You reached Oliland!")
         screen.blit(ren, (80-ren.get_width()/2, pos))
         display.update()
     self.playing = False
Example #5
0
 def win(self):
     splash = display.get_surface().copy()
     pos = 0
     time = 50
     while 1:
         button.handle_input()
         clock.tick()
         if pos < 74:
             pos += 2
         else:
             time -= 1
             if time <= 0:
                 break
         screen = display.get_surface()
         screen.blit(splash, (0, 0))
         ren = self.font.render("You reached Oliland!")
         screen.blit(ren, (80 - ren.get_width() / 2, pos))
         display.update()
     self.playing = False
Example #6
0
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
    button.handle_input()

    # If displaying dialog, do events for dialog!
    if not dialogbox.over():
        if button.is_pressed(A_BUTTON):
            dialogbox.progress()

    # Otherwise, play the "game"
    else:

        # Move if LEFT or RIGHT is being pressed.
        if button.is_held(LEFT):
            player.pos[0] -= 3
        if button.is_held(RIGHT):
            player.pos[0] += 3
Example #7
0
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
    button.handle_input()
    
    # If displaying dialog, do events for dialog!
    if not dialogbox.over():
        if button.is_pressed(A_BUTTON):
            dialogbox.progress()
    
    # Otherwise, play the "game"
    else:
        
        # Move if LEFT or RIGHT is being pressed.
        if button.is_held(LEFT):
            player.pos[0] -= 3
        if button.is_held(RIGHT):
            player.pos[0] += 3
        
 def handle_input(self):
     button.handle_input()
     if button.is_pressed(START):
         self.pause()
     if button.is_pressed(A_BUTTON) and button.is_held(SELECT):
         self.playing = False
Example #9
0
def main():
    display.init(3.0, "Kontra")
    play_music("data/nes6.xm")

    objects = retrogamelib.gameobject.Group()
    platforms = retrogamelib.gameobject.Group()
    bullets = retrogamelib.gameobject.Group()

    Bullet.groups = [objects, bullets]
    Player.groups = [objects]
    Player.platforms = platforms
    Player.objects = objects
    Platform.groups = [objects, platforms]
    Tile.groups = [objects]
    Bullet.platforms = platforms

    x = 0
    y = 0
    for row in level.split("\n"):
        for col in row:
            if col == "T":
                Platform((x, y))
            if col == "-":
                Platform((x, y))
                platforms[-1].allow_fall_through = False
            if col == "L":
                Platform((x, y), -45)
            if col == "R":
                Platform((x, y), 45)
            if col == "r":
                Platform((x, y), 30)
            if col == "B":
                Tile((x, y))
            if col == "h":
                Helicopter((x, y))
            x += 16
        x = 0
        y += 16
    player = Player()
    turret = Turret()
    turret.rect.topleft = [0, 100]
    camera = Camera()
    camera.follow(player)

    while 1:
        clock.tick()
        button.handle_input()
        aliencount = 0
        for o in objects:
            if isinstance(o, Alien):
                aliencount += 1
            o.update()

        player.controls()
        camera.update()

        surface = display.surface
        surface.fill((175, 200, 255))
        for object in objects:
            translated = camera.translate(object.rect)
            surface.blit(object.image, translated)
            if translated.x < -16 or translated.x > 300:
                if hasattr(object, "offscreen"):
                    object.offscreen(camera)
            else:
                if hasattr(object, "onscreen"):
                    object.onscreen(camera)
        display.update()

        if aliencount < 2:
            if random.randint(0, 100) > 95:
                if random.randint(0, 1) == 1:
                    alien = Alien()
                    alien.rect.topleft = [
                        258 - camera.offset[0],
                        random.randint(0, 200)
                    ]
                    alien.direction.x = -1
                else:
                    alien = Alien()
                    alien.rect.topleft = [
                        -5 - camera.offset[0],
                        random.randint(0, 200)
                    ]
                    alien.direction.x = 1
Example #10
0
def run_menu():
	play_music("sfx/title_screen.ogg")
	timer = 0
	game = Game()
	set_global_sound_volume(0.75)
	
	while True:
		clock.tick()
		button.handle_input()
		
		if button.is_pressed(START):
			
			play_music("sfx/ChibiNinja.ogg", -1)
			whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
			box = dialog.DialogBox((152, 46), (50, 50, 50), 
				GB_SCREEN_COLOR, whitefont)
			box.set_dialog([
				"GET THEM DARN ALIENS!"
			])
			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",
					"",
					"",
					"Programming by",
					"Tommy Brunn",
					"pymike",
					"saluk",
					"",
					"",
					"Art by",
					"Tommy Brunn",
					"",
					"",
					"Sound Mixing",
					"Tommy Brunn",
					"",
					"",
					"Music",
					"Eric Skiff",
					"thechad1138",
					"",
					"",
					"Special Thanks To",
					"SFXR by DrPetter",
					"pymike",
					"saluk",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					" 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("sfx/title_screen.ogg")
			
		#Draw main menu
		screen = display.get_surface()
		screen.fill(GB_SCREEN_COLOR)
		#screen.blit(load_image("gfx/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()
Example #11
0
 def handle_input(self):
     button.handle_input()
     if button.is_pressed(START):
         self.pause()
     if button.is_pressed(A_BUTTON) and button.is_held(SELECT):
         self.playing = False
Example #12
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()
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([
                "johnny the adventurer discovered a huge tower,",
                "and, being the manly man he is, must explore it!",
                "can you help him climb the perilous tower??"
            ])
            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()