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.

DarkBASIC Discussion / Dog won't stop walking!

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 22nd Feb 2008 15:26
Well when you click the bed placeholder the dog is suppose to walk up turn around and stop at the bed, but guess what? He doesn't. I supplied the short bit of that code, so you won't have so much trouble reading it....



Thanks,
Jordan


Formerely Cool Guy Jordan
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Feb 2008 16:55
= BAD CODE BAD CODE Go Lay down!

Better code?


Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 23rd Feb 2008 15:14 Edited at: 23rd Feb 2008 15:45
I maybe stupid, but would you please explain it a bit more please.


Formerely Cool Guy Jordan
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 23rd Feb 2008 15:49
Stupid? I doubt it.

Explain More? I'm pressed for time - I want to get back to my game - but I'll try to give you a boost.

1: In DarkBasic, DBPro, and DarkGDK, DarkGDK.Net - Object Positions are "FLOAT" data types. e.g. 45.67 is valid as is 1 or 2

2: Integers are spot on numbers without decimal places where 1 or 2 is valid but 45.67 is not.

3: Floating Point Numbers are never EXACT because they are stored in a pecular manner to make those decimals Work. you Might Say:

MyFloat# = 1.5

then go to print it ( Print MyFloat# )and get: 1.4999

THEREFORE... Your Code that was looking for a SPECIFIC VALUE:

If DogX#=264.56 then (Or whatever you had)

has a VERY SLIM CHANCE of EVER happening because your dog might move from 264.5 to 264.60 - Skipping right past your DOG at BED logic.


The Code I posted Above uses the ABS or Absolute Number function. what I Did Was Take you "Dog At Bed Value" and a Fudge Number (or close enough to matter Number) and I took the DogPosition - CloseEnough which may give a positive or negative result - but does tell us how close the dog is to the bed. The ABS function converts the negative values to positive. Then I check if the dog is close enough.

go back after reading this and look at those code snips again and tell me if its getting clearer to you.

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 23rd Feb 2008 17:55
Yea it is clearer.


Formerely Cool Guy Jordan
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 2nd Mar 2008 21:22
Ok I need him to move further and for some reason he passes up the whole thing when I change acceptable fudge to less than 0.5, how do I fix that?

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Mar 2008 21:54
Ok Bro - Good Question. Well.. What I would do is put some information to help me figure out the exact values. Like Printing the Dog's x,y,z positions on the screen in your main loop and watch him walk by the bed - TAKING NOTE of the values you want him "Within" to count.

Then adjust your code to use those values:

If( DogPosX>150.4 and DogPosX<170.0) then ....

Along those lines. Does that help?

Also - You COULD do Distance checking... but the method I described - to find out the "Hot Spot" and just test if "in side the hot spot" usually takes less cpu work than distance...

Hope this helps.

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 2nd Mar 2008 22:55 Edited at: 2nd Mar 2008 23:10
Or I could just position the bed back a little.

edit: I did work!

Login to post a reply

Server time is: 2025-06-04 01:54:13
Your offset time is: 2025-06-04 01:54:13