"Looping" Room or GUI

Started by LRH, Sun 01/01/2012 18:12:05

Previous topic - Next topic

LRH

I figure this should go in the newbie section, since this is really more of a "how does this get done in theory" question.

Basically what I'm trying to do is re-create the GUI from the Oregon Trail Deluxe game, which you can see here:
http://www.youtube.com/watch?v=vNcLSB0A3mI

My question is, how would I go about making the looping trail screen in the upper left corner during gameplay?

It isn't a pure loop, there are occasional "stops" during the trail, and if I really had things my way, I'd probably change the background scenery from the constant grass plateau and mountains in the distance.

Thanks for taking a look. Always appreciated.

Darius Poyer

Say the full scene has a full width of about 1000 pixels. You position everything based on the x position of a target object and subtract it from everything else. I would set it up like this

Code: ags

int wagon = 0;
int mountain = 230;
int cabin = 200;
etc...


Then anywhere
Code: ags

if(mountain>wagon) mountain = mountain - wagon;
else  mountain = wagon -  mountain;

if(cabin>wagon) cabin = cabin - wagon;
else cabin = wagon - cabin;

//to move
wagon++;

//display 
//it's simportant to never set the position of the wagon.
buttonMountain.X = mountain;
buttonCabim.X = cabin;
and so on...


very messy code there, but i think that would basically work.

Khris

When it comes to displaying the resulting scene, you can either use the actual room background and cover it in GUIs, just like the version you linked to.
Or you can draw everything to a DynamicSprite, keep it in memory, copy it to a second DynSprite, crop that, then put it on a button. When the background is supposed to be moving, you simply change the x coordinate, then copy and crop again.

SMF spam blocked by CleanTalk