roguish

Space Junk – Experimental Mobile Physics Game

Space Junk is the latest in my small anthology of experimental 2d spaceship games all using a similar 2-button input mechanic.

Sample gameplay video:
https://www.youtube.com/watch?v=ZTZBzigoAwQ

Space Junk is a prototype and works on both Android and iOS platforms. It is available as and Android APK file here: Space Junk, though it is not polished-enough to be released in the Google Play store. Apple restricts non-store distribution so although it works on my Apple test device, I have not made a playable version for distribution for Apple devices.

Gameplay:
The player sees a top-down perspective of a spaceship and 2 buttons on screen. Each button fires one of the thrusters at the rear of the ship. Like each paddle of a canoe the momentum from each thruster adds forward momentum and also turns the spaceship. Accurate steering is difficult. This dual-thrust control scheme is the feature of the game that makes it unique.

Physics:
Space Junk improves on my previous iterations of my 2d dual-thruster spaceship game with the use of 2D rigid-body physics to control all motion and collisions. The game engine is the open source Cocos2d-x v.3.3 (C++). The native physics engine integrated into Cocos2d-x is a derivative of the Chipmunk physics engine.

Camera:
I used the native integrated camera feature to track the spaceship.

  • The camera focuses on a point ahead of the ship. The ship may *drift*, moving laterally to the orientation of the ship, so the camera is placed in the direction of the ship’s movement without regard for the direction the ship is facing. As the ship moves faster the focal point is moved farther away from the ship, effectively placing the ship towards the *back* side of the screen, away from the direction of movement. This allows the user to see more of what’s in the ship’s path. Smooth camera movements are accomplished by Lerping the camera to the calculated target position.
  • A very gradual camera pull-back accompanies changes in speed to allow even more of the scene to be seen as the ship gathers speed, giving the player time to account for distant obstacles.
  • The camera is treated as a physical object in the scene, moving in/out in the z-direction as explosions occur and are resolved.

Control Scheme:
The Left Thruster/Right Thruster control scheme is awkward and requires some practice and patience. Player’s initial expectations may be that the right button is used to turn the ship to the right. In this game the right button controls the right thruster, which if fired exclusively of the left thruster, actually turns the ship to the left (think canoe or kayak steering).

Particles:
Cocos2d-x has an integrated particle effects engine. I used it in several places: ship thrusters, bomb explosions, and collision impact bursts.

Radar:
In Space Junk the magnets are the key elements players want to move towards so they are what the radar/compass points towards. By overlaying the radar over the game screen, the radar works as a head-up display and is easier to interpret and use – the player simply steers their ship in the direction of one of the radar’s magnet icons encircling the game screen.

Gravity & Repulsion:
Magnets apply a small persistent effect on nearby objects and when they’re activated they pull with much more force for a few seconds. When bombs explode they apply a large radial one-frame repulsion impulse to all nearby objects, with greater force applied to closer objects.

Scoring:
Explosions, going fast and crashing into things are the fun parts of the game, so that’s what the player can do to earn points. Explosion point values increase for objects closer to the bomb detonation point. More points are awarded for medium and high-speed collisions between the ship and objects. Going fast for long amounts of time is a way to earn a few points, and high-speed collisions are also rewarded. :)

Boundaries:
Objects have unconstrained boundaries, however for the sake of preventing objects from getting lost in space, objects that drift outside the star field (the primary playable area) will be slowly pulled back into the star field.

Expansion of Features and Objectives:
There are several additional features I’d like to add to the game, however this game was made as an exercise and I’ve learned and practiced the features of Cocos2d-x that compelled me to make this prototype so I have put further development on hold. I don’t expect to implement any more expansions, but if I did…

  • chained explosions
  • explosions made more intense by the inclusion of fuel cans caught in the blast radius
  • worm holes that warp from one area to another or banish Space Junk to another corner of space
  • Scoring: Add time limit and leaderboard
  • Objective: Space Junk Salvage. Implement some sort of gravity net that allows the ship to collect and transport the Space Junk that is encountered. Filtering the good from the bad to create a high purity salvage becomes a goal. Explosions could be used to incinerate junk or still just used to spread it around making filtering the good stuff easier.
  • Gameplay: Multiplayer
  • Gameplay: Obstacle course. Steering around a prescribed course as space junk floats around getting in the way. Multiplayer mode would allow magnets and bombs to be used strategically for offense and defense.
  • Controls: variable thrust for each thruster. Instead of toggle buttons for the thrusters, each thruster is controlled with an analog stick. Touch each thruster control slider and slide your finger up the screen to control the amount of force applied by the thruster.

For earlier versions of my dual-thrusters experimental game, see these YouTube Links:

Leave a Reply