Jump, attack, directions?

Non-platform specific questions.

Jump, attack, directions?

Postby johnx8x » Sat Mar 05, 2011 3:33 pm

I am trying to make a game, but after trying some demos and reading topics here I am still not figuring out how to make it the way I want it.. :oops:

What I am trying to do, is creating a game where the player do the normal stuff: walk, jump, attack. I want the character to extend a sword or other weapon when attacking. I have figured out how to do the walk and jump-part, but I'm struggling with adding a proper attack for it, especially when I also want the player to be able to attack both when standing on the ground as well as being in the air. I also want the character to switch to a "falling" animation when in the air (instead of just playing a walking animation when there's no ground to walk on :wink: ). To get the "falling" part I used this code (which I found here in a topic somewhere):

Code: Select all
if(yvelocity<=-3||yvelocity>=3)
{
    if(right==1) //facing right
    {
        ChangeAnimation("Event Actor", "FALLING right", NO_CHANGE);
    }
    if(right==0) //facing left
    {
        ChangeAnimation("Event Actor", "FALLING left", NO_CHANGE);
    }
    canjump=0;
}


For the walking animations, I use codes that looks like this:

Code: Select all
char *key=GetKeyState();
if(canjump == 1)
{
if (key[KEY_LEFT]==0&&key[KEY_RIGHT]==1) ChangeAnimation("Event Actor", "WALK right", FORWARD);
else if(key[KEY_LEFT]==1&&key[KEY_RIGHT]==1) ChangeAnimation("Event Actor", "STAY right", FORWARD);\
}
right = 1;


Now I'm wondering if I've chosen the wrong way to do it since I have problems adding an attack. It seems the "falling" code is messing it up whenever the player is trying to use the attack while in the air (it doesn't work at all, or it shows the attack animation for a brief second and then switches back to the falling animation). I have no experience in creating codes, so everything I've added were from topics and demos from the forum.

Can anyone give me some suggestions on how to add an attack, or maybe another way of doing it?

Thanks for helping out a noob :mrgreen:
johnx8x
 
Posts: 10
Joined: Sat Mar 05, 2011 3:14 pm
Score: 0 Give a positive score

Re: Jump, attack, directions?

Postby schnellboot » Sat Mar 05, 2011 4:59 pm

I could make a demo for ya, but it will take a while.
Or you can give me your game and I'll fix it that won't take a day then..
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Jump, attack, directions?

Postby johnx8x » Sat Mar 05, 2011 6:39 pm

Thank you! Here's the game file, I removed the attack code because it didn't work. Controls are arrow keys for left and right, and arrow key up for jump. I was thinking of space button for attack.
Attachments
testgame.zip
(19.43 KiB) Downloaded 61 times
johnx8x
 
Posts: 10
Joined: Sat Mar 05, 2011 3:14 pm
Score: 0 Give a positive score

Re: Jump, attack, directions?

Postby schnellboot » Sat Mar 05, 2011 7:25 pm

lol it took about half an hour because I had to fix it again and again
but it should work now without any problem
Attachments
gameTest.rar
(24.25 KiB) Downloaded 54 times
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Jump, attack, directions?

Postby johnx8x » Sat Mar 05, 2011 8:55 pm

Wonderful! Works perfectly, thank you so much! :D
johnx8x
 
Posts: 10
Joined: Sat Mar 05, 2011 3:14 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest