Computer Science Canada Animation |
Author: | bucky-lady [ 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 |
Author: | Prince Pwn [ Sat Jan 06, 2007 6:31 pm ] | ||||
Post 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:
|
Author: | Prince Pwn [ Sat Jan 06, 2007 6:33 pm ] |
Post subject: | |
Also, F2 indents your code. Best do that before posting the code here, makes it clean =D |
Author: | neufelni [ Sat Jan 06, 2007 6:49 pm ] | ||||||
Post subject: | |||||||
Several things that you should change: 1. Combine all of your setscreens into one:
2. You don't need the endpoint variables, just change your drawfillbox to this:
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.
|
Author: | bucky-lady [ Wed Jan 10, 2007 5:17 pm ] |
Post subject: | RE:Animation |
thank you ![]() |