Walk backwards

Started by johanvepa, Mon 16/02/2015 20:14:30

Previous topic - Next topic

johanvepa

Is there a way to make a character walk backwards? That is, keep his current view, but reverse his direction and animation.

Snarky

No. The simplest way to do it is to create another view with the directions flipped and the animations reversed. It would also be possible to code a module to reverse the view (and flip the character orientation), but that's probably a bit beyond the Beginners' forum.

selmiak

if you want to save time when animating just click on every frame in the character's view and set flipped to true. Works best for left/right and not so good for up/down.
If you want to be able to flip a character's visible movement for gameplay or confusion just create a new view and switch the frames accordingly in the view and change the view ingame when needed.

johanvepa

Weeell, both solutions are of course simple and straightforward enough. Only I was hoping for something that would let me avoid doing that by instead using a not-so-custommade piece of coding  :-D

Anyway, It's back to the drawing board for me ;)

Slasher

#4
Hi,

it would depend on how you want it applied.

in one room if char x = this:

Example I have used
Code: ags

function room_RepExec()
{
 if(cMazio.Room==10)
  
 if(cConrad.x  >=  cMazio.x) // causes view to be 1 and walking backwards to right of screen 
 cConrad.Loop=1;

 else if(cConrad.x < cMazio.x) // or just use else
 cConrad.Loop=2;
}



johanvepa

Slasher, I  haven't tried out your code yet, but I am a bit confused as to why you set cConrad's LOOP to 1 or 2, I would expect his VIEW to be the key?


Slasher

#6
Quote, but I am a bit confused as to why you set cConrad's LOOP to 1 or 2, I would expect his VIEW to be the key?
The players view is already determined in his properties: you are just manipulating his view loops.

In my example: if player is over another's chars x then he will turn to loop 1 and will walk backwards if you walk further to the right of other character's x and loop 2 if lower that chars x so you always face char. You may of course have a different condition.

I have this situation in a game and it works fine ;)




monkey0506

Quote from: slasher on Mon 16/02/2015 20:44:31
Code: ags
  if (cConrad.x >= cMazio.x) {}
  else if (cConrad.x < cMazio.x) {} // or just use else

The two conditions here are mutually exclusive. If one is true, then the other never can be (at that moment). Only one is true at a time, and it being true means that the other is false. You should never, ever, ever, ever, ever, ever do this. Ever.

If there is any possibility that one condition could change the state of cConrad.x or cMazio.x, then it might make sense to have a separate if-statement. But using else if to check the exact inverse of a condition is never right - that is what else means. If you want to add a note to yourself for added clarity, that is when you should add a comment.

Code: ags
  if (cConrad.x >= cMazio.x) {}
  else {} // this MEANS that cConrad.x < cMazio.x!

Slasher

Yar, my slip up... Cheers Monkey ;)

johanvepa

i'll have to give this a few try-outs, I guess. Thank you for your suggestions everyone.

SMF spam blocked by CleanTalk