Using ONLY left and right loops? (Obsolete, implemented)

Started by Hollister Man, Sun 03/08/2003 18:03:01

Previous topic - Next topic

Hollister Man

I tried, but I get wither a blue cup or the first frame of my second loop when walking up or down.Ã,  Any Suggestions?Ã,  This was suopposed to be a quick "hey I made one" game.Ã,  Up and down anims double my animating time.

*Cleck my last post for my solution*
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

Pumaman

This is not supported, but you can simply use the left or right frames for up and down.

scotch

Is there a reason why left and right aren't the first loops? the movement of the character is a bit strange if you put a left or right loop into the up one (see Byzantine demo)

Hollister Man

I thought there might be SOME way to do it.  The only problem is that if you are walking six degrees west of south, you could actually have the character walking backwards.  :P

I might try to do something along the lines of detecting the end-point of the walk, then animate whichever way it is supposed to go.  :)
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

Pumaman

Quote from: scotch on Sun 03/08/2003 18:29:36
Is there a reason why left and right aren't the first loops? the movement of the character is a bit strange if you put a left or right loop into the up one (see Byzantine demo)

Hehe no reason, just that when AGS was originally designed I didn't envisage anyone wanting less than 4 directions :)

Hollister Man

I deed eet!  I only wanted to make a quick demo called "Shoe Quest," so there was little point in taking twice the time wo animate the kid.  ANYWAY...  I inserted this bit of code into the On_Mouse_Click function.

if ((GetCursorMode() == 0)&&(button==LEFT))  {
   if (mouse.x>character[EGO].x){
     SetCharacterView(TIM, 3);
     MoveCharacter(TIM, mouse.x, mouse.y);
     }
   else {
     SetCharacterView(TIM, 6);  
     MoveCharacter(TIM, mouse.x, mouse.y);
     }
   }

Right before else if (button==LEFT) {

It works like a dream.  It checks which side ofthe character you clicked towards, then sets the view accordingly.  I had to make 4 loops right and 4 left, which meant a lot of "click-doubleclick"ing, but an overall time saver for me.  Here it is y'all.
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

Deckard

My player character only has one animation - for moving to the right. And using FLIPPED option in VIEWS this is enough for moving the character in all directions (diagonals included) - except for up and down.

I noticed when character moves up (or down) and a tad bit to left (or right), AGS uses animation from UP (or DOWN) which is set in the VIEW. It does not use diagonal animation.

Which makes it a problem. Since for up and down animation I can use either left or right animation, it looks strange because if I use left animation, then when characters moves up and tad bit to right, it looks as if the character is moving backwards (that is, facing left while moving a bit to the right). If up and down animations would be used only when moving strictly vertical there would be no problem, but now, I don't know how to solve this problem.

Yes, I know, one obvious way would be to animate the character going up and down, but I really really suck at animation and can't do it - I snatched this particular animation off the net and therefore can't use any other similar anim, it would look too out of place...

Any ideas? Any help?

Thank you.

Kweepa

#7
I'd say that thread from the tech archive doesn't really solve the problem, just hacks around it somewhat.
If the pathfinding takes the player character in the opposite direction to the mouse click then it fails.

A possible solution would be to use blank sprite loops (the same number of frames as the walk cycles you have) for the four walk directions, then when EGO is walking, keep track (in repeatedly_execute_always) of which direction EGO moved last and move and animate an object to match. Probably not a beginner's solution though.

Here's some code for 2.62.

Code: ags

// GLOBAL STUFF

#define LEFT 0
#define RIGHT 1
int faceDir = RIGHT;
int lastX = 0;

// assumes a four frame walk
int walkLeftSprites[4];
int walkRightSprites[4];

// IN GAME START

walkLeftSprite[0] = xx;
walkLeftSprite[1] = xx;
walkLeftSprite[2] = xx;
walkLeftSprite[3] = xx;
walkRightSprite[0] = xx;
walkRightSprite[1] = xx;
walkRightSprite[2] = xx;
walkRightSprite[3] = xx;
lastX = character[EGO].x;

// IN REPEATEDLY EXECUTE ALWAYS

if (character[EGO].walking)
{
   ObjectOn(OBJECT_PLAYERWALK);
   if (character[EGO].x > lastX)
   {
       faceDir = RIGHT;
   }
   else
   if (character[EGO].x < lastX)
   {
       faceDir = LEFT;
   }
   int sprite = 0;
   if (faceDir == RIGHT)
   {
      sprite = walkRightSprites[character[EGO].frame];
   }
   else
   {
      sprite = walkLeftSprites[character[EGO].frame]; // FIXED ERROR
   }
   SetObjectGraphic(OBJECT_PLAYERWALK, sprite);
   int width = GetGameParameter(GP_SPRITEWIDTH, sprite);
   SetObjectPosition(OBJECT_PLAYERWALK, character[EGO].x - width/2, character[EGO].y);
}
else
{
   ObectOff(OBJECT_PLAYERWALK);
}
lastX = character[EGO].x;


Completely untested and you may need to do something when changing rooms...

Cheers,
Steve
Still waiting for Purity of the Surf II

Deckard

Arh, I really don't know what I was thinking. I posted this question, because I had exactly the same solution in mind, but for some strange reason I was sure AGS does not know the concept of events and thus doesn't raise one on, say, mouse click.

When I saw the code I delved deeper into the manual and of course, there they were, events. And then I suddenly noticed them on drop down menus in AGS. Which funny enough I noticed before (and even wrote about them in the other thread in this part of the forum) but it never dawned on me that these were in fact events.

I feel so stupid...

Anyway, to make up for my stupidity, here is the code from the archived thread, except it is modified to suit the 2.7 OO programming (new code is between first and last line):

Code: ags

Ã,  else if (button == eMouseLeft) {[b]
Ã,  Ã,  if (mouse.Mode == eModeWalkto)Ã,  Ã, 
Ã,  Ã,  Ã,  if (mouse.x>cEgo.x) {
Ã,  Ã,  Ã,  Ã,  cEgo.ChangeView(VIEWRIGHT);
Ã,  Ã,  Ã,  } else {
Ã,  Ã,  Ã,  Ã,  cEgo.ChangeView(VIEWLEFT);Ã,  
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  Ã,  ProcessClick(mouse.x, mouse.y, mouse.Mode );


Steve, your dillema to this solution is interesting, however my player character can walk all over the screen, so he goes from point A to point B in a straight line.

However if in future it won't be so, your solution will come in handy...

Thanks to you both, guys...


strazer

Quote from: Gilbot V7000a on Wed 15/06/2005 02:31:15
Actually since V2.6 of AGS:
Quote
- Added ability to have only left/right walking frames for
   characters (just delete all frames in loop 0).

You don't actually need any scriptings to disable the up/down loops.

edmundito

Another easy way is to just make the walkable areas smaller so that the character cannot go up or down often.
The Tween Module now supports AGS 3.6.0!

Gilbert

Maybe we can move this thread back to technical forum and lock it, so people won't waste their time incorporating long codes into their game, before realizing that it can now be done automagically.

Hmmm, maybe adding an entry in BFAQ is a good idea (if it's not already there).

SMF spam blocked by CleanTalk