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 / Collisions with multiple objects created with For x = 1 to 100 command

Author
Message
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 12th Jan 2005 05:32
Is there anyway to do this without typing



You get the idea
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Jan 2005 05:42
for x = 2 to 100
if object collision(1,i) = 1 then ...
next x

Or depending on what you are doing

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

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 12th Jan 2005 05:51
That doesnt work :S as i have position the objects randomly and i need then to move when my player moves into it



This is my code. I am recreating purple people eaters. A game where you push around blocks and pin in monsters.
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Jan 2005 06:52 Edited at: 12th Jan 2005 16:22
I'll test this when I get home but have you tried reasigning new values to a and b each loop?



[edit] That code I posted works but only when you are pressing the right arrow key. I kept that because it was in your code. Note however there are bugs in DBP's collision and you would be better to rotate the entire world 180 degrees on the x axis as the collision is dead on from left to right (x+ to x-) and it is exactly half the objects size of in the right to left (x- to x+) direction. So your objects will have to pretty much on top of each other to register a collision in that direction. As long as you keep moving the cube the same as the objects distance it won't be a problem though.

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 13th Jan 2005 02:56
Your code didnt work because it created a new random number so moved the block somewhere random. I need the blocks to move 1 space to the right.

You did give me an idea though.

When creating the many boxes, could i use this



The [x] is meant to be the number x so if it was on X = 10 loop then the varible would be A10 and if it was x= 89 then the warible would be A89

I can't get this to work though as it creates a varible ax not a[x]
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Jan 2005 04:42
Oh you want to actually push the object I didn't read that correctly. Probably because I was too sleepy. Try this instead. It is untested because I am at work. Remember the collision bugs I posted about as well.



Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 13th Jan 2005 06:02
My player object just moves through them with that :S
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Jan 2005 06:19
try changing the a and b variables to floats.



Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 13th Jan 2005 11:50
that works lost in thought, heres that same thing so that you can push the blocks in all directions and u dont go through them...


now u need to do collision detection from one blue cube to another so they dont stack into eachother...

NukeSoft
http://www.geocities.com/nukesoft0
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 13th Jan 2005 15:23 Edited at: 13th Jan 2005 15:25
Yeah I have a suggestion though. If you are going to have all of the cubes the same size and you are going to move the same distance each loop like that ... it would be faster to do distance checks than object collision checks I would think.

I get 530 fps with this code



vs 460 FPS with this code



Also it is better to assign object collision(2,x) to a variable as it lags each time it is called.

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 14th Jan 2005 02:47
Okay thanks a lot guys
Major Payn
20
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 14th Jan 2005 06:14
OH Xlaydos, just some quick advice from me...

Making objects with the for-next loop is the fastest way! But naming those objects things like x,b, or a, can get a bit confusing, I recommand naming them things that really sum up what they are, because you can name then whatever you want! Say your making a bunch of enemies....

for enemies=1 to 100

see! now you can make every object command easier, because the name is simple to understand, such as this object collision statement...

if object collision(enemies,bullet)>0

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.

Login to post a reply

Server time is: 2024-09-23 09:23:15
Your offset time is: 2024-09-23 09:23:15