SOLVED: Altitude display

Started by Slasher, Wed 30/12/2015 09:18:42

Previous topic - Next topic

Slasher

Hi

I am making an altitude indicator.

The character is climbing a mountain.

As the character goes up or down the screen the altitude indicator displays height up/down the mountain.

What i need to do is have the altitude display height (int) remain and continue when going to next room.

Eg leave room at say 400 feet and have altitude display height up the mountain display 400.

I have 2 ints in rep global exec always: Altitude and Height.

Code: ags

Laltitude.Text=(String.Format("%d", Altitude - cBond.y-1));
HEIGHT=Altitude - cBond.y-1;


Which of course works except it does not keep the exact altitude display height as per leaving previous room.

all help appreciated.

cheers


Cassiebsg

You could maybe use a global variable to store the previous altitude and add that to the new altitude (or subtract if the player goes down again)?
There are those who believe that life here began out there...

Slasher

That's what i was tying to do with the HEIGHT variable.

Khris

Are you changing rooms by sending the player to fixed coordinates?
Because you should probably do something like: player.ChangeRoom(5, player.y + 190);
That way, the next room is 190 pixels "higher" then the previous, regardless of the y coordinate the player happens to be at when triggering the room change. Now you simply add 190 to a global height variable in the next room's before fadein:   height += 190;

In your rep_exe, you calculate room height and add global height: height + (200 - player.y)

Slasher

#4
Hi Khris,

QuoteAre you changing rooms by sending the player to fixed coordinates?
Because most of the paths slop up the y co-ordinates will change in the next room (there will be about 10 rooms in all).

So this y needs to be allowed for.

apart from that the script's fine...(nod)

EDIT: Seeing as each room changes players y I have kept the Changeroom x y and used this in every room and just need to adjust the maths accordingly:

Code: ags

function repeatedly_execute_always() // in all rooms
{
// Example
 Laltitude.Text=(String.Format("%d", Altitude - cBond.y+240)); // adjust cBond.y+240 as required in each room.
 HEIGHT=Altitude + cBond.y-1;
}


This seems to do the trick and thanks Khris for your gentle hand (nod)


Khris

Sorry, but I guess you didn't understand my post at all. But if you got it to work...

Also, where are you using the HEIGHT variable?

Slasher

Quoteplayer.ChangeRoom(5, player.y + 190);
puts the character in a wrong y position in the next room and off the walkable area...

Khris

The 190 was just an example (and so was the 5). (roll)

It was all about keeping the altimeter consistent, given that it is based on the character's y coordinate.
If room A uses 400 - player.y, and room B uses 590 - player.y, then going from room A to B should increment the character's y coordinate exactly by 190.

Say they leave room A at player.y = 23. According to the altimeter, that's a height of 400 - 23 = 377.
If you send them to a fixed spot, like (10, 220), in the next room the altimeter will jump to 590 - 220 = 370.
If you instead send them to (10, player.y + 190), they will appear at 10, 213 and the altimeter will still show 590 - 213 = 377.

All you need to do is make sure that the region that triggers the room change covers a y range shifted by 190 exactly, or whatever the altitude difference between the two rooms is.

(also, what are you using HEIGHT for?)

Slasher

Hi Khris,

Quote(also, what are you using HEIGHT for?
I was going to use HEIGHT to tweak the altitude per room but it's not needed so its out.

Thanks for the info, taken on board.

cheers ;)

slasher


SMF spam blocked by CleanTalk