Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / My function wont work

Author
Message
GeeB
21
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 12th Jul 2003 20:47
I created a function to move an image around the screen using the arrowkeys. It works fine if i cut the code out of the function and put it in the main loop, but as a function it does nothing. Please someone help me.
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 12th Jul 2003 20:54
I'm guessing that the problem lies in that your variables are local variables and so get reset each time the movesquare() function is called.

Try calling new values for the variables at the beginning of your movesquare() function each time it initialises.

Cheers

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
GeeB
21
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 12th Jul 2003 21:34
Im sorry, im not sure what you mean by calling new values for the variables. Could you explain how i could fix this problem in a little more detail. I'm a little new to this language. Thanks for the help.

GeeB
21
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 12th Jul 2003 23:31
Anybody????

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 12th Jul 2003 23:58
The variables x#,y#,xvel#,yvel# are local to the function movesquare() that means each time you call this function the variables are set to zero. Use global variables instead.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
GeeB
21
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 13th Jul 2003 00:11
Thanks for the help. Thats just what i needed.

Login to post a reply

Server time is: 2024-09-20 15:27:02
Your offset time is: 2024-09-20 15:27:02