What is a good way to anti-moon walk?

Non-platform specific questions.

What is a good way to anti-moon walk?

Postby Goomba » Tue May 01, 2012 9:54 pm

I need help again... How do you do a moonwalk i did someone's tutorial... but I found a glitch that won't let me sleep :wink: but i need help i made a game that's very hard (so don't expect ged i will make an example with another file :D ) and the platforms are like the picture shows... then when you jump and hold jump you stick to the platform... you can move but are still stuck to the platform (like in "after" picture) then when you move off the platform you go up like you just jumped!!! its so annoying!! :evil: :evil: could someone help... and like i said the game itself is extremely hard so i wont put the ged up, i will make a similar game without enemies. :)
Attachments
pacman help - Copy.png
After jump(under another platform)
pacman help.png
Before jump(under another platform)
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: What is a good way to anti-moon walk?

Postby skydereign » Tue May 01, 2012 10:09 pm

That isn't moonwalking. That is most likely caused by you not having separate collision events for the top and bottom of the ground actor. Because of that while you are colliding with the ceiling, your jump variable is set to 1 again, and you can keep jumping. If you are using collisions, you should have different collisions for the top side, bottom side, and another for the left/right side.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Hblade » Tue May 01, 2012 10:28 pm

Draw Actor: Script Editor
Code: Select all
char*key=GetKeyState();

int dir=key[KEY_RIGHT]-key[KEY_LEFT];
int lastDir;


switch(dir)
{
    case 0: //none;
    switch(lastDir)
    {
        case 0: //right
            change animation to stop right
        break;
        case 1: //left
            change animation to stop left
        break;
    }
    break;
   
    case 1: //right;
        lastDir=0;
        x+=5;
        change animation to walk right
    break;
   
    case -1: //left;
        lastDir=1;
        x-=5;
        change animation to walk left
    break;
}


There may be typos in that, I don't know, I wrote that from memory and tried a different thing.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Goomba » Wed May 02, 2012 5:02 pm

Thank you hblade and skydereign uh I didn't know what to call it, the slide stick, and hblade i read the script and as you know the default pac-man actor doesn't have any animations except for the still :D :arrow: :roll: :arrow: :lol: but will i still need ALL of the code or could i take out the animation snippets? or would it not work that way.
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Hblade » Wed May 02, 2012 5:21 pm

You can remove the animation parts :) Here's a simpler code if your not using animations
For left and right:
Code: Select all
int kDir=key[KEY_RIGHT]-key[KEY_LEFT];

switch(kDir)
{
    case 0:
    break;
   
    case 1: //right
    x+=5;
    break;

    case -1: //left
    x-=5;
    break;
}


For all 4 directions:
Code: Select all
int lrDir=key[KEY_RIGHT]-key[KEY_LEFT];
int udDir=key[KEY_UP]-key[KEY_DOWN];

switch(lrDir)
{
    case 0:
    break;
   
    case 1: //right
    x+=5;
    break;

    case -1: //left
    x-=5;
    break;
}
switch(udDir)
{
    case 0:
    break;
   
    case 1: //up
    y-=5;
    break;

    case -1: //down
    y+=5;
    break;
}


:D now you can use the arrow keys to move :)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: What is a good way to anti-moon walk?

Postby skydereign » Wed May 02, 2012 5:25 pm

Hblade wrote:You can remove the animation parts :) Here's a simpler code if your not using animations
For left and right:
Code: Select all
int kDir=key[KEY_RIGHT]-key[KEY_LEFT];

switch(kDir)
{
    case 0:
    break;
   
    case 1: //right
    x+=5;
    break;

    case -1: //left
    x-=5;
    break;
}

That is the same thing as this.
Code: Select all
char* key = GetKeyState();
x+=(key[KEY_RIGHT]-key[KEY_LEFT])*5;


Hblade wrote:For all 4 directions:
Code: Select all
int lrDir=key[KEY_RIGHT]-key[KEY_LEFT];
int udDir=key[KEY_UP]-key[KEY_DOWN];

switch(lrDir)
{
    case 0:
    break;
   
    case 1: //right
    x+=5;
    break;

    case -1: //left
    x-=5;
    break;
}
switch(udDir)
{
    case 0:
    break;
   
    case 1: //up
    y-=5;
    break;

    case -1: //down
    y+=5;
    break;
}

And that is the same as this.
Code: Select all
char* key = GetKeyState();
x+=(key[KEY_RIGHT]-key[KEY_LEFT])*5;
y+=(key[KEY_DOWN]-key[KEY_UP])*5;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Goomba » Wed May 02, 2012 5:56 pm

Thanx to the both of you this is a great help i will test it soon and maybe put the game up...(after i make it easier :D ) Thank you very much... I have a question though... which code would be better to use hblade's or skydereign's skydereign's is shorter but hblade's is probably more detailed then again i daon't know much about C so it's probably the same... :oops: oops sorry i was ranting on was I? :oops: :arrow: :lol:
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Hblade » Wed May 02, 2012 6:34 pm

Oh wow sky :D wow... I really need to start thinking outside the box xD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Goomba » Wed May 02, 2012 10:11 pm

SO are they the same? :?
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score

Re: What is a good way to anti-moon walk?

Postby skydereign » Wed May 02, 2012 11:27 pm

If that is the only code you use, yes they are the same. My version is better, as it is more concise, and doesn't use unnecessary variables. But, if you wanted to add code depending on the direction (animation changes for instance) you would have to use Hblade's. I only posted the shorter code because he was posting them with the intent that there was no animation.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Hblade » Thu May 03, 2012 2:56 am

Agreed, his code is for sure shorter, and less power-hungry
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: What is a good way to anti-moon walk?

Postby Goomba » Thu May 03, 2012 4:37 pm

Got it and thank you very much :D :D :D
Batman can't be killed - setosorcerer
he can only be neutered... - ASFJerome
User avatar
Goomba
 
Posts: 220
Joined: Wed Apr 25, 2012 2:55 am
Location: Beyond time and space...
Score: 7 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron