Skip to content

jonasCCa/Asteroids-Stormworks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Asteroids_Logo

Asteroids on Stormworks

This project is a non-faithful recreation of the classic game Asteroids playable in Stormworks: Build and Rescue.

The game's microcontroller has some settings that can be configured in a per-placement basis, which allow for difficulty tuning. More on those settings on the Configurability section.

This game does not change sprite proportions according to the screen size and, although will technically work on any display size, the UI won't fit properly in anything smaller than the 3x3 display and it's best played on a larger screen, given the bigger playspace. The example found in the Game Elements section uses the biggest (9x5) display, but a 5x3 works fine as well.

Created with nameouschangey's LifeBoatAPI - Stormworks Lua plugin for VSCode for easier testing using the simulator and for code minimization. The original hotkey instructions that are automatically created when starting a new Microcontroller Project with the LifeBoat plugin were preserved in the source.

How to Play

A ready-to-play vehicle is available on the Steam Workshop page.
Instructions are as follows:

Controls

After seating on the pilot chair, the controls are as folows:

Keys Action
Accelerate
← → Turn
Spacebar Shoot

Game Elements

A screenshot of the game, with some highlighted elements that are explained below

  1. The Player's current Lives;
    • Reaching 0 Lives causes a Game Over.
  2. The current score, followed by the Highscore achieved in the spawned vehicle;
    • More on scoring in the Scoring section;
  3. The Player Ship;
    • Once passing through the screen boundaries, the Player Ship wraps around to the other side, both vertically and horizontally;
    • The Player Ship's collision is a small circular collision, as shown in the image below:
      The Player Ship with its collision circle drawn on top of it
  4. A bullet shot by the Player;
    • Unliek the Player Ship, Bullets do not wrap around the screen;
    • There can only be a given number of bullets on the screen simultaneously!
  5. An Asteroid.
    • Just like the Player Ship, the Asteroids also wrap around the screen;
    • Once hit, an Asteroid divides itself in two smaller ones. This happens twice before they are destroyed for good!
    • Those have circular collisions that is the approximatedly the circumcircle of their sprites;

Scoring

When destroying an Asteroid, the Player is granted points. The amount of points granted depends on the Asteroid's size.
There are 3 Asteroid sizes:

The three Asteroid sizes, side-by-side

Sizes ranging from 3 to 1, from left to right:

  • Large (3): 50 points
  • Medium (2): 100 points
  • Small (1): 150 points

The Highscore can be kept indefinitely if connected to a Memory Register; more on that on the Data Input and Output section.

Asteroid Spawning

At the start of the game, an amount equal to the Asteroid Limit gets spawned. After that, new Asteroids can spawn in two ways:

  1. When a Large or Medium Asteroid is destroyed, two of the next smaller size are spawned at its place;
  2. When a Small Asteroids is destroyed, if the number of Astroids present doesn't exceed the Asteroid Limit, a Large Asteroid is spawned somewhere on the screen borders.

Configurability

Aside from changing the source code, the script makes use of Stormworks' Microcontroller Properties in order to configure some of the game's variables, which have some presets available in the aforementioned vehicle. If any of the properties are not present, the variable will be set to its default value.
Below is the list of available variables, with their default values and descriptions.

Variable Default Value Description
Lives 3 How many lives the Player has at the start of the game. Reaching 0 results in a Game Over.
Max Speed 0.75 Hard limit for the Player Ship's speed; measured in pixels per tick.
Acceleration 0.011 How fast the Player Ship accelerates; measured in pixels per tick.
Drag 0.002 How fast the Player Ship will reduce its speed; measured in pixels per tick.
Turn Speed 0.14 How fast the Player Ship can turn.
Bullet Speed 0.5 How fast the bullets travel, added to the Player Ship's speed when fired; measured in pixels per tick.
Bullet Limit 5 How many bullets can be on screen simultaneously at any point.
Asteroid Speed 0.5 How fast the asteroids travel; measured in pixels per tick.
Asteroid Limit 8 How many asteroids can be on screen before new ones stop spawning.

Data Input and Output

The game's script expects some information at the Data Input in order for it to work as intended. Those are as follows:

Input Channel Expected Behavior Used For
Acceleration On/Off [10] Signal is On when the Player is pressing the accelerate button Accelerates the Player Ship
Right Turn On/Off [11] Signal is On when the Player is pressing the right turn button Turns the Player Ship clockwise
Left Turn On/Off [12] Signal is On when the Player is pressing the left turn button Turns the Player Ship counterclockwise
Shoot On/Off [13] Signal is On when the Player is pressing the shoot button Shoots a bullet, once per press
Highscore Number [10] A number representing the current highscore Displaying and comparing highscores

The Data Output also is used:

Output Channel Used For
Highscore Flag On/Off [1] Signals when a new highscore is set
Highscore Value Number [1] The value for the current highscore

Although one could simply plug the Highscore Value output into the Highscore input, it is advisable to take advantage of the Highscore Flag output and use a Memory Register. The reason for this being that the internal Lua Script state gets lost once a vehicle is unloaded (due to being too far from any players), but the general Microcontroller's states (such as a Memory Register) are kept intact.

Future Improvements

  • Add an invunerability interval, so that the Player Ship can't be destroyed right after appearing
  • Rewrite the drawing portions of the code in order to maintain a more concise and robust way of describing and using vector sprites
  • Rewrite the bullet and asteroid management, as well as the collision system, so that there's a centralized handling of objects
  • Fix some of the rotation code

About

A non-faithful recreation of the classic game Asteroids playable in Stormworks: Build and Rescue.

Topics

Resources

License

Stars

Watchers

Forks

Languages