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 / If Statement Problem

Author
Message
Jimi
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 14th Sep 2003 22:23 Edited at: 14th Sep 2003 22:51
I just found DarkBASIC, and WOW!!!

I've been part of a 2d game making community called Adventure Game Studio for a while, but I really wanted to make a 3d game. I got so far with C and C++, when i found DarkBASIC, and Its great.

I've had it for 2 days, and I've started making a Crazy Golf game. The coding didn't seem to hard to understand after c++, so I learned quicky.

But I have a problem. This is part of the script:

Shoot:

rem Hit Ball
If Spacekey()=1
If speed#=0 then goto Shoot
Unglue Object 3

While speed#>0.0
Move Object 1,speed#
speed#=speed#-0.5
sleep 25

If Object Collision(1,4)=1
YRotate Object 1,360-angle#
Endif

If Object Collision(1,5)=1
YRotate Object 1,360-angle#
Endif

If Object Collision(1,6)=1
YRotate Object 1,360-angle#
Endif

Endwhile




angle# is just the angle the ball is facing, andspeed# is its speed. I also added little thing so the ball would slow down as it moved.

When it gets to the 3 IF statements where it checks for a collision with objects 4,5, and 6, it only seems to work for the first statement. If I swap them around, its still only the top one that works. Its bugging me now, and I really want to develop this game.

Cheers,
Dan
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 22:37
the "if spacekey" at the start isn`t closed anywhere, I guess this has fooled the compiler into messing up the structure so that only the first case gets checked, other than that it looks ok.

Mentor.
Jimi
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 14th Sep 2003 23:05 Edited at: 14th Sep 2003 23:14
Sorry, It seems I missed a part after the code out.

The full code is in the source thingy. It does have an endif, (I forgot to put that on there) but its doesn't work. I changed the if to a while too, but the game suddenly went VERY slow. So I changed it back.

I can't figure out what it is. I tried using Else If, but darkbasic doesn't use them.

Dan

ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 14th Sep 2003 23:07
if condition
<code>
else
<code>
endif
dark basic understands that fine


Jimi
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 14th Sep 2003 23:10
But there are 3 IF statements, not two.

Login to post a reply

Server time is: 2025-05-20 05:07:07
Your offset time is: 2025-05-20 05:07:07