def __init__(self, bank, width=8, height=2, text1=None, text2=None, sprite1=None, palette=None, buffer=None): super().__init__(bank, width, height, palette, buffer) self.showing = False # first line of text self.marginX = 4 self.marginY = 4 self.text = None if text1: self.text1 = stage.Text(width=len(text1), height=1) self.text1.text(text1) # second line of text self.marginX2 = self.marginX self.marginY2 = self.marginY + 15 self.text2 = None if text2: self.text2 = stage.Text(width=len(text2), height=1) self.text2.text(text2) # extra sprite self.sprite1 = None if sprite1: self.sprite1 = sprite1 # frames to wait at start (avoids accidental button presses) self.framesToWait = 2 self._curFramesWaiting = 0
def menu(): background = stage.Grid(image_bank_1, 10, 8) text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(55, 50) text1.text("WELCOME!") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(40, 70) text2.text("PRESS START") text.append(text2) game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_START != 0: game_scene()
def game_over_scene(): global score image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text0 = stage.Text(29, 14, None, constants.PLT, buffer=None) text0.move(22, 20) text0.text("Final Score: {:0>2d}".format(score)) text.append(text0) text1 = stage.Text(29, 14, None, constants.PLT, buffer=None) text1.move(43, 60) text1.text("GAME OVER") text.append(text1) text2 = stage.Text(29, 14, None, constants.PLT, buffer=None) text2.move(32, 110) text2.text("PRESS START") text.append(text2) game = stage.Stage(ugame.display, 60) game.layers = text + [background] game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_SELECT != 0: keys = 0 menu_scene()
def menu_scene(): # this function is the splash game loop # new pallet for black filled text NEW_PALETTE = ( b'\xff\xff\x00\x22\xcey\x22\xff\xff\xff\xff\xff\xff\xff\xff\xff' b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff') # An image bank for CicuitPython image_bank_1 = stage.Bank.from_bmp16("space_aliens.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_1, constants.SCREEN_X, constants.SCREEN_Y) # a list of sprites that will be updated every frame sprites = [] # add text objects text = [] text1 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text1.move(20, 10) text1.text("Dylan & Ben\n Game Studios") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text2.move(40, 110) text2.text("Press Start") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the layers, items show up in order game.layers = text + sprites + [background] # render the background and initial location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input keys = ugame.buttons.get_pressed() # print(keys) # A button to fire if keys & ugame.K_START != 0: sound.play(start_sound) game_scene() # update game logic game.tick() # wait until refresh rate finishes
def game_over(final_score): image_bank_1 = stage.Bank.from_bmp16("iib_sprites.bmp") background = stage.Grid(image_bank_1, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) for x_location in range(constants.SCREEN_GRID_X): for y_location in range(constants.SCREEN_GRID_X): background.tile(x_location, y_location, 3) sprites = [] text = [] text_game_over = [] text_game_over_list = [] text_game_over = stage.Text(width=29, height=12, font=None, palette=constants.ICE_ICE_BABY_PALETTE, buffer=None) text_game_over.move(45, 50) text_game_over.text("Game Over") text.append(text_game_over) # V If game lags, change this V game = stage.Stage(ugame.display, constants.FPS) # add text at top of screen for score score_text = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) score_text.clear() score_text.cursor(0, 0) score_text.move(16, 80) score_text.text("Final Score: {0}".format(final_score)) game.layers = [score_text] + [text_game_over] + [background] game.render_block() while True: pass
def game_over_scene(final_score): # this function is the game over scene image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text0 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text0.move(22, 20) text0.text("Final Score: {:0>2d}".format(final_score)) text.append(text0) text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(43, 60) text1.text("GAME OVER") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(32, 110) text2.text("PRESS SELECT") text.append(text2) game = stage.Stage(ugame.display, 60) game.layers = text + [background] game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_SELECT != 0: # Start button keys = 0 menu_scene()
def game_over_scene(final_score): # this function is the game over scene # image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("space_aliens.bmp") # sets the background to image 0 in the image Bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # add text objects text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.BLUE_PALETTE, buffer=None) text1.move(22, 20) text1.text("Final Score: {:0>2d}".format(final_score)) text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.BLUE_PALETTE, buffer=None) text2.move(43, 60) text2.text("GAME OVER") text.append(text2) text3 = stage.Text(width=29, height=14, font=None, palette=constants.BLUE_PALETTE, buffer=None) text3.move(32, 110) text3.text("PRESS SELECT") text.append(text3) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the layers, items will show up in order game.layers = text + [background] # render the background and initial location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input keys = ugame.buttons.get_pressed() # Start button selected if keys & ugame.K_SELECT != 0: supervisor.reload() # update game logic game.tick() # wait until refresh rate finishes
def game_over_scene(score): # this function is the game over scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("egg_collector_image_bank_test.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # a list to hold game over text text = [] text0 = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) text0.move(22, 20) text0.text("Final Score: {:0>2d}".format(score)) text.append(text0) text1 = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) text1.move(43, 60) text1.text("GAME OVER") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) text2.move(32, 110) text2.text("PRESS SELECT") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic keys = ugame.buttons.get_pressed() # print(keys) if keys & ugame.K_SELECT != 0: # Start button keys = 0 main_menu_scene()
def game_over_scene(final_score): # this function is the game over scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("sprites.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(22, 20) text1.text("Final Score: {:0>2d}".format(final_score)) text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(43, 60) text2.text("GAME OVER") text.append(text2) text3 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text3.move(32, 110) text3.text("PRESS SELECT") text.append(text3) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the background layer game.layers = text + [background] # render the background # most likely you will only render background once per scene game.render_block() # Game loop while True: # Update game logic keys = ugame.buttons.get_pressed() if keys & ugame.K_SELECT != 0: keys = 0 main_menu_scene()
def game_over_scene(final_score): # this function is the game over scene # turn off sound from last scene sound = ugame.audio sound.stop() # image banks for CPython image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") # sets the background to image 0 in the image Bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # Text boxes text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text1.move(22, 20) text1.text("Final Score: {:0>2d}".format(final_score)) text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.NEW_PALETTE, buffer=None) text2.move(43, 60) text2.text("GAME OVER") text.append(text2) text3 = stage.Text(width=29, height=14, font=None, palette=constants.NEW_PALETTE, buffer=None) text3.move(32, 110) text3.text("PRESS SELECT") text.append(text3) game = stage.Stage(ugame.display, constants.FPS) game.layers = text + [background] game.render_block() while True: # get user input keys = ugame.buttons.get_pressed() # Start button pressed if keys & ugame.K_START != 0: supervisor.reload() # update game logic game.tick()
def menu_scene(): # Menu scene # IMAGE BANK menu_image_bank = stage.Bank.from_bmp16("image_bank_1.bmp") # BACKGROUND # Sets background to the 0th image in the image bank, 10x8 grid menu_background = stage.Grid(menu_image_bank, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # Sets the floor as the 1st image in the image bank, the walls are # still going to be the 0th image for x_location in range(1, constants.SCREEN_GRID_X - 1): for y_location in range(1, constants.SCREEN_GRID_Y - 1): tile_picked = 1 menu_background.tile(x_location, y_location, tile_picked) # TEXT text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.PALETTE, buffer=None) text1.move(32, 10) text1.text("Ghost Dodge!") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=constants.PALETTE, buffer=None) text2.move(35, 110) text2.text("PRESS START") text.append(text2) # STAGE AND RENDER # creates stage and sets it to 60fps game = stage.Stage(ugame.display, constants.FPS) # sets the layers of all sprites, in order game.layers = text + [menu_background] # renders all sprites, only once game.render_block() while True: # get user input keys = ugame.buttons.get_pressed() # select start button if keys & ugame.K_START != 0: game_scene() # update game logic game.tick()
def menu_scene(): image_bank_1 = stage.Bank.from_bmp16("iib_sprites.bmp") background = stage.Grid(image_bank_1, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) for x_location in range(constants.SCREEN_GRID_X): for y_location in range(constants.SCREEN_GRID_Y): background.tile(x_location, y_location, 15) sprites = [] text = [] text3 = [] text3_list = [] text3 = stage.Text(width=29, height=12, font=None, palette=constants.ICE_ICE_BABY_PALETTE, buffer=None) text3.move(30, 6) text3.text("Ice Ice Baby") text.append(text3) text4 = [] text4_list = [] text4 = stage.Text(width=17, height=5, font=None, palette=constants.ICE_ICE_BABY_PALETTE, buffer=None) text4.move(16, 116) text4.text("Press A To Begin") text.append(text4) game = stage.Stage(ugame.display, constants.FPS) game.layers = text + sprites + [background] game.render_block() # get sound ready press_start_audio = open("press_start_audio.wav", 'rb') sound = ugame.audio sound.stop() sound.mute(False) lvl1 = None final_score = None while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_X != 0: final_score = 0 sound.play(press_start_audio) time.sleep(1) score = lvl_1() lvl1 = 1 game.tick() if lvl1 == 1: final_score = lvl_2(score) lvl1 = 2 game.tick() if lvl1 == 2: game_over(final_score) game.tick()
def game_splash_scene(): # this function is the game scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(19, 50) text1.text("Rousseau & Watson") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(35, 60) text2.text("Corporations") text.append(text2) # get sound ready # follow this guide to convert your other sounds to something that will work # https://learn.adafruit.com/microcontroller-compatible-audio-file-conversion coin_sound = open("coin.wav", 'rb') sound = ugame.audio sound.stop() sound.mute(False) sound.play(coin_sound) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic time.sleep(1.0) main_menu_scene()
def menu_scene(): # this function is the menu scene # image bank image_bank_mt_background = stage.Bank.from_bmp16("mt_game_studio.bmp") # add text objects text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studios") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text2.move(40, 110) text2.text("PRESS START") text.append(text2) # sets bg to image 0 in the image bank background = stage.Grid(image_bank_mt_background, constants.SCREEN_X, constants.SCREEN_Y) # creates stage and sets it to 60fps game = stage.Stage(ugame.display, constants.FPS) # sets the layers of all sprites, in order game.layers = text + [background] # renders all sprites, only once game.render_block() while True: # get user input keys = ugame.buttons.get_pressed() # select start button if keys & ugame.K_START != 0: game_scene() # update game logic game.tick()
def menu_scene(): # this function is the menu scene # image banks for CircuitPython image_bank_mt_background = stage.Bank.from_bmp16("mt_game_studio.bmp") # add text objects text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.RED_PALETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studios") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=constants.RED_PALETTE, buffer=None) text2.move(40, 110) text2.text("PRESS START") text.append(text2) # sets the background to image 0 in the image bank background = stage.Grid(image_bank_mt_background, constants.SCREEN_X, constants.SCREEN_Y) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the layers, items show up in order game.layers = text + [background] # render the background and initial location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input keys = ugame.buttons.get_pressed() # Start button selected if keys & ugame.K_START != 0: game_scene() # update game logic game.tick() # wait until refresh rate finishes
def main_menu_scene(): # this function is the MT splash scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("break_out.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text1 = stage.Text(width=29, height=15, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(40, 10) text1.text("Breakout") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(35, 110) text2.text("PRESS START") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = sprites + text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic # Wait for 3 seconds keys = ugame.buttons.get_pressed() if keys & ugame.K_START != 0: # Start button game_scene()
def game_splash_scene(): # this function is the game splash scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("egg_collector_image_bank_test.bmp") # sets the background to image 0 background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # displays text onscreen text = [] text1 = stage.Text(width=40, height=20, font=None, palette=constants.SCORE_PALETTE, buffer=None) text1.move(35, 10) text1.text("Produced By") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) text2.move(19, 110) text2.text("Douglass Jeffrey") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic # Wait for 1 seconds time.sleep(1.0) main_menu_scene()
def main_menu_scene(): # this function is the game scene # repeat forever, game loop # repeat forever, game loop image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(60, 10) text1.text("Pong") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(35, 110) text2.text("PRESS SELECT") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() while True: # get user input # update game logic keys = ugame.buttons.get_pressed() # Wait for 1 seconds if keys & ugame.K_SELECT != 0: key = 0 game_scene() # redraw sprite list pass # just a placeholder until you write the code
def game_splash_scene(): # this function is the MT splash scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("break_out.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text1 = stage.Text(width=29, height=15, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(50, 60) text1.text("Ferda Games") text.append(text1) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic # Wait for 3 seconds time.sleep(3.0) main_menu_scene()
def menu_scene(): image_bank_1 = stage.Bank.from_bmp16("ball.bmp") background = stage.Grid(image_bank_1, 10, 8) sprites = [] text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text1.move(58, 10) text1.text("JOJOS") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text2.move(43, 110) text2.text("APPROACH?") text.append(text2) text3 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text3.move(13, 20) text3.text("BIZZARE ADVENTURE") text.append(text3) game = stage.Stage(ugame.display, constants.FPS) game.layers = text + sprites + [background] game.render_block() while True: # get user inputs keys = ugame.buttons.get_pressed() # print(keys) if keys & ugame.K_START != 0: game_scene()
def mt_splash_scene(): # this function is the MT splash scene # an image bank for CircuitPython image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) # used this program to split the iamge into tile: https://ezgif.com/sprite-cutter/ezgif-5-818cdbcc3f66.png background.tile(2, 2, 0) # blank white background.tile(3, 2, 1) background.tile(4, 2, 2) background.tile(5, 2, 3) background.tile(6, 2, 4) background.tile(7, 2, 0) # blank white background.tile(2, 3, 0) # blank white background.tile(3, 3, 5) background.tile(4, 3, 6) background.tile(5, 3, 7) background.tile(6, 3, 8) background.tile(7, 3, 0) # blank white background.tile(2, 4, 0) # blank white background.tile(3, 4, 9) background.tile(4, 4, 10) background.tile(5, 4, 11) background.tile(6, 4, 12) background.tile(7, 4, 0) # blank white background.tile(2, 5, 0) # blank white background.tile(3, 5, 0) background.tile(4, 5, 13) background.tile(5, 5, 14) background.tile(6, 5, 0) background.tile(7, 5, 0) # blank white text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studios") text.append(text1) # get sound ready # follow this guide to convert your other sounds to something that will work # https://learn.adafruit.com/microcontroller-compatible-audio-file-conversion coin_sound = open("coin.wav", 'rb') sound = ugame.audio sound.stop() sound.mute(False) sound.play(coin_sound) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input # update game logic # Wait for 1/2 seconds time.sleep(1.0) game_splash_scene()
def game_splash_scene(): # this function is the game scene text = [] sprites = [] image_bank_3 = stage.Bank.from_bmp16("jungle_joe.bmp") image_bank_4 = stage.Bank.from_bmp16("elemental_studios.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_3, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text_1 = stage.Text(width=29, height=14, font=None, palette=constants.SCORE_PALETTE, buffer=None) text_1.move(13, 60) text_1.text("ELEMENTAL STUDIOS") text.append(text_1) fire_upper_right = stage.Sprite(image_bank_4, 0, 16, 0) sprites.append(fire_upper_right) fire_bottom_right = stage.Sprite(image_bank_4, 1, 16, 16) sprites.append(fire_bottom_right) fire_upper_left = stage.Sprite(image_bank_4, 2, 0, 0) sprites.append(fire_upper_left) fire_bottom_left = stage.Sprite(image_bank_4, 3, 0, 16) sprites.append(fire_bottom_left) water_upper_right = stage.Sprite(image_bank_4, 6, 144, 0) sprites.append(water_upper_right) water_bottom_right = stage.Sprite(image_bank_4, 7, 144, 16) sprites.append(water_bottom_right) water_upper_left = stage.Sprite(image_bank_4, 4, 128, 0) sprites.append(water_upper_left) water_bottom_left = stage.Sprite(image_bank_4, 5, 128, 16) sprites.append(water_bottom_left) earth_upper_right = stage.Sprite(image_bank_4, 10, 16, 98) sprites.append(earth_upper_right) earth_bottom_right = stage.Sprite(image_bank_4, 11, 16, 112) sprites.append(earth_bottom_right) earth_upper_left = stage.Sprite(image_bank_4, 8, 0, 98) sprites.append(earth_upper_left) earth_bottom_left = stage.Sprite(image_bank_4, 9, 0, 112) sprites.append(earth_bottom_left) wind_upper_right = stage.Sprite(image_bank_4, 14, 144, 98) sprites.append(wind_upper_right) wind_bottom_right = stage.Sprite(image_bank_4, 15, 144, 112) sprites.append(wind_bottom_right) wind_upper_left = stage.Sprite(image_bank_4, 12, 128, 98) sprites.append(wind_upper_left) wind_bottom_left = stage.Sprite(image_bank_4, 13, 128, 112) sprites.append(wind_bottom_left) game = stage.Stage(ugame.display, 60) # set the layers, items show up in order game.layers = sprites + text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene # wait until refresh rate finishes game.render_block() # repeat forever, game loop while True: # get user input # update game logic time.sleep(1.0) main_menu_scene() # redraw sprite list pass # just a placeholder until you write the code
def menu_scene(): # setting text NEW_PALETTE = (b'\xff\xaf\x00\x22\xcey\x22\xab\xff\xff\xff\xba\x22\ \xff\xff\xff' b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\ \xff\xff\xff\xff') # image bank image_bank_1 = stage.Bank.from_bmp16("space_aliens.bmp") # set background background = stage.Grid(image_bank_1, constants.SCREEN_X, constants.SCREEN_Y) # sprite bank sprites = [] # text objects text = [] text1 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studio") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text2.move(40, 110) text2.text("Press START") text.append(text2) game = stage.Stage(ugame.display, constants.FPS) game.layers = text + sprites + [background] game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_START != 0: main() game.tick()
def main(): # an image bank for CircuitPython image_bank_1 = stage.Bank.from_bmp16("ball.bmp") # sets the background to image 0 in the bank background = stage.Grid(image_bank_1, constants.SCREEN_X, constants.SCREEN_Y) # a list of sprites that will be updated every frame sprites = [] text = [] text1 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studios") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=constants.NEW_PALETTE, buffer=None) text2.move(40, 110) text2.text("PRESS START") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the background layer game.layers = text + sprites + [background] # render the background # most likely you will only render background once per scene game.render_block() while True: # get user inputs keys = ugame.buttons.get_pressed() # start button is pressed if keys & ugame.K_START != 0: game_scene() game.tick()
def game_over_scene(final_score): # This function is the game over scene # on image bank for circuitpython image_bank_2 = stage.Bank.from_bmp16("mt_game_studio") # sets the background to image 0 in hte bank background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text0 = stage.Text(width=29, height=14, font=None, palette=constants.NEW_PALETTE, buffer=None) text0.move(22, 20) text0.text("Final Score: {0>2d}".format(final_score)) text.append(text0) text1 = stage.Text(width=29, height=14, font=None, palette=constants.NEW_PALETTE, buffer=None) text1.move(43, 60) text1.move("Game Over") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.NEW_PALETTE, buffer=None) text2.move(32, 110) text2.text("PRESS SELECT") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the layers to show up in order game.layers = text + [background] # render the background and intial location of the sprite list game.render_block() while True: # update game logic keys = ugame.buttons.get_pressed() if keys & ugame.K_SELECT != 0: keys = 0 menu_scene()
def menu_scene(): # menu NEW_PALETTE = ( b'\xff\xff\x00\x22\xcey\x22\xff\xff\xff\xff\xff\xff\xff\xff\xff' b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff') image_bank_1 = stage.Bank.from_bmp16("space_aliens.bmp") background = stage.Grid(image_bank_1, constants.SCREEN_X, constants.SCREEN_Y) sprites = [] text = [] text1 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text1.move(20, 30) text1.text("MT GAME STUDIOS") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=NEW_PALETTE, buffer=None) text2.move(35, 80) text2.text("PRESS START") text.append(text2) game = stage.Stage(ugame.display, constants.FPS) game.layers = text + sprites + [background] game.render_block() while True: keys = ugame.buttons.get_pressed() # print (keys) if keys & ugame.K_START != 0: game_scene()
def game_over_scene(final_score): image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) text = [] text0 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text0.move(22, 20) text0.text("Final Score: {0}".format(final_score)) text.append(text0) text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(43, 60) text1.text("Game Over") text.append(text1) text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text2.move(32, 110) text2.text("PRESS SELECT") text.append(text2) # create a stage for the background to show up on # and set the frame rate to 60fps game = stage.Stage(ugame.display, constants.FPS) # set the layers, items show up in order game.layers = text + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_SELECT != 0: keys = 0 menu_scene()
def menu_scene(): NEW_PALLETTE = (b'\xff\xff\x00\x22\xcey\x22\xff\xff\xff\xff\xff\xff\xff\ \xff\xff' b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\ \xff\xff') image_bank_1 = stage.Bank.from_bmp16("ball.bmp") background = stage.Grid(image_bank_1, constants.SCREEN_X, constants.SCREEN_Y) sprites = [] text = [] text1 = stage.Text(width=29, height=12, font=None, palette=NEW_PALLETTE, buffer=None) text1.move(20, 10) text1.text("MT Game Studios") text.append(text1) text2 = stage.Text(width=29, height=12, font=None, palette=NEW_PALLETTE, buffer=None) text2.move(40, 110) text2.text("PRESS START") text.append(text2) game = stage.Stage(ugame.display, 60) game.layers = text + sprites + [background] game.render_block() while True: keys = ugame.buttons.get_pressed() if keys & ugame.K_START != 0: game_scene()
def game_loop(): # this function is a scene # an image bank for CircuitPython image_bank_1 = stage.Bank.from_bmp16("space_aliens.bmp") # sets the background to image 0 in the bank # we will not change the background after initially drawing it background = stage.Grid(image_bank_1, 160, 120) # a list of sprites that will be updated every frame sprites = [] # create a sprite # parameters (image_bank, image # in bank, x, y) #alien = stage.Sprite(image_bank_1, 9, 80-8, 60-8) #sprites.append(alien) # show text on screen text = stage.Text(width=29, height=1) text.move(30, 110) text.text("PRESS A or B") # create a stage for the background to show up on # and set the frame rate to 30fps game = stage.Stage(ugame.display, 30) # set the layers, items show up in order game.layers = [text] + sprites + [background] # render the background and inital location of sprite list # most likely you will only render background once per scene game.render_block() # repeat forever, game loop while True: # get user input keys = ugame.buttons.get_pressed() # update game logic if keys & ugame.K_X != 0: # A button a_scene.game_loop() if keys & ugame.K_O != 0: # B button b_scene.game_loop() # redraw sprite list game.render_sprites(sprites) game.tick() # wait until refresh rate finishes
def game_over_scene(): # this function is the game over scene # repeat forever, game loop while True: text = [] text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) text1.move(60, 10) text1.text("GAME OVER") text.append(text1) # update game logic keys = ugame.buttons.get_pressed() # Wait for 1 seconds if keys & ugame.K_SELECT != 0: key = 0 mt_splash_scene() # redraw sprite list pass # just a placeholder until you write the code