Easiest anti-moonwalk of all the time!

Non-platform specific questions.

Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 12:48 pm

:D Hello, here's very easy and simple anti-moonwalk.
There is very few lines of code in the demo, but animations work perfectly. :D

There is ChangeAnimation() - command in the draw actor event and it does all the animation
changings. String called anim holds the animation names and prevAnim holds last animations
animindex. It's used for changing animations when keys right and left are pressed.

I hope it's useful. :)

- lcl -


EDIT: demo updated
Attachments
Anti-Moonwalk.zip
Here is the example file
(14.29 KiB) Downloaded 427 times
Last edited by lcl on Sun Feb 27, 2011 6:15 pm, edited 3 times in total.
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby skydereign » Sun Feb 27, 2011 12:54 pm

If you press both left and right down at the same time, it messes up, so not quite perfect. I still say the state method is easier, although it does have more lines of code.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 1:16 pm

Messes up?
It didn't when I tried it. When you press both of them it changes the animation to
stopright or stopleft according to were you moving left or right. That's what I think
seems best when both keys are pressed. :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby Hblade » Sun Feb 27, 2011 1:17 pm

NICE


EDIT: HOLY FREKN' CRAP DUDE.... EPIC
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 180 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 1:49 pm

Hblade wrote:NICE


EDIT: HOLY FREKN' CRAP DUDE.... EPIC

Thanks! :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby Hblade » Sun Feb 27, 2011 1:51 pm

It's so simple yet advanced! :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 180 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby skydereign » Sun Feb 27, 2011 1:53 pm

Well the difference probably has to do with our keyboards. After a bit of debugging, I figured out why this happens though.
Order of events:
Key Right [stop=0, prevAnim=3]
Key Left [stop=0, prevAnim=3]
Key Both [stop=1, prevAnim=3]

So, it doesn't update prevAnim quick enough (as in the draw event happens after the fact, to be precise the last event to trigger), and the animation is locked. You can fix the flaw by changing the animation on the actual event, but that would ruin the whole point of this method. Another weird thing is that keydown events seem to trigger more than once per frame.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 2:25 pm

skydereign wrote:Well the difference probably has to do with our keyboards. After a bit of debugging, I figured out why this happens though.
Order of events:
Key Right [stop=0, prevAnim=3]
Key Left [stop=0, prevAnim=3]
Key Both [stop=1, prevAnim=3]

So, it doesn't update prevAnim quick enough (as in the draw event happens after the fact, to be precise the last event to trigger), and the animation is locked. You can fix the flaw by changing the animation on the actual event, but that would ruin the whole point of this method. Another weird thing is that keydown events seem to trigger more than once per frame.

Wow, that's weird. :shock:
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby skydereign » Sun Feb 27, 2011 2:31 pm

Well now that I think of it, the error makes sense, even though the other part doesn't. Essentially your system requires a one frame delay to act perfectly, as you you don't apply a lock. Just to note, the multiple key events per frame stops a couple of frames after the key down events. It eventually stabilized to left, both, right, draw as the order.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 2:47 pm

Ah, ok.
Since it works fine for me I can't test that but how would it work for you if you
would write prevAnim = animindex; before sprintf(anim, "..."); in key down events?
Could you try it? :D

EDIT: I got this problem also, I just had to press other one of the buttons
repeatedly. I tried moving the prevAnim thing into keydown events and the problem seems
to be gone! :)
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Sun Feb 27, 2011 6:17 pm

Hey, I found the most important thing for fixing that problem you mentioned, skydereign.
When you hit two keys immediately same time the animation glitched.
But all I had to do was to add cases for animindexes 2 and 3 to key down for both keys pressed same time. (See the new demo) :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby skydereign » Sun Feb 27, 2011 11:28 pm

Wow... should have realized that. It was around 6:00 in the morning when I was looking at it. Well, good job then. Trying to add other animations with this system would probably make it overly complicated.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Mon Feb 28, 2011 6:16 am

skydereign wrote:Wow... should have realized that. It was around 6:00 in the morning when I was looking at it. Well, good job then. Trying to add other animations with this system would probably make it overly complicated.

Thanks. :D
And well, I don't know if it would be complicated or not,
but I think it's better than use million rows of code in draw actor. :wink:
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby Camper1995 » Mon Feb 28, 2011 2:22 pm

:shock: wow... really good job man! +1
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Easiest anti-moonwalk of all the time!

Postby lcl » Mon Feb 28, 2011 2:27 pm

Camper1995 wrote::shock: wow... really good job man! +1

Thanks! :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest