keyboard controls for a gun ship

Blitz3D Forums/Blitz3D Beginners Area/keyboard controls for a gun ship

Hi,

I was just wondering if anybody can give any advice or
perhaps maybe a small fragment of code showing how
to setup the keybord arrow keys to control a gunship that moves up & down and yet allow you to shoot at the same time that you're moving your gunship up & down.

Example:

; ------------------
;  Frenzy Game
; ------------------

Graphics3D 640,480 : SetBuffer BackBuffer()

Global x#=0, y#=0, z#=14, fx#=0, fy#=0, cn#=0.0, fire_on_off=0, fire_left=0, fire_right=0
Global gun, green_jewel, blue_jewel, red_jewel, background

camera = CreateCamera() : light = CreateLight()

gun = LoadMesh ("media\gun2.x")
RotateEntity gun, -90, 0, 0
PositionEntity gun, 0,-14,12
ScaleEntity gun, 1.5,.2,02.2

green_jewel = LoadMesh ("media\gg.x")
RotateEntity green_jewel, -180, 0, 0
PositionEntity green_jewel, 11.0,8.4,12.0
ScaleEntity green_jewel, .7,.7,1

blue_jewel = LoadMesh ("media\bg.x")
RotateEntity blue_jewel, -180, 0, 0
PositionEntity blue_jewel, -.1,4,12
ScaleEntity blue_jewel, 1.5,1.5,1

red_jewel = LoadMesh ("media\rg.x")
RotateEntity red_jewel, -180, 0, 0
PositionEntity red_jewel, -.1,2,12
ScaleEntity red_jewel, .7,.7,1

background = CreateCube()
PositionEntity background, 0,0,20
ScaleEntity background, 20,15,.01
background_tex = LoadTexture("media\bg1.bmp")
EntityTexture background,background_tex



While Not KeyDown( 1 )

		;Copy gun positions into 'Fire' Coordinates
		fx# = x# : fy# = y#

	Controls() : Move_Gun() : Render_Screen()

Wend


; =====================
; ==	Functions    ==
; =====================


Function Controls()

		If KeyDown(200)=True And y#<9.0 Then y#=y#+0.2
						
		If KeyDown(208)=True And y#>-9.0 Then y#=y#-0.2
					
		If KeyDown(203)=True Then Fire_Jewel_Left()
			
		If KeyDown(205)=True Then Fire_Jewel_Right()
								
End Function

Function Fire_Jewel_Left()
			
	For i=0 To -13 Step -1
		PositionEntity blue_jewel, i, y#, z#
		RenderWorld
		Text 0,60, "fx Position: "+i : Flip
		For t=0 To 10000000 : Next
	Next
						 
End Function

Function Fire_Jewel_Right()

	For i=0 To 13
		PositionEntity blue_jewel, i, y#, z#
		RenderWorld
		Text 0,60, "fx Position: "+i : Flip
		For t=0 To 10000000 : Next
	Next

End Function

Function Move_Gun()

	PositionEntity gun, x#, y#, z#
	PositionEntity blue_jewel, x#, y#, z#
		
End Function

Function Render_Screen()

	RenderWorld
	Text 0,20, "Y Position: "+y#
	Text 0,40, "X Position: "+x#
	Flip
	
End Function


Any Help would be very much appreciated, Thank's guys!


jackzip7