I like to use function in my program as well as types, but i am getting a problem when trying to create collisions.
I put the Collisions command directly before my game loop, and i then in my game loop create objects when a certain action happens.
Now collisions will work when that code is inserted direcly in the main game loop like above. But here is the problem. If i get that same exact code and put it into a functin like below, it will never create a collision.
Is there a way to get around this problem in blitz3D? I know you can use arrays, but arrays do not offer the same power as types do. When i created a 2d game i had no poblem with testing collisions from space ship that were creating ouside of the main game loop in a function. I know that Blitz3D is different, but is there any command that will allow me still have collisions even if the type is instantiated out side of the main loop?
I put the Collisions command directly before my game loop, and i then in my game loop create objects when a certain action happens.
While Not Keydown(1) ; If MouseHit(1) Then Select g_currentweapon Case "pistol" pistol.weapontype = New weapontype ;create a new projectile and add it to type_projectile pistol\projectile = CreateSphere() EntityRadius pistol\projectile, .01 ;make the sphere smaller like a bullet ScaleEntity pistol\projectile, .02, .02, .02 PositionEntity pistol\projectile, EntityX(camera), EntityY(camera), EntityZ(camera) TurnEntity pistol\projectile, EntityPitch(camera), EntityYaw(camera), EntityRoll(camera) pistol\name$ = "pistol" EntityType pistol\projectile, type_projectile End Select End If UpdateWorld() RenderWorld() Flip Next
Now collisions will work when that code is inserted direcly in the main game loop like above. But here is the problem. If i get that same exact code and put it into a functin like below, it will never create a collision.
While Not Keydown(1) ; ;Here i just replaced the code above with this function TestInput() UpdateWorld() RenderWorld() Flip Next Function TestInput() If MouseHit(1) Then Select g_currentweapon Case "pistol" pistol.weapontype = New weapontype ;create a new projectile and add it to type_projectile pistol\projectile = CreateSphere() EntityRadius pistol\projectile, .01 ;make the sphere smaller like a bullet ScaleEntity pistol\projectile, .02, .02, .02 PositionEntity pistol\projectile, EntityX(camera), EntityY(camera), EntityZ(camera) TurnEntity pistol\projectile, EntityPitch(camera), EntityYaw(camera), EntityRoll(camera) pistol\name$ = "pistol" EntityType pistol\projectile, type_projectile End Select End If End if End Function
Is there a way to get around this problem in blitz3D? I know you can use arrays, but arrays do not offer the same power as types do. When i created a 2d game i had no poblem with testing collisions from space ship that were creating ouside of the main game loop in a function. I know that Blitz3D is different, but is there any command that will allow me still have collisions even if the type is instantiated out side of the main loop?