Simple collision question
Blitz3D Forums/Blitz3D Beginners Area/Simple collision question
| ||
Hi, My understanding is that the "Collisions" command is required if you want to check for collisions at all in your game. The challenge is that I don't want any sort of automated response to my collisions and would rather handle it manually. Is it possible to do collision checking without initializing using the Collisions command? For example, say I were making a 3D pong game. When the ball hits the sides of the play area or the player's paddle I want to have it rebound in the opposite direction which means I don't need the automated stop / sliding collision responses. How would I go about doing this? Thanks for any help or advice :) Have a happy new year! |
| ||
There are the "pick" commands, EntityPick, LinePick, CameraPick, etc... Also you could just keep track of the x,y,z of the paddles and the ball and consider a collision when the ball's position is within a certain distance of the paddle's position. |
| ||
There have been a perpetual discussion about this "no-response-collision". It is possible, eg. this way: first create some collision types, eg: BALLTYPE=1 PADTYPE=2 ball=createsphere() entitytype ball,BALLTYPE pad=createcube() entitytype pad, PADTYPE collisions BALLTYPE,PADTYPE,2,2 ;--------------mainloop----------------- while playerdidnthitescorsomething entitytype ball, BALLTYPE entitytype pad, PADTYPE ; controls and everything usual ; move bal and pad etc., then store the new position(s) x#=entityx(ball) y#=entityy(ball) z#=entityz(ball) ; now call the collsion handler updateworld() ; now you can check for collisions, eg. EntityCollided etc. ; after using all required collision information, do this: entitytype ball, 0 positionentity ball,x,y,z ; the coords we saved before ; now use your own response code here! renderworld() flip wend |
| ||
For a Pong game, I'd just set up ball collision with a 'stop' response, and then check to see if the ball has collided with anything every frame. If it has, change it's trajectory and send it on it's way again, or whatever. :) |
| ||
how to handel 2D collsion ? I use this If ImagesCollide(sprite1,x%,y%,a%,berg1,200,200,0) but than the moving object is hanging in a tree. I thought mmm then I change the x and y -1 or +1 but that's not working because you can walk arround the tree. ;some code here wend ;some code here Collide() ;move If KeyDown(205) Then ;right x%=x%+1 a%=3 End If If KeyDown(203) Then ;left x%=x%-1 a%=9 End If If KeyDown(200) Then ;up y%=y%-1 a%=0 End If If KeyDown(208) Then ;down y%=y%+1 a%=6 End If DrawImage sprite1,x%,y%,(sprite1_frm+a%) a% = "" ;idle Flip Wend End Function Collide() If ImagesCollide(sprite1,x%,y%,a%,berg1,200,200,0) Then Text 250,250,"Now i'm stuck in a tree" ;But I want to walk again EndIf End Function |
| ||
I think he said 3D. |