Skip to content

A small game written in Processing. Enjoy your flight through deep space in a comfy spaceship but don't forget to avoid asteroids!

Notifications You must be signed in to change notification settings

MariiaSkybaIntel/Space-flight-mini-game

Repository files navigation

THIRD PERSON SPACE FLIGHT MINI-GAME

The code for this game is written in Processing language (Java Mode).

Important prerequisites:

  • Copy the code into a new Processing sketch and save it in a folder with the same name.

  • Create a new folder called "Data" inside the main sketch folder.

  • Download and store all the attached files into this folder for the game to work correctly.

  • DKThievery.vlw font needs to be installed.

  • Minim library needs to be installed in Processing to play audio files.

Game logic:

Control the spaceship with the right and left keys.

You've got three lives. The goal is to reach maximum possible speed.

Avoid collisions with asteroids. The faster you travel the faster they appear.

Your record will be displayed on screen after no more lives are left.

Additional info:

Four different trajectories have been created for the asteroids to move along using vectors. The following variable generates a random number from 0 to 3 and then passes the value to 'side':

float fside=random(0,4);
side=int(fside);

This tells the asteroid which trajectory to use. Each trajectory uses three vectors, so the corners of an image can be guided along these lines. Asteroid sprite increases in size as it moves along a trajectory. This was achieved by guiding the four points of the asteroid image along the trajectory lines, which spread out near the edges of the screen. This helped create the illusion of depth.


Spaceship movement is calculated by using trigonometric functions:

spaceship_x = 220 * sin(angle) + OriginX;
spaceship_y = 240 * cos(angle) + OriginY;

It moves in a semi-circle to help create perspective. Left and right keys control spaceship’s movement.

movement

Credits and resources:

About

A small game written in Processing. Enjoy your flight through deep space in a comfy spaceship but don't forget to avoid asteroids!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published