top of page
gergokocsis

Asteroid Game

Updated: Nov 1, 2021

One of my assignments was to create a small game prototype with a parallax background, random spawning, and collision detection in C++ using SFML.

This is how Asteroid Game came to life (very creative name, I know). The difficulty increases as each time interval a new asteroid is awakened and becomes active, which means it will spawn just off the right side of the screen.

As the asteroid leaves the screen on the left side, it is immediately teleported back to the right side in a place where it will not collide with other asteroids.

The difficulty, therefore, increases over time as more asteroids are active and moving towards the left endlessly.

There are 100 asteroids in the game, each second, one asteroid becomes active and begins moving to the left.

The background is made up of 8 sprites, however, the sky and the ground do not move. The others are moved by a factor depending on their order on screen. The same effect could have been achieved by moving a rect across the texture, however, at lower fames per second, this could look choppy, so physically moving two instances of the texture across the screen and teleporting them when they move off-screen is a more elegant solution to this problem.


3 views

Recent Posts

See All

Comments


Commenting has been turned off.
bottom of page