serious code problem

Game Editor comments and discussion.

serious code problem

Postby DarkParadox » Tue Jan 22, 2008 9:47 pm

heres the code:
Code: Select all
if(keyAmount.textNumber == 1 || keyAmount.textNumber > 1 && animpos == 0)
{
ChangeAnimationDirection("Event Actor", FORWARD);
keyAmount.textNumber-=1;
}


and for some wierd reason the door only opens if keyAmount's text number = 1 exactly,
can someone either fix this code or give me another code for this.
i also tryed this code but it had to equal zero to open the door is this a glitch?

Code: Select all
if(keyAmount.textNumber > 0 && animpos == 0)
{
ChangeAnimationDirection("Event Actor", FORWARD);
keyAmount.textNumber-=1;
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: serious code problem

Postby Game A Gogo » Wed Jan 23, 2008 12:35 am

this should work better:
Code: Select all
if(keyAmount.textNumber >= 1 && animpos == 0)
{
    ChangeAnimationDirection("Event Actor", FORWARD);
    keyAmount.textNumber-=1;
}


if it gives out an error, put "=>" instead of ">=" I forgot which one goes first...
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: serious code problem

Postby DarkParadox » Wed Jan 23, 2008 12:50 am

now it's messing up with the subtraction, its removing all the keys instead of 1.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: serious code problem

Postby DocRabbit » Tue Jan 29, 2008 1:40 pm

What event is your code running under? Keydown or Draw? If keydown, make sure repeat is turned off or it would subtract down multiple times even though you think you hit key once.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Re: serious code problem

Postby Game A Gogo » Tue Jan 29, 2008 4:51 pm

This problem has been solved over with the chat room. I forgot what it was, but he figured it out himself :3
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


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron