This is just for a simple question, then please, errese this

Game Editor comments and discussion.

This is just for a simple question, then please, errese this

Postby Wayra Condor » Wed Mar 19, 2008 9:59 pm

I just make this to ask makslane a litle problem I got with "if"s (yea, again...)
example.zip
A bomberman with only 2 directions
(11.03 KiB) Downloaded 105 times

game glitch.zip
The cause of my nightmares on GE
(81.08 KiB) Downloaded 119 times

I know I had the same trouble maybe 5 posts ago, but I'm sure makslane will find the problem, if is the codes, my computer, or... a GE glitch.
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Wed Mar 19, 2008 10:48 pm

I think the problem is too many conditionals. You've made it too complicated with all the tests.

Let me try to fix it if someone doesn't do it before me.

Here is the fixed version.
bomberman.zip
wayra's bomberman animation fixed
(11.01 KiB) Downloaded 123 times


I solved two problems
  • Move the actor in the right direction when a key is pressed.
  • Make the actor stop and stand facing in the right direction when a key is let up.

To solve the first problem, when a key down even occurs I allow repeat and move the actor in the correct direction. We also change the animation, but we don't want to always change the animation. So, I created a global flag (MOVE_UP, MOVE_DOWN, etc) and a variable to hold the current direction (MoveDirection). If the MoveDirection value is not the right one, we change the animation and then reset the MoveDirection to the correct flag value.

The second problem is solved similarly. When the key up event occurs, we reset the flag and change the animation to the right one.

I hope this helps. You were using the if's correctly, you just needed to think about the problem a little more.
Last edited by edh on Wed Mar 19, 2008 11:50 pm, edited 1 time in total.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby stevenp » Wed Mar 19, 2008 11:41 pm

beware the "repeat while key down" function can be a deadly one

your animation was being repeated because of it, and that ignored your 6 FPS

i separated your code into 2 parts, key down repeat, and NOT key down repeat,

then i had a new problem, since you can walk diagonaly, a key up event made your character face that direction even if he was walking the other way,

so i created a variable, "stop animation direction if no keys are pressed",

another benifit of this is if you pres keys in sequence, ( like left, then right, he will face the direction in that order) the last directional key gains priority
Attachments
problem solved.zip
(16.73 KiB) Downloaded 112 times
Last edited by stevenp on Wed Mar 19, 2008 11:57 pm, edited 1 time in total.
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Wed Mar 19, 2008 11:56 pm

Nice catch on the diagonals, Mojo.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby stevenp » Thu Mar 20, 2008 12:02 am

thanks :)
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

And the other?

Postby Wayra Condor » Thu Mar 20, 2008 2:55 am

Thanks guys, I'm sending 1 point for you both, but...
How about the second one, makslane still don't answer, and I'm having this problem since I got GE, I know edh tried to solve it by a "count" method, but I couldn't put it at the moving player so I tried using variabels again, can you chack the game please? :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby stevenp » Thu Mar 20, 2008 4:00 am

wheres the post?
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Thu Mar 20, 2008 10:37 am

Wayra, I changed your if...else to a switch statement and put the WayraCondor_ma in the keydown event.

When your player does the action is when you want to change the text, not in the if..else conditional block.

Check it out...
koperu.zip
wayra's king of peru, mortal combat text
(81.28 KiB) Downloaded 109 times
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby Wayra Condor » Thu Mar 20, 2008 4:58 pm

Yup, it works!
But again I got the problem to make the text have inerence on the player.
Here is the same file with an actor, what I try ti find is how to change his state using the text, this is the idea:
If "rumi maki" is active, then the actor should move up
If "cholitzu" is active, then the actor should move down
And if the other text is active, then the actor should move right.
Test of actions using the text.zip
Try testing with the actor
(85.02 KiB) Downloaded 111 times

By the way mojo, I made my post in support section, there you will see that edh tried to solve it, but I couldn't get inerence on a player.
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Thu Mar 20, 2008 5:17 pm

I really don't think you want to control the actions with the variables like this. You would be better off to start with the bomberman example and add the text event to that, instead of using the text to control your actor.

For example, if your actor moves right, or kicks or whatever, then you want to change the text.

I'll rework it and send it back...
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Sat Mar 22, 2008 11:50 am

Here is a version of bomberman that changes the text to the direction that bomberman is going. It only changes if the action changes.

I created two global functions that should help you with your own king of peru. The text effect is separated from the action behavior (like moving or doing a mortal combat action) to make it easier to read, and code.

Hope this helps, good luck with KoP!

bomberman.zip
bomberman with mortal kombat style action text
(91.36 KiB) Downloaded 117 times
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby Wayra Condor » Sun Mar 23, 2008 3:05 am

...
Well, it help a bit, but I see you don't understand what I try to do.
Have you ever played a Mortal Kombat game? Well on the lastest ones the characters used a martial arts system, this system consist on this:

A "x" player have the following moves (imagine those letters are the control):

A: normal punch
B: high puch
X: double punch
Y: low kick

But, if you change the martial art, the moves changes (the stance and pictures too):

A: high kick
B: low kick
X: high punch
Y: throw

So, the idea is that the text is only an indicator of what will happen if I press that key.
The demo I made was just for an example, so starting by that I'll see how to make this work.
In the game which I'm making, each player has two martial arts and one weapon (similar to the mortal kombat system), there will be used 4 keys to attack, plus the ones that need to be pressed together with an arrow key, there are maximium 20 different attack per martial art (or weapon), in total a maximiun of 60 attack per player (making it a very hard game to cordinate); so thats how it works.
What I tried to do was use a variable that depending on the martial art that shows the text, the player must perform certain attack, the problem is I don't know very well how do variables work, and I can't perform 3 martial arts (with weapon included) because there can only be 1 "if" and 1 "else if" in the same code, in other words, all got harder that I thought.

Thats what I tried to do, someone please tell me how, beacause I'm still learning the basics of C language, and is really hard to make cordinate this system.

Thank you for giving me support edh, if I solve this I hope to be sending a preview of the game in some time. :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: This is just for a simple question, then please, errese this

Postby edh » Sun Mar 23, 2008 10:45 am

Wayra, I understand what you are trying to do. I have given you everything you need to accomplish what you want. But I also understand that it can be hard to make the leap from an simple example to a complicated full game.

Try something small first. Only work on the kicks. Once it works, add punches or something.

If you notice, in the bomberman, the key press that changes the text is only movement but it could have been B+Left Button on the GP2X. Or A+B or whatever you need. The key down event is when you are going to call changeActionText. If you have 60 action flags, it will still work. The code is all ready for you to reuse and replace the action text with whatever you want.

First, you can have as many if...else if in the same code as you want.

Code: Select all
if (a == 1)
{

} else if (a == 2)
{

} else if (a == 3)
{

} else if ( )
... on and on


Second, if you have a ton of if ... else, change them to a switch statement

Code: Select all
switch (a)
{
   case 1:
         // do something
         break; // stop here for case 1
   case 2:
         // do something else
         break; // stop here for case 2
   case 3:
         // do something for case 3
         break; // stop case 3
   case .... on and on
}


This is much easier to read.

Third, understand how if else works. If you write this code
Code: Select all
if (a == 1)
{
   // do a == 1 stuff
} else if (a == 2)
{
  // do a == 2 stuff
} else if (a == 3)
{
   // a == 3
}
// etc


It is the same as
Code: Select all
if (a == 1)
{
   // a == 1
}
else
{
    // a != 1
    if (a == 2)
    {
        // a == 2
    }
    else
    {
        // a != 1 and a != 2
        if (a == 3)
        {
            // a== 3
        }
       else
       {
           // a != 1 and a != 2 and a != 3
       }
    }
}



You will only ever get into the the third else if a != 1 and a != 2 and a != 3.

Also, you need to know where your flags and variables are set. This means you need to understand how the events occur in GE. I put all the code that changes things in events like draw actor, out of vision, etc. But I also made functions to hold the complicated stuff and just called those from the events. When the key down or key up events occur, that is when the variables change. The rest executes as a result of the event. GE is event driven.

I think that just understanding this stuff will help, and King of Peru will be available soon. :D
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron