MiniB3D Collisions Tutorial

BlitzMax Forums/BlitzMax Tutorials/MiniB3D Collisions Tutorial

Captain Wicker (crazy hillbilly)(Posted 2012) [#1]
Here is my MiniB3D Collisions Tutorial :)
Newcomers, Read carefully
Copy and paste into MaxIDE or BLIde for syntax highlighting!


'* MiniB3D Collisions Tutorial
'* By: Captain Wicker (Austin)
'* http://www.captainwicker.webs.com/
'* Credit is to be given NOT taken
'* Use as you wish :)

SuperStrict  'just what it says
Import sidesign.minib3d	 'import MiniB3D module or nothing will work
'AutoMidHandle True 	  'does nothing in this code

Const Sphere_Collision:Int = 1	'setup a constant for the sphere's collision
Const Sphere2_Collision:Int = 2	'setup a constant for the second sphere's collision

Graphics3D(640, 480, 16, 2)		'set graphics mode to 640x480 pixels with 16 bit color mode (can be changed to 24 or 32 colors) in windowed mode

Global Light:TLight = CreateLight(2)	'create light and double it's light by 2
	
Global CAMERA:TCamera = CreateCamera()	'create the camera so the objects will show themselves!

Global Sphere:TMesh = CreateSphere(24)	'create rouder 24 triangle/poly sphere
	EntityColor(Sphere, 255, 0, 0)		'color the sphere red - *(red,green,blue)*
	PositionEntity(Sphere, 2, 0, 5)		'Position the sphere in front of the camera and away from the other sphere
	EntityType(Sphere, Sphere_Collision) 'append the constant collision data to the sphere
	
Global Sphere2:TMesh = CreateSphere(24)	'create rounder 24 triangle/poly sphere
	PositionEntity(Sphere2, -2, 0, 5)	'Position second sphere in front of the camera and away from the other sphere
	EntityColor(Sphere2, 0, 0, 255)		'color the second sphere blue - *(red,green,blue)*
	EntityType(Sphere2, Sphere2_Collision) 'append the constant collision data to second sphere

While Not AppTerminate() And Not KeyHit(KEY_ESCAPE)  'run program until either the application is exited or the escape key is hit


If KeyDown(KEY_UP) Then	  'If the up key is down then \/ ('then' is not a must have)
	MoveEntity(Sphere, 0, 0, .1)	'move sphere forward 
ElseIf KeyDown(KEY_DOWN) Then		'If the down key is down then \/ ('then' is not a must have)
	MoveEntity(Sphere, 0, 0, -.1)	'move sphere backward
ElseIf KeyDown(KEY_LEFT) Then		'If the left key is down then \/ ('then' is not a must have)
	MoveEntity(Sphere, -.1, 0, 0)	'move sphere to the left
ElseIf KeyDown(KEY_RIGHT) Then		'If the right key is down then\/ ('then' is not a must have)
	MoveEntity(Sphere, .1, 0, 0)	'move sphere to the right
EndIf	'end move state 

Collisions(Sphere_Collision, Sphere2_Collision, 2, 2)  'update collisions using the ellipsoid to polygon and full sliding collision methods


UpdateWorld 'Update the scene
RenderWorld 'Draw the scene after updated

Text(260, 440, "Ball Collisions") 'Draw Text to the bottom of the screen

Flip(+ 1)	'Leave as is for SpeedSync or change to Flip(-1) for VSync (slower)
Wend 	'close program loop


Last edited 2012


simonh(Posted 2012) [#2]
That looks more like a code snippet than a tutorial...


Captain Wicker (crazy hillbilly)(Posted 2012) [#3]
:(


SystemError51(Posted 2012) [#4]
I checked the Blitz3D documentation which is also valid for MiniB3D. I couldn't find a 'Collisions' command. I'm pretty sure I didn't find one either in the MiniB3D source :-\

I rest my case.

[bbcode]Function Collisions(src_no:Int,dest_no:Int,method_no:Int,response_no:Int=0)
TGlobal.Collisions(src_no,dest_no,method_no,response_no)
End Function[/bbcode]

Last edited 2012