Page 1 of 1

sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 1:42 pm
by sonicforvergame
well this is the game data for just the concept of sonic HD
it doesn't have much but it is basically what i made so far.
so you can first check how the game will act and also try and solve this problem
1- sonic can physically jump but no matter what id o he wont change into the jumping animation.
if you load it into game mode it will be easier for you to understand and if you can i would appreciate if you could solve the jumping animation problem

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 2:56 pm
by Hblade
Tips on programming:
Make a text variable that displays a list of your variables currently being used (This helps debug issues)

Example:
Code: Select all
sprintf(text, "Jump: %d\nYvelocity: %f", jump_variable, yvelocity);


where jump variable checks and sees if jump is activated.

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 3:38 pm
by sonicforvergame
Thanks hblade that is really nice ,now i am sure sonic jumps but he still dosent do the jumping animation when i press the jump button? Did you find out why that happens?

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 4:19 pm
by Hblade
I haven't opened the GED, just giving a bit of advice that may help :)

Make sure in draw actor nothing is changing his animation, also make sure that the collision with the ground isn't changing his animation either.

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 4:23 pm
by koala
Sonic jumps only in the beginning of the game, before you press any other button.
At the start all variables are 0, so
Code: Select all
sprintf(str,"Sonic%s%s%i",stateText[run],directText[lastdirect+1],speed/20+1);
will give "SonicStandNothing1".
That code will execute every frame, but you don't have animation with that name, so animation won't change.
Also, state = 0.
When you press "space" Sonic jumps and jump animation activates. state = 8. However, that animation continues even when Sonic touches the ground.
When you move Sonic you change variables and animation you activate every frame exists, so "there's no time" for jump animation to activate.
I suppose you need to reset all variables in order to activate jump animation.

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 5:53 pm
by sonicforvergame
well i removed all the switch state system because i am not able to use it how i should . I am not able to know when to use each state and how it works so i removed every state mechanism.
But state mechanism is really good for multiple animation and i wanted to ask if you could help me with it In PM or something
Would you mind if i PM you my questions?

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 6:00 pm
by koala
Send them, no problem. But may I ask, why PM, why not post them?

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 6:15 pm
by sonicforvergame
because i actually need help with sate and not just concept i mean how to use and how it works i think i am using it the wrong way

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 6:55 pm
by koala
sonicforvergame wrote:because i actually need help with sate and not just concept i mean how to use and how it works i think i am using it the wrong way
Good you've mentioned that. That reminded me that you forgot to put
Code: Select all
break;
at the end of every case. Unfortunately it doesn't change anything, but it is something you should do.
For example:
Code: Select all
switch (state) {
    case 1: a = 5;
    case 2: b = 6; break;
    case 3: c = 7; break;
}
If state == 1: a = 5, b = 6.
if state == 2: b = 6.
If state == 3: c = 7.

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 8:49 pm
by sonicforvergame
But what does case means? Is it the animation for instance, run-right is registered as the third animation on the players animation list. So case=3 represent the actor when doing run-right animation?

Re: sonic dosen't want to jump

PostPosted: Mon Jun 08, 2015 9:49 pm
by koala
I am not sure I understand what confuses you. :?
Let me tell you a few things about switch, which you may already know.
switch is from C language and it looks like this:
Code: Select all
switch (some_integer_variable) {
    case a: some_code; break;
    case b: some_code; break;
    case c: some_code; break;
    ...
    default: some_code; break;
}
This code has nothing to do with Game Editor, this is how C switch looks, wherever you use it and whenever you use it.
a, b, c, ... are integer values.
case a: some_code; break; means - in case that some_integer_variable has value a, do some_code.
You don't need to put break at the end of case, but then the next case will execute and so on until the first break.
default is not necessary. It will execute if value of some_integer_variable doesn't match any case.
So, switch is used for multiple choices. Which choice will be executed depends on some_integer_variable.

As I can see, you change state variable only inside switch. In the beginning it is 0 because you didn't initialize it. So case 0 will execute. One of the consequences is that state is now 1, because of code line state = 1;. switch has nothing to do with animations and their position on players animation list.

Re: sonic dosen't want to jump

PostPosted: Tue Jun 09, 2015 6:15 am
by sonicforvergame
I got it know and i managed to make the game work using the switch methode it is a really nice add to the game. thanks a lot for helping me out

Re: sonic dosen't want to jump

PostPosted: Tue Jun 09, 2015 12:12 pm
by koala
No problem. :D