Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Thu 04/03/2004 01:27:05

Title: Scrolling room problem in RPG-like game
Post by: on Thu 04/03/2004 01:27:05
I'm using the AGS engine to make an RPG, and I'm having trouble with interactions. I'm making it so you move with arrow keys, and when you press enter, the character interacts with whatever is right in front of him. The code I'm using is this, in on_key_press:

 if (keycode==13) {
       if(character[GUY].loop == 0)
         ProcessClick(character[GUY].x,character[GUY].y+2,1);
       if(character[GUY].loop == 1)
         ProcessClick(character[GUY].x-20,character[GUY].y,1);
       if(character[GUY].loop == 2)
         ProcessClick(character[GUY].x+20,character[GUY].y,1);
       if(character[GUY].loop == 3)
         ProcessClick(character[GUY].x,character[GUY].y-20,1);
     }

Now, this works fine in small static rooms, but in scrolling rooms it all seems to bugger up, with hotspots all in the wrong place when I scroll along a certain amount. What am I doing wrong? Thanks.
Title: Re:Scrolling room problem in RPG-like game
Post by: Alynn on Thu 04/03/2004 01:37:13
I had a problem similar to this.

The characters x,y position is its pixel position on screen, not in the room itself, so you will probably have to add the GetViewportX() and GetViewportY() functions

So if (keycode==13){
if(character[GUY].loop==0)
ProcessClick(character[GUY].x + GetViewportX(), character[GUY].y + GetViewportY() + 2, 1);

///so on and so forth :)
Title: Re:Scrolling room problem in RPG-like game
Post by: on Thu 04/03/2004 02:50:14
Yeah, I tried that, but it didn't seem to help... and the plain old moving around system works perfectly alright in scrolling rooms, despite just being a case of:

MoveCharacter(EGO,character[EGO].x + 20,character[EGO].y)
Title: Re:Scrolling room problem in RPG-like game
Post by: a-v-o on Thu 04/03/2004 10:48:08
It should be:
ProcessClick(character[GUY].x - GetViewportX(), character[GUY].y - GetViewportY() + 2, 1);
Title: Re:Scrolling room problem in RPG-like game
Post by: Alynn on Thu 04/03/2004 18:57:16
Ok my bad, because my code is the following:

MoveCharacter(0, GetViewportX()+mouse.x, GetViewportY()+mouse.y);

I see where I got confused :P

I should lay off the crack....