| Animation 
 
	 
	
		| Author | Message |   
		| bucky-lady 
 
 
 
 
 | 
			
				|  Posted: Sat Jan 06, 2007 6:00 pm    Post subject: Animation |  |   
				| 
 |  
				| How do you make the little blue box not go outside the size of the screen or distort ? 
 thank you for your help.
 
 Code :
 
 % Declaration Section
 var startpointx, startpointy : int := 0
 var endpointx, endpointy : int := 50
 var key : string (1)
 
 % set screen mode and size
 setscreen ("graphics : 400;400 ")
 setscreen ("noecho")
 setscreen ("nocursor")
 setscreen ("offscreenonly")
 procedure display
 drawfillbox (startpointx, startpointy, endpointx, endpointy, white)
 drawfillbox (startpointx + 1, startpointy + 1, endpointx - 1, endpointy - 1, blue)
 getch (key)
 if key = chr (200) then
 startpointy := startpointy + 1
 endpointy := endpointy + 1
 elsif key = chr (208) then
 startpointy := startpointy - 1
 endpointy := endpointy - 1
 elsif key = chr (205) then
 startpointx := startpointx + 1
 endpointx := endpointx + 1
 else
 if key = chr (203) then
 startpointx := startpointx - 1
 endpointx := endpointx - 1
 end if
 end if
 View.Update
 end display
 
 % Main program
 loop
 display
 exit when key = chr (27)
 end loop
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Prince Pwn 
 
 
 
 
 | 
			
				|  Posted: Sat Jan 06, 2007 6:31 pm    Post subject: (No subject) |  |   
				| 
 |  
				| I did a bit of cleaning of your code, and in comments I put how you figure out of your box is off screen. I don't see your box distorting at all. And when you post any of your code, do: 	  | code: |  	  | [code]PLACE CODE HERE[/code] | 
 
 
 	  | code: |  	  | 
% Declaration Section
 var startpointx, startpointy : int := 0
 var keys : array char of boolean
 
 % set screen mode and size
 setscreen ("graphics : 400;400 ")
 setscreen ("noecho")
 setscreen ("nocursor")
 setscreen ("offscreenonly")
 procedure display
 drawfillbox (startpointx, startpointy, startpointx + 50, startpointy + 50, blue)
 Input.KeyDown (keys)
 if keys (chr (200)) then
 startpointy := startpointy + 1
 elsif keys (chr (208)) then
 startpointy := startpointy - 1
 elsif keys (chr (205)) then
 startpointx := startpointx + 1
 elsif keys (chr (203)) then
 startpointx := startpointx - 1
 end if
 View.Update
 cls
 %if the x is equal or less than 0 then increase x
 %if the x axis plus the radius is greater than the max x then decrease x
 %if the y is equal or less than 0 then increase y
 %if the y axis plus the radius is greater than the max y then decrease y
 end display
 
 % Main program
 loop
 display
 exit when keys (chr (27))
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Prince Pwn 
 
 
 
 
 | 
			
				|  Posted: Sat Jan 06, 2007 6:33 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Also, F2 indents your code. Best do that before posting the code here, makes it clean =D |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| neufelni 
 
 
 
 
 | 
			
				|  Posted: Sat Jan 06, 2007 6:49 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Several things that you should change: 
 1. Combine all of your setscreens into one:
 
 	  | code: |  	  | setscreen ("graphics:400;400, noecho, nocursor, offscreenonly") | 
 
 2. You don't need the endpoint variables, just change your drawfillbox to this:
 
 	  | code: |  	  | drawfillbox (x, y, x + 50, y + 50, blue) | 
 
 3. You just need to add an extra condition to each of your if statements so that you can't move left if startpointx = 0, move right if endpointx = maxx, move down if startpointy = 0, or move up if endpointy = maxy.
 
 4. Use code tags.
 
 Here is your code with those changes and a few others.
 
 	  | code: |  	  | % Declaration Section
var x, y : int := 0
 var key : string (1)
 
 % set screen mode and size
 setscreen ("graphics:400;400, noecho, nocursor, offscreenonly")
 procedure display
 drawfillbox (x, y, x + 50, y + 50, blue)
 getch (key)
 if key = chr (200) and y + 50 not= maxy then
 y := y + 1
 elsif key = chr (208) and y not= 0 then
 y := y - 1
 elsif key = chr (205) and x + 50 not= maxx then
 x := x + 1
 elsif key = chr (203) and x not= 0 then
 x := x - 1
 end if
 View.Update
 cls
 end display
 
 % Main program
 loop
 display
 exit when key = chr (27)
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| bucky-lady 
 
 
 
 
 | 
			
				|  Posted: Wed Jan 10, 2007 5:17 pm    Post subject: RE:Animation |  |   
				| 
 |  
				| thank you  |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |