Star developer diary

Star developer diary

About Star

Star is an hobby game developed by me for the purpose of improving my game development skills with OpenGL and C++. It's using the SDL library.

It's an arcade game where the player controls a spaceship and dodges incoming asteroids on its way to Earth. The latest playable version can be found in my portfolio.

3D-feel Starfield

CodingPosted by Marie Mon, April 30, 2012 12:40:09
In Star, I'm using three layers in order to create a feeling of 3D-depth in a 2D game:

* Front stars, moving fast and pulsating, large size

* Middle stars, moving fast, medium size

* Background stars, moving slow, small size

The depth feeling comes from the two last layers, when you see the "closer" (larger) stars moving past the "distant" (smaller) ones.

But lets talk and let me show you some code on the first one, the pulsating front stars. This layer if made up by three different textures, that each is transparent except for a few white painted stars.

I only show one of the three front star textures and once, and toggle which one is used, with a pause in between. When a texture is being used, I will gradually change the transparency to make a fade-in-fade-out pulsating effect.

I also move the layer to the left and paint it anew to the right as the side-scrolling game progresses.

Code sample from the pulsating stars:

Fill in only if you are not real

The following XHTML tags are allowed: <b>, <br/>, <em>, <i>, <strong>, <u>. CSS styles and Javascript are not permitted.