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 / Multiple Objects

Author
Message
monkeyboy
19
Years of Service
User Offline
Joined: 24th Oct 2004
Location: England
Posted: 31st Oct 2004 01:40
Is there any way to make multiple objects with the same number/name and be able to place each of them in specific places instead of random?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 31st Oct 2004 02:55
no, all the objects need to have seperate numbers, just how could you position objects if they all had the same number anyway?, what are you trying to do?, you use diffrent numbers for objects and position them in different positions, you can do exactly what you like as far as positioning, scale, orientation, speed etc, a description of what you are trying to do would be helpfull.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
monkeyboy
19
Years of Service
User Offline
Joined: 24th Oct 2004
Location: England
Posted: 31st Oct 2004 03:14
making enemies. Ive got a little code that says if the bullet hits them they disappear but i dont want to have to do the collision over and over with the new enemy number so i wanted multiple with the same number in different places
zao420
21
Years of Service
User Offline
Joined: 5th Aug 2003
Location: Canada
Posted: 31st Oct 2004 03:46
you can copy an object with the clone object command

http://cavesoft.no-ip.com
WIP Version of my site. Usally it is offline.
http://dev-cavesoft.no-ip.com
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 31st Oct 2004 07:19
To detect collision with them all, use a for-next loop using the id numbers of them. That way, you just have to write one function for the collision, and it will go through it as many times as you need it to with different enemies each time. Understand?

Xander Moser - Bolt Software - Firewall
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 31st Oct 2004 20:12
Yes. For example, lets say you have 10 lasers and 20 enemies, you might check collision like this:

for i = 1 to 10

for j = 1 to 20

check_collision(i, j)

next j

next i

where the function check_collision() checks whether the specific laser number i has collided with the specific enemy number j.

However, thats a fairly inefficient method. You'd want to optimise it by putting in lots of if / endifs to remove checks where, for example, they are too far apart, etc. etc.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 31st Oct 2004 20:24 Edited at: 31st Oct 2004 20:54
just make your enemies the highest numbered objects in the game (say 10000+) then just do one check per bullet, say you have 32 bullets max active at any one time, do.....

for i=1 to 32
hit=object collision(bulletnumber,0)
if hit>10000
do_handling_of_enemys_hit()
endif
next i

easy enough, the less bullets airborn at once the better though, more checks make for slower code.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
monkeyboy
19
Years of Service
User Offline
Joined: 24th Oct 2004
Location: England
Posted: 31st Oct 2004 21:23
k thanks for the help

Login to post a reply

Server time is: 2024-09-23 04:24:48
Your offset time is: 2024-09-23 04:24:48