Splash Scene¶
The splash scene includes 3 short splash scenes before reaching the main menu scene. the entire game begins with a short white screen which shows up for half a second:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | def blank_white_reset_scene():
# this function is the blank splash scene game loop
# do house keeping to ensure everythng is setup
# reset sound to be off
sound = ugame.audio
sound.stop()
sound.mute(False)
# an image bank for CircuitPython
image_bank_1 = stage.Bank.from_bmp16("mt_game_studio.bmp")
# sets the background to image 0 in the bank
background = stage.Grid(image_bank_1, 160, 120)
# 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 = [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(0.5)
mt_splash_scene()
# redraw sprite list
|
Then, a splash screen which displays MT Studios along with a lightbulb image appears for a second:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 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)
# 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)
game_splash_scene()
# redraw sprite list
|
Finally, a splash screen which displays our “company” name(Rousseau & Watson Corporations) is shown for a second, along with a coin sound:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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()
|
After, the game moves to the main menu scene.