Testing out some 2D concepts, Dynamic Background
Few hours of boredom, and wanting to play around with some new ideas and just a 2D program, and a very basic “space” shooter was born.
And while this game isn’t overly complex, it was fun to just put together a small, very simple game while not having to worry about 3D math and graphics :) I think my next project will not be a game, really.. but more so a particle engine or a more complex editor for putting together a 2d terrain. We’ll see how it goes. I would like to eventually put together a mini-RPG like game (think Secret of mana style) eventually, but learning 3D is priority for me at the moment.
So one of the cool things I was trying out with the screenshots above, was a dynamic sky background. I kinda wanted to see how many stars you could get on screen before the game started dropping frames left and right… and to my surprise even when putting 10,000 stars in the background (which didn’t look good AT ALL) and having each one of those stars update every frame with random modifiers for velocity and intensity, the game still ran at a silky smooth 60fps. In case you’re wondering, the cut-off before I got any sort of frame drops was around 35,000 stars in the sky. It really isn’t that complex of code either.. but here is the stars Update method;
public void Update(GameTime gameTime)
//Updates the stars position in the sky
_position.X -= (float)(gameTime.ElapsedGameTime.TotalSeconds * RNG.GetRandomFloat(.1f, 10f));
//if the star goes off screen, recycle star
if (_position.X < 0)
_position.X += Globals.GraphicsDevice.Viewport.Width;
Now normally I wouldn’t do anything like this in a real game, I’d just create a star texture for the background and maybe a set number of dynamic stars, but to have 1000 stars in-game like this.. looks pretty cool for a small game :)