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 / Simple question, please help

Author
Message
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 03:31
I've gone a bit simple and can't remember how to do something that should be easy. I'm using the static line of sight command and can get it to return a value of 1 for true and 0 for false, I can get so that if it is true it prints on the screen, my problem is I can't get it to print something on the screen if it returns a value of 0 which means it can't see anything within its line of sight. All I need is for it to say "I can see you" when the return value is 1(Which I can do) and "I can't see you" when the return value is 0(which I am having trouble with). Please help.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 04:44
Also, I want to know how to say which object(object number) is in the line of sight, eg "I can see you object 203"
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 06:19
are you putting the result into a variable? Like

blocked=static line of sight([,,,,])
Text 0,0,"Blocked="+str$(blocked)

Besides, you won't be able to tell which object is blocking the line because static objects lose their individuality when they become static, and are no longer referenced by number, unless you're using the 'attach/detach object to/from static' commands, so you have a bit of a catch22 here

Better would be to find a line of sight function someones written which you can use on regular objects

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 06:44
Thanks, I should have guessed that by the way static boxes don't have an object number
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 06:50
Is there any way I can say what static box number I'm looking at??
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 07:05
You'll have to define coordinates for the box to make it in the first place, so store those coordinates into an array or memblock as you do. Now do a math check to see if a line projected from the pov towards an object intersects the box area of those coordinates

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 07:10
OK, all the static boxes are associated with boxes randomly positioned around a matrix, I guess I'll have to put some structure into where I place my boxes, Thanks Again
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 07:22 Edited at: 20th Apr 2003 07:23
O.K. You must be creating the boxes and spreading them around randomly, so at this point they still have object numbers. You get the object positions as you make them (I'm assuming inside a for/next loop) Then take an offset from this point to define the static collision box after you've 'make static object whatever' so you store the same numbers/variables you used to define the static collision boxes into an array at the same time, an array like:
staticboxes#([number of boxes],[coordinates to store])

Then it doesn't matter if you're placing them randomly see?

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 08:01
Sorry, Im not to familiar with arrays. This is the code I originally used to make my boxes and static boxes.
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 10:16 Edited at: 20th Apr 2003 10:17
Ack!, try the one below

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 10:17 Edited at: 20th Apr 2003 10:50
Ok that's fine, but I suggest you learn about arrays, they're not that hard to use, think of an array as a filing cabinet for variables.
each drawer in the cabinet has any number of containers in it, for now that's all we need.

So an array can be

dim testarray(1)
that has 2 'drawers', numbered 0 and 1
dim testarray(1,5)
this one has 2 drawers, each with 6 tupperware containers in it.

So if you think about it, you can make an array where the 1st dimension is the drawer which holds 3 coordinates in a tupperware container(second dimension)

We need 230 drawers because that's how many boxes you're making.
Inside each drawer we have a container with the coordinate variables for each box in it.

So add to your code:

dim collision_boxes#(230,2)

for i = 20 to 250
make object cube i,50
position object i,rnd(5000),25,rnd(5000)
x#=object position x(i)
y#=25
z#=object position z(i)
MAKE STATIC COLLISION BOX x#-25,y#-25,z#-25,x#+25,y#+25,z#+25
`our array starts at 0, but the boxes start at 20, so:
box=i-20
`now we store the coordinates into our array. We only need the `positions as the `boxes are all the same size:
collision_boxes#(box,0)=x#
collision_boxes#(box,1)=y#
collision_boxes#(box,2)=z#
`make the box static and delete the object
make static object i
delete object i
next i

Now whenever you need to extract the info for where the boxes are:
(you can consider the collision boxes as numbered from 0 to 230)

for collision_box=0 to 230
x#=collision_boxes#(collision_box,0)
y#=collision_boxes#(collision_box,1)
z#=collision_boxes#(collision_box,2)
`now do the calculations based on the offsets (+/-25) from these `variables
`for each collision_box you want to check
next collision_box

I also realized you didn't quite understand how the static objects work, you can delete the object after you make it static, otherwise there's not really much point to using the static collision box

Hope that's not too complex

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 10:40 Edited at: 20th Apr 2003 10:45
Here's an example of how you could use that stuff (god I'm bored, hope you appreciate this!)

It's in the source code box
[edit]
Oh yeah, press the space key to see the collision boxes get a number, effectively allowing you to number a static object

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 10:46 Edited at: 20th Apr 2003 10:58
Great, I cant get it going in DBPro. If anyone can convert it so that Pro doesnt say that object 20 already exists that would be great.

Yes, I do appreciate this, it is a shame you dont have DBPro though, luckly I have both, Thanks again.
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 11:53
I don't see why, check each command, starting with the arrays and see if the syntax is different in pro, or if static objects are handled differently. Perhaps it's only something very simple which needs to change.

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 12:34
Theres at least one command that is not longer used in DBPro, "Make static object NUM", but its mainly the line that makes the plain for the number of the box, no matter what I put it says it already exists, Ive tried returning the po value out of the function so it can only be used once but it didnt work and removing the spacekey bit, but as its in the loop it keeps trying to make the same object.Ive tried allowing space to only be pressed once, but the numbers flash up quickly and a cant press space again.
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 20th Apr 2003 13:50 Edited at: 20th Apr 2003 13:52
Well maybe put this just before the main loop and replace the function with the one in the source box

What is the new command for making a static object in pro?

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 20th Apr 2003 14:41
Perfect, you are awesome, thanks
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 21st Apr 2003 03:18 Edited at: 21st Apr 2003 03:48
Now I know which object box is associated with its own Static Box.If I use the Static Line of Sight command how can I return the box number so that I know which box Im looking at, can this be done??


I got it saying which object numbers they are and they are not the same as the static box number function, they are quite different
Danmatsuma
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 21st Apr 2003 10:43
Yeah well I got you started, but the thing is you'll not nessecarily use the static line of sight command.
Look about on the code snippets board for a line of sight command that is maths based, and you can read coordinates into that from the arrays we set up.
Line of sight is basically about projecting a line from one point to another, and all you have to do from there is find out if your line intersects the coordinates in the array. If you know your trig this shouldn't be too hard. I'll be working on something like this tomorrow or the next day so if you haven't found something by then I'll post what I work out

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
ibbi
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location:
Posted: 26th Apr 2003 10:46
can any one tell me how to make more monsters and more levels please,and please stick to coding according to the game that is in the darkbasic tutorial.please do try to email meIBRAHIMIbbi@aol.com

Login to post a reply

Server time is: 2024-11-24 12:50:17
Your offset time is: 2024-11-24 12:50:17