Page 2 of 2

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 12:33 pm
by youbob1212
Hello, Hey very good job, but could you show a step by step tutorial. Because as a noob, I don't really know what you did or which steps did you take to make this product.

Thanks anyways, and if not I will figure it out someday.

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 12:49 pm
by SuperSonic
Nice job lcl :D
+point

I'm having a little trouble understanding your code though :)
In the key down event, what does "if (!stop)" mean?
Second, what does "sprintf" do?
And third, i'm having trouble understanding the switch statement for when both keys are pressed.
Could you help me a little? :P

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 1:37 pm
by schnellboot
SuperSonic wrote:Nice job lcl :D
+point

I'm having a little trouble understanding your code though :)
In the key down event, what does "if (!stop)" mean?
Second, what does "sprintf" do?
And third, i'm having trouble understanding the switch statement for when both keys are pressed.
Could you help me a little? :P


1. if(!stop) is similar to if(stop==0)

2. sprintf(stringVar, "string") put's the "string" in stringVar

3. the switch statement is if the previous animation was left or leftStop it's changed to leftStop and if prevAnim was right or rightStop it's changed to rightStop

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 3:17 pm
by Game A Gogo
http://www.rohitab.com/discuss/topic/11 ... rial-in-c/

sprintf is one heck of a time saver... I use it almost in every game I make now!

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 4:32 pm
by SuperSonic
Thanks schnell :D
but when I said I was confused about the switch statement i meant I was confused why he put case 0 and then put no instructions for it. Same with case 1.
Could you help me with that? :P

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 8:04 pm
by schnellboot
yes
case 0:
case 2:
means if 0 or 2

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 8:55 pm
by SuperSonic
Aha :P Thanks
+point :wink: :wink:

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 9:53 pm
by lcl
Sorry SuperSonic, I wasn't here to see your post..
I would have helped you if I saw it earlier. :)

And youbob1212:
The code works by printing the animation name to global variable and then changing that named animation for the actor. :) ask more if you need to. :)

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sat Apr 23, 2011 10:38 pm
by SuperSonic
Sorry SuperSonic, I wasn't here to see your post.

That's Ok :D
But maybe you could explain why you did not set any instructions after case 0 and case 2 :P

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sun Apr 24, 2011 7:18 am
by schnellboot
SuperSonic wrote:But maybe you could explain why you did not set any instructions after case 0 and case 2 :P

so you want him to explain it or didn't you understand what I said?

Re: Easiest anti-moonwalk of all the time!

PostPosted: Sun Apr 24, 2011 7:25 am
by lcl
Oh, yeah I should have commented also those lines.
0 and 2 are animations facing left and 1 and 3 facing right.
This code
Code: Select all
switch(prevAnim)
{
    case 0:
    case 2:
        sprintf(anim, "charStopLeft");
    break;

    //and so on with cases 1 and 3..
}

works just the same as this would:
Code: Select all
if (prevAnim == 0 || prevAnim == 2)
{
    sprintf(anim, "charStopLeft");
}
//continues with prevAnim == 1 || prevAnim == 3


So, if two cases are put in line without break; between them they will share the same code until break;

Did that help you? :)

Re: Easiest anti-moonwalk of all the time!

PostPosted: Mon Apr 25, 2011 2:52 am
by SuperSonic
Oh Ok, I was still a little confused even after schnell explained it but I understand now :P
Thanx