controller help!

Blitz3D Forums/Blitz3D Beginners Area/controller help!

blade007(Posted 2007) [#1]
For some reason the game seems to completly ignore the function. Some 1 help plz
graphics 800,600,32,2
Global controller
global x
global y
global frame
print"select controller device"
Print"0 = mouse"
Print"1 = joystick"
Print"2 = keyboard"
.ask_for_controller
controller = input("")
if controller > 2 or controller < 0 then goto ask_for_controller
while not keydown(1)
   controller_control()
      plot x,y
      flip
     cls
wend
Function controller_control()
	Select controller
		Case 0
				If MouseX() > x Then
					x = x + speed
					frame = Rand(0,5)
				EndIf			
				If MouseX() < x Then
					x = x - speed
					frame = Rand(0,5)
				EndIf
				If MouseY() > y Then
					y = y + speed
					frame = Rand(0,5)
				EndIf
				If MouseY() < y Then
					y = y - speed
					frame = Rand(0,5)
				EndIf
		Case 1
				If JoyX() >  0.5 Then
					x = x + speed
					frame = Rand(0,5)
				EndIf			
				If JoyX() < -0.5 Then
					x = x - speed
					frame = Rand(0,5)
				EndIf
				If JoyY() >  0.5 Then
					y = y + speed
					frame = Rand(0,5)
				EndIf
				If JoyY() < -0.5 Then
					y = y - speed
					frame = Rand(0,5)
				EndIf

		Case 2
				If KeyDown(200)
					y = y - speed
					frame = Rand(0,5)
				EndIf
				
				If KeyDown(208)
					y = y + speed
					frame = Rand(0,5)
				EndIf
				
				If KeyDown(205)
					x = x + speed
					frame = Rand(0,5)
				EndIf
				
				If KeyDown(203)
					x = x - speed
					frame = Rand(0,5)
				EndIf
	End Select
End Function



Stevie G(Posted 2007) [#2]
You haven't declared the variable speed as global.

global Speed = 1

This works.


blade007(Posted 2007) [#3]
ohhh thanks.( that was dumb)


blade007(Posted 2007) [#4]
ps is there a way to declare all variables as global?


chwaga(Posted 2007) [#5]
have to do it one by one, but you can do:

Global bob, sue, suesie, fred, jill

instead of
Global bob
Global sue
Global suesie
Global fred
Global jill