Code archives/Graphics/Easy Collisions Example
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
An easy example of collision detection by me | |||||
AppTitle("Collisions Example") Graphics3D 800,600,32,2 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() Const entity_sphere=1 Const entity_sphere2=2 sphere=CreateSphere(32) PositionEntity sphere,-.85,0,5 sphere2=CreateSphere(32) PositionEntity sphere2,.85,0,5 EntityType sphere,entity_sphere EntityType sphere2,entity_sphere2 While Not KeyDown(1) EntityColor sphere,Rnd(255),Rnd(255),Rnd(255) MoveEntity sphere,0,.1,0 TurnEntity sphere,1,0,1 EntityColor sphere2,Rnd(255),Rnd(255),Rnd(255) MoveEntity sphere2,0,.1,0 TurnEntity sphere2,1,0,-1 Collisions entity_sphere,entity_sphere2,1,2 Collisions entity_sphere2,entity_sphere,1,2 If EntityCollided(sphere,entity_sphere2) Then RuntimeError("Collisions Detected!!!") If EntityCollided(sphere2,entity_sphere) Then RuntimeError("Collisions Detected!!!") UpdateWorld RenderWorld Flip Wend |
Comments
| ||
Very Nicely Done if I do say so myself. ;) |
| ||
Why do you insist on spamming the code archives with pointless code? |
| ||
It isn't pointless, It shows how simple it is to detect collisions. :P What's so wrong about a fellow doing some good for people struggling with collisions eh? :D |
| ||
What's so wrong about a fellow doing some good for people struggling with collisions eh? Nothing's wrong with it, but this belongs in tutorials, not in the archives. The archives should be reserved for advanced or complicated processes that simplify a technique, usually in 1 to 2 line functions. "Collisions" is a Blitz native command, and while you demonstrate its use effectively, it was not designed by you, and so this really doesn't belong in the archives. Instead, this should go in tutorials because you are showing how the Blitz system works. However, if you made your own custom Collisions system that is better or easier to use than Blitz's, the archives would be the perfect place to submit this. |
| ||
Oops! I suppose so then ^^; |
Code Archives Forum