| Input keydown functions 
 
	 
	
		| Author | Message |   
		| Regole 
 
 
 
 
 | 
			
				|  Posted: Fri Jan 09, 2004 1:15 pm    Post subject: Input keydown functions |  |   
				| 
 |  
				| we are all familiar with the popular code for recieving input from the keyboard: 
 	  | code: |  	  | 
setscreen ("offscreenonly")
 var chars : array char of boolean
 var x, y, x1, y1,col, w1 : int
 w1 := Window.Open ("title:Game test 01,graphics:1024,768,position:0,0")
 x := 500
 y := 500
 x1:=5
 y1:=5
 col:=16
 loop
 Input.KeyDown (chars)
 if chars (KEY_UP_ARROW) then
 y := y + 3
 elsif chars (KEY_RIGHT_ARROW) then
 x := x + 3
 elsif chars (KEY_LEFT_ARROW) then
 x := x - 3
 elsif chars (KEY_DOWN_ARROW) then
 y := y -3
 elsif chars ('g') then
 x1:=x1+2
 y1:=y1+2
 elsif chars ('d') then
 x1:=x1-2
 y1:=y1-2
 elsif chars ('c') then
 col:=col+1
 elsif chars ('s') then
 col:=col-1
 end if
 if col<1 then
 col:=256
 elsif col>256 then
 col:=1
 end if
 drawfilloval (x, y, x1, y1, col)
 View.Update
 end loop
 
 | 
 however i am experiencing a few problems, i am trying to make a simple circle move using this,i made it smooth using view.update, however the problem is it is not redrawing properly,and the result is a very nice etch-a sketch program...but its not what i want.does anyone know what i'm missing here?also how might i go about enabling diagonal movement?
 thanks for your help.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| DanShadow 
 
  
 
 
 | 
			
				|  Posted: Fri Jan 09, 2004 2:44 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Here, use this: 
 	  | code: |  	  | 
var x, y : int := 200
 var chars : array char of boolean
 loop
 setscreen ("offscreenonly")
 View.Update
 Draw.FillBox (0, 0, maxx, maxy, 0)
 Draw.FillOval (x, y, 10, 10, 12)
 Input.KeyDown (chars)
 if chars ('8') then
 y := y + 3
 elsif chars ('2') then
 y := y - 3
 elsif chars ('4') then
 x := x - 3
 elsif chars ('6') then
 x := x + 3
 elsif chars ('7') then
 x := x - 3
 y := y + 3
 elsif chars ('9') then
 x := x + 3
 y := y + 3
 elsif chars ('3') then
 x := x + 3
 y := y - 3
 elsif chars ('1') then
 x := x - 3
 y := y - 3
 end if
 end loop
 
 | 
 And Your welcome.
   [Use the number pad to the right of your key board to move.]
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |