Scrolling room problem in RPG-like game

Started by Flim, Thu 04/03/2004 01:27:05

Previous topic - Next topic

Flim

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.

Alynn

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 :)

Flim

#2
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)

a-v-o

It should be:
ProcessClick(character[GUY].x - GetViewportX(), character[GUY].y - GetViewportY() + 2, 1);

Alynn

#4
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....

SMF spam blocked by CleanTalk