RotateSprite3D(1, ShipAngle, 0)
Ok I tried this method out however either my starting angle is off (set to 270 by default as i assume east is 0) or my angle is not calculating correctly. Below is the full source try out and possibly explain visually more of what I'm working with: (Use any 2 .png files for missle.png and blobship_1-1.png )
Code: Select all
InitKeyboard() : InitSprite() : InitSound() : InitMouse() : InitSprite3D()
;Bomb Struct
Structure Bomb
X.F
Y.F
TX.F
TY.F
SpeedY.L
SpeedX.L
SpriteNum.L
Delay.L
T.F
EndStructure
Dim MyFriends.Bomb(200)
win_id1 = OpenWindow(#PB_Any,#PB_Default,#PB_Default,1280,768,"Bomb Dodge",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(win_id1),0,0,1280,768,0,0,0)
UsePNGImageDecoder()
LoadSprite(1, "images\blobship_1-1.png",#PB_Sprite_Texture)
TransparentSpriteColor(1, RGB(4,4,4))
CreateSprite3D(1, 1)
;Reset Game
begin:
;Variables
Health = 100
Points = 0
Release = 0
ReleaseCounter = 0
Test = 0
Pause = 0
PosX = 640
PosY = 700
ShipSpeed = 7
ShipAngle.F = 270
;LoadSound(1, "Sounds\Music.wav")
;PlaySound(1)
For a = 2 To 200
result = LoadSprite(a, "images\missle.png")
MyFriends(a)\X = Random(1000) + 1
MyFriends(a)\Y = - Random(50) + -1000
MyFriends(a)\TX = 0
MyFriends(a)\TY = 0
MyFriends(a)\SpeedY = 3
MyFriends(a)\SpeedX = 3
MyFriends(a)\Delay = 0
MyFriends(a)\SpriteNum = a
MyFriends(a)\T = 0
TransparentSpriteColor(a, RGB(4,4,4))
Next
CreateImage(0, 300, 200)
Repeat
event = WaitWindowEvent()
ExamineMouse()
ExamineKeyboard()
;Pause
If KeyboardReleased(#PB_Key_P)
Pause = Pause ! 1
EndIf
;Controls
If KeyboardPushed(#PB_Key_Up)
radians.d = ShipAngle*#PI/180
PosX = PosX + ShipSpeed *Cos(radians)
PosY = PosY + ShipSpeed *Sin(radians)
EndIf
If KeyboardPushed(#PB_Key_Down)
PosY + ShipSpeed
EndIf
If KeyboardPushed(#PB_Key_Left)
If ShipAngle < 0
ShipAngle = 360 - ShipAngle
Else
ShipAngle - 7
EndIf
RotateSprite3D(1, ShipAngle, 0)
EndIf
If KeyboardPushed(#PB_Key_Right)
If ShipAngle > 360
ShipAngle = ShipAngle - 360
Else
ShipAngle + 7
EndIf
RotateSprite3D(1, ShipAngle, 0)
EndIf
Debug ShipAngle
;Check for Pause
If Pause = 0
ClearScreen(RGB(0,0,0))
ReleaseCounter + 1
;Delay Release of Bomb
If ReleaseCounter = 45
release = Random(200)
If release >= 2
MyFriends(release)\Delay = 1
EndIf
ReleaseCounter = 0
EndIf
;If Bomb Delay is Set Non Active Release
For c = 2 To 200
If MyFriends(c)\Delay = 1
Corner = Random(2)
If MyFriends(c)\Y < -20 And MyFriends(c)\Y > -40
Select Corner
Case 1
MyFriends(c)\Y = 0
MyFriends(c)\X = 0
MyFriends(c)\SpeedX = 3
MyFriends(c)\TX = PosX
MyFriends(c)\TY = PosY
Case 2
MyFriends(c)\Y = 0
MyFriends(c)\X = 1280
MyFriends(c)\SpeedX = 3
MyFriends(c)\TX = PosX
MyFriends(c)\TY = PosY
EndSelect
EndIf
EndIf
Next
;Points Generator
Points + 1
;Calculate Path of bombs to current position
For x = 2 To 200
If MyFriends(x)\Delay = 1
MyFriends(x)\T + 0.0001
MyFriends(x)\X = MyFriends(x)\X + (MyFriends(x)\TX - MyFriends(x)\X) * MyFriends(x)\T
MyFriends(x)\Y = MyFriends(x)\Y + (MyFriends(x)\TY - MyFriends(x)\Y) * MyFriends(x)\T
;Ship Collision with bombs
If SpriteCollision(1, PosX, PosY, x, MyFriends(x)\X, MyFriends(x)\Y)
Health - 1
MyFriends(x)\Delay = 0
MyFriends(x)\Y = -50
MyFriends(x)\X = 100
MyFriends(x)\T = 0
EndIf
EndIf
Next
;Display Active Bombs
For a = 2 To 200
If MyFriends(a)\Delay = 1
DisplayTransparentSprite(a ,MyFriends(a)\X , MyFriends(a)\Y)
EndIf
Next
;If health is 0 restart
If Health < 0
Goto begin
EndIf
Start3D()
DisplaySprite3D(1, PosX, PosY)
Stop3D()
If StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
BackColor(RGB(0,155,155))
FrontColor(RGB(255,255,255))
DrawText(5, 5,"Health: " + Str(Health))
DrawText(5, 20,"Points: " + Str(Points))
StopDrawing()
EndIf
EndIf
FlipBuffers(2)
Until KeyboardPushed(#PB_Key_Escape) Or event = #PB_Event_CloseWindow
End
Sorry about the extra types on my variables, I was previously informed it was the correct way. I think I was able to remove the majority from my code. Thanks again for taking the time to give me a hand with getting this ship to move the way its facing.