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 / Move function problem

Author
Message
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 14:42 Edited at: 6th Jun 2004 14:43
Anyone can help figure out whats wrong with this function?



The direction is sorted out in a player_input function then this move function is called. But it doesnt want to move! I have a print_status function that shows that goal_x and goal_y is updated if i press an arrowkey, but it still wont move.

Direction variable:
1 = up
2 = right
3 = down
4 = left

Full source if you want to run it yourself



Thanks in advance
Mizipzor

Dreaming of creating a highly advanced AI mind
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 6th Jun 2004 19:10
I have not read the whole thing, but I can see a possible problem here...

if object position z(object)=goal_z(object) then moving(object)=0
if object position x(object)=goal_x(object) then moving(object)=0

Due to floating point errors, it possible that you may not get an exact match on position. You might want to try something like this:

if abs(object position z(object) - goal_z(object)) < .1 then moving(object)=0
if abs(object position x(object) - goal_x(object)) < .1 then moving(object)=0
--
TAZ

History did not begin with PONG. -- Greg Costikyan

Game Beavers
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 19:56
Its working now thanks...

Dreaming of creating a highly advanced AI mind

Login to post a reply

Server time is: 2024-11-26 20:17:23
Your offset time is: 2024-11-26 20:17:23