help on code, whats wrong with it?

Game Editor comments and discussion.

help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 1:40 pm

Hello, i need help on this code and i don't know how to fix it but i just can't do it :cry:

Code: Select all
char *key = GetKeyState();
if(key[KEY_LEFT] == 1)
{
if(switchdiretion==1)
{
    ChangeAnimation("Event Actor", "right-to-left", FORWARD);
    switchdiretion=-1;
    anifinishright=0;
}
if(anifinishright==1)
{
x = x - 2;
}
}
if(key[KEY_RIGHT] == 1)
{
if(switchdiretion==-1)
{
    ChangeAnimation("Event Actor", "left-to-right", FORWARD);
    switchdiretion=1;
    anifinishleft=0;
}
if(anifinishleft==1)
{
x = x + 2;
}
}



User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:13 pm

come on, please help me :cry:
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Sat Dec 15, 2007 2:15 pm

Why you dont use KeyDownEvent???I'm not tried it yet
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:19 pm

no, but should i?
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:24 pm

everything is working exept for the fact that he's not moving left or right
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Sat Dec 15, 2007 2:26 pm

just try it with Keydown event...there're many ways to do something, just try it one by one and choose the best one :D
Ummm...have you added
Code: Select all
x=x-3;

in keydown LEFT, and
Code: Select all
x=x+3;

in keydown RIGHT
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:29 pm

i put x = x +2;
but does it make that much of a diffrence
'
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Sat Dec 15, 2007 2:32 pm

I think not... :D
Btw, make sure if that keydown event to move, which have x=x-2; inside is repeated :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:35 pm

i did i just not working either
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby DarkParadox » Sat Dec 15, 2007 2:40 pm

Wait i found my error and fixed it
thank for trying to help, +1 point
for your troubles :D :D
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Sat Dec 15, 2007 2:45 pm

I dont think if made troubles...
KeyDown>Left>ScriptEditor>
Code: Select all
x=x-3;

KeyDown>Right>ScriptEditor>
Code: Select all
x=x+3;

It should work fine :wink:
Btw, I'm not attracted with score... :roll:
THANKS anyway :oops:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: help on code, whats wrong with it?

Postby Game A Gogo » Sun Dec 16, 2007 12:21 am

Make sure that "anifinishright" or "anifinishleft" are equal to one when pressing the keys, try to change it so it checks if the value is 0 instead, you could do trouble shooting from there
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Sun Dec 16, 2007 6:39 am

nice analysis :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: help on code, whats wrong with it?

Postby Game A Gogo » Mon Dec 17, 2007 12:34 am

I use that technique a lot
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: help on code, whats wrong with it?

Postby Bee-Ant » Mon Dec 17, 2007 4:58 am

Yeah I see...because you're senior here :roll:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron