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 Professional Discussion / How to waste a couple of hours

Author
Message
DJ_Irritant
23
Years of Service
User Offline
Joined: 19th Jul 2003
Location:
Posted: 20th Jul 2003 01:05
I'm just getting started with DBP. As part of this I've been porting (trying to port) old starter games from DB classis like Swarm. I'm using DBPro "Lite Demo" in anticipation of buying it.

Several things don't work, but here's one that's pretty bad, and the fix.

rem Assume an array of integers in bullet #

rem This if statement will fail even if both values are the same:

if bullet#(b,4)=who

rem But reverse the order of the two terms, like so, and the comparison succeeds.

if who=bullet#(b,4)

This is fairly poor compiler behavior. Expression eval should not be position dependent in this way.

Has anyone else noticed this?
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 20th Jul 2003 01:15
it print 15 all right here

Dim bullet#(10,10)
b=6:who=15
bullet#(b,4)=15
do
if bullet#(b,4)=who
set cursor 0,0
print who
endif
loop
end
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Jul 2003 01:18
It may be down to the fact that you are comparing an integer with a float - not every integer is directly representable as a float.
DJ_Irritant
23
Years of Service
User Offline
Joined: 19th Jul 2003
Location:
Posted: 20th Jul 2003 01:31
Thanks for the fast response!

Forgot all about the fact that the array is going to force everything to float.

In this code, bullet#() was set up to hold integers in the (,1) and (,4) positions, and floating point x and y coords in the (,2) and (,3) positions. Would have been much cleaner if two parallel arrays had been used.

This is from the original Swarm code. I'm on a quest to see if I can get all those old sample programs to work under DBPro; good learning experience. Games like Iced and Room (the scorpion demo) are thoroughly hosed. This sort of thing may be a large part of the reason why.

In any event, it's a miracle the thing works at all. The (,1) position holds the integer index of the 3D object itself, and f/p inaccuracies there would have been a killer.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Jul 2003 02:42
Instead of forcing everything to floating point, why not use a type:

DJ_Irritant
23
Years of Service
User Offline
Joined: 19th Jul 2003
Location:
Posted: 20th Jul 2003 04:15
Thanks again!

If I were doing a complete rewrite, I'd certainly want to go the data structure route. Anything that brings about more OO structure is good. I don't think types were available in classic DB, certainly none of their sample projects made use of them.

Login to post a reply

Server time is: 2026-07-21 12:50:14
Your offset time is: 2026-07-21 12:50:14