Pirate Game

BlitzMax Forums/BlitzMax Beginners Area/Pirate Game

kantuno(Posted 2014) [#1]
I'm making a pirate game, but im having an issue with the cannon firing. I have it creating a sphere next to the ship (currently testcube), but i dont know how to get the cannonball sphere to move on its own. Also, i want it to fire from the sides of the ship, but it always goes on the x axis regardless of which way the ship is turned. Here is the code:


If MouseHit(1) Then
cannon1 = CreateSphere()
PositionEntity
cannon1,EntityX(testcube),EntityY(testcube),EntityZ(testcube)
ScaleEntity cannon1,0.3,0.3,0.3
EntityType cannon1,cannon_col
EntityColor cannon1,50,50,50
MoveEntity cannon1,-1.5,0,0
EndIf


Henri(Posted 2014) [#2]
Hello,

sounds a bit like Blitz3D. You should post there for more answers.

-Henri


PhotonTom(Posted 2014) [#3]
I'm making a pirate game, but im having an issue with the cannon firing. I have it creating a sphere next to the ship (currently testcube), but i dont know how to get the cannonball sphere to move on its own.

Not sure what your asking here

As for your second problem, it always moves in the x-axis because when you create a new sphere it is always pointing in the default direction (not the direction of the pirate ship) try using this code:

If MouseHit(1) Then
cannon1 = CreateSphere()
PositionEntity
cannon1,EntityX(testcube),EntityY(testcube),EntityZ(testcube)
RotateEntity cannon1,Entitypitch(testcube),Entityyaw(testcube),Entityroll(testcube)
ScaleEntity cannon1,0.3,0.3,0.3
EntityType cannon1,cannon_col
EntityColor cannon1,50,50,50
MoveEntity cannon1,-1.5,0,0
EndIf 


You can see that I'm setting the cannon1 to point in the same direction as your ship (testcube) by using the command RotateEntity

Also this is the bmax helping forum, this is blitz3d so I'd ask your next questions there: http://www.blitzmax.com/Community/topics.php?forum=5. Furthermore when you post code enclose it in code tags as shown here: http://www.blitzbasic.com/faq/faq_entry.php?id=2