Vertical Scrolling Room [SOLVED]

Started by arj0n, Sat 17/07/2010 09:31:50

Previous topic - Next topic

arj0n

I'm trying to get a vertical scrolling room working.
Gameresolution: 640x480, room background resolution: 640x5421
Can't figure out why this piece of code doesn't work...:


function room_RepExec()
{
if (mouse.y <= 20) { //if mouse is near top of screen
 SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels. Change this for quicker or slower scrolling.
}
else if (mouse.y >= 300) { //if mouse is bottom of screen
SetViewport (GetViewportY() + 10, GetViewportX()); // scroll up 10 pixels. Change this for quicker or slower scrolling.
}
}

GarageGothic

#1
You're ADDING ten pixels in both cases. Obviously the first case should subtract them. Also you will need to check that you're not setting the Viewport out of the room bounds.

Edit: Did you just edit the code? Or am I seeing things? Just realized, you've inverted the x,y coordinate order in SetViewport.

arj0n

added this:
SetViewport (GetViewportY() + 10, GetViewportX()); // scroll down 10 pixels.
into:
SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels.

I noticed it after submitting the post...

arj0n

The problem is that it doesn't scroll at all ???

GarageGothic

Made an edit of my own:

Quoteyou've inverted the x,y coordinate order in SetViewport

arj0n

{
if (mouse.y <= 20) { //if mouse is near top of screen
  SetViewport (GetViewportX() - 10, GetViewportY()); // scroll down 10 pixels.
}
else if (mouse.y >= 300) { //if mouse is bottom of screen
SetViewport (GetViewportX() + 10, GetViewportY()); // scroll up 10 pixels.
}
}

Having this, still nothing happens.

GarageGothic

Dude, you still need to add/subtract the pixels from the y coordinate (vertical), not the x (horizontal)

arj0n

I'm sorry but I don't understand it.

Tried this
SetViewport (GetViewportX() - 10, GetViewportY()); // scroll down 10 pixels.
and this
SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels.

both do nothing...

GarageGothic

Code: ags
SetViewport (GetViewportX(), GetViewportY()-10);


That's scroll UP 10 pixels, btw.

arj0n


Khris


arj0n

#11
Yeh sorry, I know... ;)

Somehow I thought I needed to switch GetViewportX() & GetViewportY()
in stead switching the number of pixels from X to Y...
Anyway...

Matti

;D

Sorry, but that's the funniest beginner's tech thread I've seen in a long long time.

SMF spam blocked by CleanTalk