
The variables are:
Code: Select all
PlayerX
PlayerY
PlayerDirection
BulletX
BulletY
BulletDirectionBut not the XY position, I suck at math...
Any help would be appreciated!


Code: Select all
PlayerX
PlayerY
PlayerDirection
BulletX
BulletY
BulletDirectionCode: Select all
If InitSprite()=0 Or InitKeyboard()=0 Or InitSprite3D()=0
MessageRequester("Error","Problem Initializing DirectX")
End
EndIf
#RAD=0.0175
#Guy=0
x.f=320
y.f=240
Xg=9
Yg=-24
speed.f=0
If OpenScreen(640,480,32,"")
SetFrameRate(75)
LoadSprite(#Guy,"guy.bmp",#PB_Sprite_Texture)
CreateSprite3D(#Guy,#Guy)
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
rot-2
If rot<0:rot=359:EndIf
EndIf
If KeyboardPushed(#PB_Key_Right)
rot+2
If rot>359:rot=0:EndIf
EndIf
speed=0
If KeyboardPushed(#PB_Key_Up)
speed=2
EndIf
If KeyboardPushed(#PB_Key_Down)
speed=-2
EndIf
x-Cos((rot+90)*#RAD)*speed
y-Sin((rot+90)*#RAD)*speed
If x<0:x=0:EndIf
If x>639:x=639:EndIf
If y<0:y=0:EndIf
If y>479:y=479:EndIf
gunx=x+((Xg*Cos(rot*#RAD))-(Yg*Sin(rot*#RAD)))
guny=y+((Xg*Sin(rot*#RAD))+(Yg*Cos(rot*#RAD)))
If KeyboardPushed(#PB_Key_Space) And fire=0
fire=1
shotx=gunx
shoty=guny
shotincx=Cos((rot+90)*#RAD)*5
shotincy=Sin((rot+90)*#RAD)*5
EndIf
ClearScreen(0,0,0)
Start3D()
RotateSprite3D(#Guy,rot,0)
DisplaySprite3D(#Guy,x-32,y-32)
Stop3D()
StartDrawing(ScreenOutput())
If fire
shotx-shotincx
shoty-shotincy
If shotx>0 And shotx<639 And shoty>0 And shoty<479
Circle(shotx,shoty,5,RGB(255,0,0))
Else
fire=0
EndIf
EndIf
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
End

