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.

AppGameKit Classic Chat / Endless Background

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Nov 2014 20:37
Hi.

I want make endless background for my game but I don't know how to do it.

Please Guide Me.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Nov 2014 22:04
Check out SetSpriteUVOffset

You can make a sprite that is wider than your screen and scroll the texture by setting the UV offset. Make sure the ends are seamless so that you don't see a join.

Quidquid latine dictum sit, altum sonatur
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Nov 2014 22:11
or if sprites move left outside move it again to the right outside.
meaning clouds,trees,ground etc.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 6th Nov 2014 00:02
...or use a tilemap. Just remember to copy the first screens worth of tiles to the last screen of tiles so that it can loop around.

Then of course you have procedurally generated backgrounds that could go on and on forever For example, if your background is a space scene, you could have a bunch of planet, star, nebula etc. sprites and simply use the RANDOM function to place them. Make sure you set a random seed at the beginning of your code so you get the same sequence of 'random' positions on each run.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2014 09:23
Quite often I create randomly generated backgrounds (using an integer seed if you want the background to always be the same). If it is a constantly moving sidescroller (for example) this is a great way to deal with an 'endless' background as you can just "randomly" add scenery as you go along and delete scenery as it goes off screen. Attached is a current WIP as an example of what can be done easily although I've only added trees and bushes as yet... If you play the game a couple of times you'll see that the background and enemy are always the same but actually you can play the game for hours (if you don't die and it's currently pretty easy not to die) and still have the same enemies and background each time.

Never underestimate the usefulness of "Random"...

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Nov 2014 09:56
Imagine if Hanna Barbera had Random capabilities in their cartoons. Scooby Doo and Top Cat chase scenes would never be the same again!

Quidquid latine dictum sit, altum sonatur
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 11:06
Thanks All For Guide.

and Thanks baxslash for your example but I can't download it.

I attach my project, Please if possible show me your mean in this Project.

Thanks.

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Nov 2014 11:54
Remember to set the image to X and Y wrapping - otherwise the UV offset may not work. I think the command is SetImageWrapU(img,1) and SetImageWrapV(img,1)

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 12:10
Quote: "Remember to set the image to X and Y wrapping - otherwise the UV offset may not work. I think the command is SetImageWrapU(img,1) and SetImageWrapV(img,1)"


Thanks VanB but this commands don't change any thing.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2014 13:38
Quote: "I attach my project, Please if possible show me your mean in this Project."

Here's an example of how you could easily add to your code to make the background endless:
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 13:58
Thanks baxslash work very well.

Login to post a reply

Server time is: 2024-05-02 10:36:03
Your offset time is: 2024-05-02 10:36:03