Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / infinite 2d background for space game

Author
Message
logicandchaos
15
Years of Service
User Offline
Joined: 22nd Sep 2009
Location:
Posted: 5th Nov 2009 02:44
hi i'm making a 2d space game and after a while when i move i run out of background and i want it to just keep going forever, i'm not sure if i should make a bigger image 4 the background that wraps around or tile a smaller image for the background, but i'm not sure how to go about either way, or the best way 2 do it, the movement is in both the x and y axis.

logicandchaos
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 5th Nov 2009 04:08
for stars, I'd make a vector of classes. The classes should have the x, y and z positions of each star which you could randomly generate in the beginning. Then when the player moves, go through the vector and move the stars in the opposite direction that the player is moving (so it looks like they're moving) and then divide it by its z position. Here is some code (I did a space shooter a while back too)

SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 5th Nov 2009 04:35
take a look at the dark invaders sample where it has an infinite background

if(You.AddCode.toPost)TGC.Users.CanHelp = true;
else return NoCodeMessage;
logicandchaos
15
Years of Service
User Offline
Joined: 22nd Sep 2009
Location:
Posted: 5th Nov 2009 15:11
actuall i started out with the dark invaders sample and i just, looked it over more closly, there is 2 of every background sprite, right, to make the background continuous, but to add left right movement i would have to add 2 more sprites, i think, to have 4 setup like: 12
34
puppy of kosh thanx for the code i was considering something like that, i think it would be the best for star movment, but wasn't sure how to implement it
i was thinking maybe i can use both ideas together, have black background and vetors 4 stars for the bottom layer, and have images over top 4 the other layers, like in dark invaders, anyways thanx alot

logicandchaos

Login to post a reply

Server time is: 2024-10-01 16:39:45
Your offset time is: 2024-10-01 16:39:45