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 / probably a dumb question but please help

Author
Message
cycloid gamma
23
Years of Service
User Offline
Joined: 20th Feb 2003
Location:
Posted: 30th Oct 2003 07:36
ok when you use this code

for i=1 to 10
if object collision x(1,i)>0
somevariable=1
endif
next i

this code is actually saying

if object collision x(1,1)>0
somevariable=1
endif

if object collision x(1,2)>0
somevariable=1
endif

and so on until

if object collision x(1,10)>0
somevariable=1
endif

what about when you want to use a similar kind of short cut but also
using the "or" in the code

a shortcut for something like

if object collision(1,1)>0 or object collision(1,2)>0 ......or object collision(1,10)>0
somevariable=1
endif

i have tried so hard to figure this out but maybe i just need a different point of view, please help.
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Oct 2003 07:42
from what youre asking you are doing it correctly in a loop. What is it exactly you are trying to do with the OR? I don't understand the problem. post whatever code you have and explain what it is you are trying to do - someone here will undoubtedly help you!

-RUST-
cycloid gamma
23
Years of Service
User Offline
Joined: 20th Feb 2003
Location:
Posted: 30th Oct 2003 08:08
when you use the code(for example)

for i=2 to 10
if object collision y(1,i)>0
jump=0
endif
next i

the computer reads

if object collision y(1,2)>0
jump=0
endif

if object collision y(1,3)>0
jump=0
endif

and so on

i want the computer to read

if object collision y(1,2)>0 or object collision y(1,3)>0 and so on
jump=0
endif

but in a shortcut
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 30th Oct 2003 12:07
if object collision(1,0)>0?

Will return a non-zero value if the object is colliding iwth anything, or if you just want to restrict it to objects 1-10:

if object collision(1,0) => 1 and object collision(1,0) <= 10 then...

"The trouble with the French is that they have no word for 'entreprenuer'" - Pres. George W Bush
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Oct 2003 12:30
I suggest that you assign the collision check to a variable instead of checking twice, like what David suggests, except something like:

objcol=object collision(1,0)
if objcol => 1 and objcol <= 10 then etc....

Collision checks are slow, and should be used as sparingly as possible.


Van-B

CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Oct 2003 15:51
ah ha. ok. you want to check for 1 colliding with a range of objects (ie thru 10) do what David89 says - it will return the value of the object collided with. no need for a loop or a bunch of OR's

-RUST-
cycloid gamma
23
Years of Service
User Offline
Joined: 20th Feb 2003
Location:
Posted: 30th Oct 2003 21:34
thanks everybody for the help.

Login to post a reply

Server time is: 2026-07-26 08:30:42
Your offset time is: 2026-07-26 08:30:42