Game Editor Favors Right Over Left?

Non-platform specific questions.

Game Editor Favors Right Over Left?

Postby Turon » Sun Dec 01, 2013 6:59 pm

I was trying to make the player able to run and run jump in both left and right directions.
In both Game Editor 1.4.0 and 1.4.1 It always seems to favor right over left even when the left code is practically the same thing as the right. so why? who decided this? it just new problem
I have fallen into it never used to bother me!
My gravity is "yvelocity++;"
And this is my Collision with "Ground".
Code: Select all
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 0.000000);
jump=1;


The Key up Event
And my Right Key Down
Code: Select all
if(PlayerSpeedUp==0)
{
  ChangeAnimation("Event Actor", "MaxWalkRight", NO_CHANGE);
  x+=2;
  playerdir=2;
}
if(PlayerSpeedUp==1)
{
  ChangeAnimation("Event Actor", "MaxRunRight", NO_CHANGE);
  x+=4;
  playerrundir=2;
}

And My Left Key Down
Code: Select all
if(PlayerSpeedUp==0)
{
  ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
  x-=2;
  playerdir=1;
}
if(PlayerSpeedUp==1)
{
  ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);
  x-=4;
  playerrundir=1;
}

My "X" Key Down Event
Code: Select all
if (jump == 1)
{
    yvelocity=-10;
    jump = 0;
}
if(PlayerSpeedUp==0)
{
 if(playerdir==1)ChangeAnimation("Event Actor", "MaxJumpLeft", NO_CHANGE);
 if(playerdir==2)ChangeAnimation("Event Actor", "MaxJumpRight", NO_CHANGE);
}
if(PlayerSpeedUp==1)
{
 if(playerrundir==2)ChangeAnimation("Event Actor", "MaxRunJumpRight", NO_CHANGE);
 if(playerrundir==1)ChangeAnimation("Event Actor", "MaxRunJumpLeft", NO_CHANGE);
}

My "Z" Key Down Event "PlayerSpeedUp=1;"

Now the Key Down Events.
My Left Key Down Event
Code: Select all
ChangeAnimation("Event Actor", "MaxStillLeft", NO_CHANGE);

My Right Key Down Event
Code: Select all
ChangeAnimation("Event Actor", "MaxStillRight", NO_CHANGE);

My "X" Key Down Event
Code: Select all
if(playerdir==1)ChangeAnimation("Event Actor", "MaxStillLeft", NO_CHANGE);
if(playerdir==2)ChangeAnimation("Event Actor", "MaxStillRight", NO_CHANGE);

And last but not least The "Z" Key Down Event is "PlayerSpeedUp=0;".

I dont understand my problem at all and I dont see why Game Editor would favor right over left.
if want to have a look at the working ged. Ive got it here aswell.
Attachments
Max.zip
(49.97 KiB) Downloaded 155 times
Last edited by Turon on Sat Dec 14, 2013 3:14 pm, edited 2 times in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby schnellboot » Sun Dec 01, 2013 7:06 pm

i think it has to do with your keyboard because when i play your demo it favors left
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Sun Dec 01, 2013 7:32 pm

Um so why is it favoring one direction? And how can I fix it?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby DarkParadox » Mon Dec 02, 2013 2:52 am

It favors one direction because that's how computers work. It has to check all the keys that are pressed, and computers can only do one thing at a time. Thankfully, It's not too hard to fix. What you need to do is combine your left and right keydown events into one keydown event, and use code to choose which one should be working.
Here's a little demo, there's only one event on the actor Player that has the code you'll need.
Attachments
lrdemo.ged
(1.08 KiB) Downloaded 169 times
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Mon Dec 02, 2013 12:06 pm

Kay so I am now trying to integrate your system into my game but I am running into trouble, I don't know quite whats wrong but GE is not excepting my code so um here it is.
Code: Select all
char* key = GetKeyState();
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0)
{
    x+=2;
    ChangeAnimation("Event Actor", "MaxWalkRight", NO_CHANGE);
}
   
if (key[KEY_RIGHT] == 1 && key[KEY_x] == 1)
{
    x+=4;
    ChangeAnimation("Event Actor", "MaxRunRight", NO_CHANGE);
}
else if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
    x-=2;
    ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
}
else if (key[KEY_LEFT] == 1 && key[x] == 1)
{
    x-=2;
    ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);
}
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby DarkParadox » Mon Dec 02, 2013 5:39 pm

A couple things went wrong there. You got some of your IF's and ELSE IF's confused, and "x" isn't valid, it's "KEY_x" here's a fixed code to use in place of that:
Code: Select all
char* key = GetKeyState();
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0)
{
   // IF KEY RIGHT IS PRESSED AND NOT LEFT
   if(key[KEY_x]==1) {
      // AND THEN IF X IS ALSO PRESSED
      x+=4;
       ChangeAnimation("Event Actor", "MaxRunRight", NO_CHANGE);
    }
    else
    {
       // BUT IF X ISN'T PRESSED
       x+=2;
       ChangeAnimation("Event Actor", "MaxWalkRight", NO_CHANGE);
    }
}

if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
   // IF KEY LEFT IS PRESSED AND NOT RIGHT
   if(key[KEY_x]==1) {
      // AND THEN IF X IS ALSO PRESSED
      x-=4;
       ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);
    }
    else
    {
       // BUT IF X ISN'T PRESSED
       x-=2;
       ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
    }
}

You'll be running into more problems, though. The way this code is set up, I assume the animations will mess up.

Anyways, here's a list of valid characters for "key[KEY_HERE]"
Code: Select all
KEY_BACKSPACE
KEY_TAB
KEY_CLEAR
KEY_RETURN
KEY_PAUSE
KEY_ESCAPE
KEY_SPACE
KEY_EXCL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ALT_GR
KEY_HELP
KEY_PRINT
KEY_SYSREQ
KEY_BREAK
KEY_MENU
KEY_MAC_POWER
KEY_EURO
KEY_POCKET_UP
KEY_POCKET_DOWN
KEY_POCKET_LEFT
KEY_POCKET_RIGHT
KEY_POCKET_A
KEY_POCKET_B
KEY_POCKET_C
KEY_POCKET_START
KEY_POCKET_AUX1
KEY_POCKET_AUX2
KEY_POCKET_AUX3
KEY_POCKET_AUX4
KEY_POCKET_AUX5
KEY_POCKET_AUX6
KEY_POCKET_AUX7
KEY_POCKET_AUX8
KEY_GP2X_BUTTON_UP
KEY_GP2X_BUTTON_DOWN
KEY_GP2X_BUTTON_LEFT
KEY_GP2X_BUTTON_RIGHT
KEY_GP2X_BUTTON_UPLEFT
KEY_GP2X_BUTTON_UPRIGHT
KEY_GP2X_BUTTON_DOWNLEFT
KEY_GP2X_BUTTON_DOWNRIGHT
KEY_GP2X_BUTTON_CLICK
KEY_GP2X_BUTTON_A
KEY_GP2X_BUTTON_B
KEY_GP2X_BUTTON_X
KEY_GP2X_BUTTON_Y
KEY_GP2X_BUTTON_L
KEY_GP2X_BUTTON_R
KEY_GP2X_BUTTON_START
KEY_GP2X_BUTTON_SELECT
KEY_GP2X_BUTTON_VOLUP
KEY_GP2X_BUTTON_VOLDOWN
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Fri Dec 06, 2013 6:31 pm

Thanks! but my jumping left and right is fine but running left and right and run jumping left and right is a bit of an issue. Any Idea on how to do that?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Mon Dec 09, 2013 10:04 pm

Am I being unclear?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Tue Dec 10, 2013 12:48 pm

You see at this point in time I am just trying to alow the player to walk left and walk right, jump left and jump right, run left and run right,
run jump left and run jump right. I'm trying to make the "z" key activate all the running events but the script editor is just not excepting my code.
Code: Select all
char* key = GetKeyState();
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0 && key[KEY_z] ==0)
{
    x+=2;
    ChangeAnimation("Event Actor", "MaxWalkRight", NO_CHANGE);
}
else if (key[KEY_RIGHT] == 1 && key[z] == 1 && key[KEY_LEFT] ==0)
{
    ChangeAnimation("Event Actor", "MaxRunRight", NO_CHANGE);
    x+=4;
}
else if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0 && key[z] ==0)
{
    x-=2;
    ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
}
else if (key[KEY_LEFT] == 1 && key[z] == 1 && key[KEY_RIGHT] ==0)
{
    ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);
    x-=4;
}

For now the only thing I'm trying to achieve is allowing the player to walk in both directions and jump in both directions neatly.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby DarkParadox » Tue Dec 10, 2013 6:28 pm

Like I said above, "key[z]" isn't a valid key. To use a letter key, you need to use "key[KEY_z]"
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Tue Dec 10, 2013 9:15 pm

Kay so I got the 'key[key_x]' thing but I cant jump while pressing both 'z' and key left same shlep as the one at the begining oh "!!" I just don' no wat to do!
It just wont run jump left! simple as that!
Last edited by Turon on Fri Dec 13, 2013 8:59 pm, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Wed Dec 11, 2013 6:04 pm

I have been thinking, If the problem has to do with run jumping left not running left while on the ground, Then it is more probable that we can solve the problem by looking into the actual jump code.
This is my regular jump code
Code: Select all
if(jump == 1)
{
    yvelocity=-10;
     jump = 0;
 }

And this was my attempt at solving "The Inability to Run Jump Left Problem".
Code: Select all
char* key = GetKeyState();
if (key[KEY_x] == 1 && key[KEY_RIGHT] == 1 && key[KEY_z] ==1 && key[KEY_LEFT] == 0)
{
    ChangeAnimation("Event Actor", "MaxRunJumpRight", NO_CHANGE);
   if (jump == 1)
   {
     yvelocity=-10;
     jump = 0;
   }
}
else if (key[KEY_x] == 1 && key[KEY_LEFT] == 1 && key[KEY_z] == 1 && key[KEY_RIGHT] == 0)
{
    ChangeAnimation("Event Actor", "MaxRunJumpLeft", NO_CHANGE);
   if(jump == 1)
   {
     yvelocity=-10;
     jump = 0;
   }
}
else if (key[KEY_x] == 1 && key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0 && key[KEY_z] == 0)
{
    ChangeAnimation("Event Actor", "MaxJumpRight", NO_CHANGE);
   if(jump == 1)
   {
     yvelocity=-10;
       jump = 0;
   }
}
else if (key[KEY_x] == 1 && key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0 && key[KEY_z] == 0)
{
    ChangeAnimation("Event Actor", "MaxJumpLeft", NO_CHANGE);
   if(jump == 1)
   {
       yvelocity=-10;
       jump = 0;
   }
}
else if (key[KEY_x] == 1)
{
   if(jump == 1)
   {
       yvelocity=-10;
       jump = 0;
   }
}

Bare in mind I haven't fixed the problem yet.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Fri Dec 13, 2013 6:53 pm

Oh are you confused? it may be hmm Ive got a diagram of the completed movement system just to help you understand better what I'm trying do.
Image
It shows what buttons are being pressed for one of the action.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Sun Dec 15, 2013 9:41 pm

One Question, the reason I cant run-jump left is because my computer favors the right while pressing 3 keys? If it took only 2 keys then I would be able to run-jump left?
I need to minimize it down to just 2 keys, Now how do you suppose we'll do that? well I was thinking that if you pressed down the the left or right keys for a few seconds
it will Make the player Accelerate!
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right Over Left?

Postby Turon » Mon Dec 16, 2013 12:17 pm

This is my experimental Acceleration Demo the good thing is that when I hit max Speed the animation will change to running. The downsides are that its all very slippery and it doesn't work well with gravity.
But please! Enough with the silent treatment! If you don't understand something just ask!



Edit
Case closed! Because my topic has changed I should make a new topic!


(Download removed now in "Acceleration Problem Topic")
Last edited by Turon on Wed Dec 18, 2013 12:22 pm, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest