dark mode light mode Search Menu
Search

Make a Mini Micro Collection Game

Today, we’re going to make a collection game in Mini Micro. The player controls a spaceship by moving their mouse and collecting stars for points.

First, we’ll want to boot up Mini Micro. You can find it at https:// miniscript.org/minimicro. I recommend downloading Mini Micro to your computer since the browser version can’t save files for later.

With Mini Micro open, enter the edit command in the console to start working on a new script. Remember to save your work periodically. I named my script spacegame.ms. 

First, we’ll need to do some setup before our game loop. Carefully type in the code in (A), lines 1-26. The first thing we do is import two MiniMicro libraries, mathUtil, and listUtil, and then set up some constants, lines 1-26. These are variables that won’t change during program execution. Then we set up the background image and load files that we’ll need for our collectibles.

A

You may notice that we draw the background image bgImage twice in a row, lines 16-17. Later, this will help us create the illusion that the world is turning by changing gfx.scrollX every frame, in line 46. Last, we’ll set up the player’s spaceship in lines 23- 26. It will follow the mouse around using x and y coordinates, picking up any stars the player touches.

Next, we create two functions to manage the collectible stars. Carefully enter the code in (B), lines 28-43. makeNewStar creates a new star with a random position, speed, and size, in lines 33-35. Fast stars are smaller and spin more quickly as they zoom past. Once a star is created, it’s added (pushed) to two lists: spriteList draws it on screen, and starList tracks every star that’s been made. Then we have the removeStar function, which can remove a star from each list.

B

With our helper functions sorted, it’s time to write the game loop. Carefully enter the code from (C), lines 45-74. In every frame, we move and spin each star according to its size, in lines 55-57. Then we check whether it’s colliding with the player in line 59. If so, we raise the player’s score by one and delete the star. Last, in lines 62-63, we check whether the star has flown off the screen. It’s good to clean those up since the player can’t reach them anymore.

C

Now that you’ve got the code in, save your work by clicking the Save button at the top of the editor. Then run the program by clicking the Play button in the editor, or by exiting the editor and then entering the run command. Good luck collecting stars.

A: Setup Code (Lines 1-26):

  • Constants
    • kNextStarTime – number of frames between new stars appearing on screen
    • kStarMaxSpeed – highest speed a star can be created with
    • kEndTime – how long the game lasts, in seconds
  • Loads background image
    • Drawn twice on the background layer to make use of scrolling in the game loop
  • Sets up the player and pushes it to spriteList

B: Star Functions (Lines 28-43):

  • makeNewStar
    • Creates a new Sprite and assigns the star image
    • Randomly sets the star’s speed and size – faster stars are smaller
    • Adds the star to two Lists – spriteList and starList
  • removeStar
    • Removes the star from spriteList and starList

C: Game Loop (Lines 45-71):

  • Scroll the background image
  • Moves the player to the mouse position
  • Call makeNewStar every kNextStarTime frames
  • Update every star in stars, described below
  • Draw score

C: End Screen (Lines 73-74)

  • Draws final score on screen. Code should be included with the game loop for Image C.

Learn More 

MiniScript Wiki

https://miniscript.org/wiki/

MiniMicro Cheat Sheet

https://miniscript.org/files/MiniMicro-CheatSheet.pdf

MiniScript Manual

https://miniscript.org/files/MiniScript-Manual.pdf

MiniScript

https://miniscript.org/

Make a Simple Mini Micro Game

https://www.youtube.com/watch?v=HGTpJXYAA28