Kind of Isometric character control (SOLVED)

Started by , Fri 09/06/2006 18:57:54

Previous topic - Next topic

Nightsky

Hi to all,
I'm new here at the forum. I'm working on a project, that for now I would prefer to keep secret, (at least until I have something more consistent) based on Isometric view. I have a poor programming background, based on a little experience in Flash actioscripting, and obiouvsly, I'm stuck in a little problem, concerning the main character keyboard control. To say the truth, the view of the game is not a proper isometric (or at least, so I think), because I would like to permit only 4 directions: left, right, upright and downleft; I searched the forum and the KB and I don't know how to realize it. I tried using KeyboardMovement101, but what I need, it's a script that let me move left and right of a "X" quantity, and upRight and downLeft of a 2X quantity. The problem is when I set, for upRight and downLeft, a quantity bigger than X, because the diagonal view is changed with the lateral view, I don't know why. Logically, the best solution would be a complete isometric movement in 8 directions, where up,down,upleft and downright are disabled. I hope this section of the forum is right for this problem. Thank you in advance, for helping us all newbies!

Ashen

So what exactly is your question? How to mimic isometric movement with keyboard controls?

I think you can do it quite easily, adapting the KeyboardMovement module you've already got. (I'm assuming you mean this one.)

Open up the module manager, and edit the script. Scroll down to the repeatedly_execute function, and find the section that starts (around line 92):
Code: ags

  if (newdirection == eKeyboardMovement_DownRight) {
    dx = DISTANCE;
    dy = DISTANCE;
  }


Now, for the Upleft, DownLeft, UpRight and DownRight conditons, set dy to be half it's current value (if the line says dy = DISTANCE; make it dy = DISTANCE/2;, if it's -DISTANCE, make it -DISTANCE/2). The player should now move in a smore Isometric way, rather than the diagonals being at 45 degrees.
(You'll need to make the same changes to the on_key_press function, around line 163).

Just above that bit of code (line 74 for rep_ex, line 147 for on_key_press) there should be a group of lines that control setting the direction. You can edit those to limit movement to the directions you want.

QuoteThe problem is when I set, for upRight and downLeft, a quantity bigger than X, because the diagonal view is changed with the lateral view, I don't know why.

I'm not sure what you mean here. I'm guessing you mean that when a character moves 'isometrically', it uses the standard left/right loop, and not the diagonal one? If so, I think that's how AGS is coded to work, and I don't know what you can do about it. You could try locking the player to the proper loop, using the Character.Loop property in rep_ex. You could also check out Bernie's 8-Direction Movement module, which handles the loops differently. (But you'll need to adjust it to do isometric angles.)
I know what you're thinking ... Don't think that.

Nightsky

Thank you very much, Ashen, I think your answer respond exactly to what I need. I'll give it a try and let you know how goes it.

Nightsky

Many thanks Ashen, your useful tips were precious!
Well, I solved the problem using the Keyboard Movement 101 (the same you first suggested, because I found more simple than the 8 directions one) and 2 different views for the mai ncharacter. But one step at a time:

1) I created a new view (view2) of the main character, where loop0 (down) is replicated as loop1 (left) and loop3(up) is replicated as loop2 (right).

2) I modified the Keyboard Movement 101 so to remove all the lines concerning the diagonal control (upRight,UpLeft,DownRight,DownLeft) and added the character[EGO].lockview() property as follows, around line 82:

if (newdirection == eKeyboardMovement_Down) {
            dx = -(DISTANCE+DISTANCE);
            dy = DISTANCE;
            character[EGO].LockView(2);
         }
         else if (newdirection == eKeyboardMovement_Left) {
            dx = -DISTANCE;
            dy = 0;
            character[EGO].LockView(1);
         }
         else if (newdirection == eKeyboardMovement_Right) {
            dx = DISTANCE;
            dy = 0;
            character[EGO].LockView(1);
         }
         else if (newdirection == eKeyboardMovement_Up) {
            dx = (DISTANCE+DISTANCE);
            dy = -DISTANCE;
            character[EGO].LockView(2);
         }

And all works fine for me! I know, It may be not much elegant, but it works.
Thanks again Ashen!

SMF spam blocked by CleanTalk