I've made a couple updates and pointed them out. Call them mini-lessons.
Turing: | setscreen ("graphics:639;399,nobuttonbar,offscreenonly")
% ^ Setting it to graphics, screen size 639x399, hiding the button bar at the top of the run window, and the needed offscreenonly for drawing.
drawfillbox (50, 50, 100, 100, 7)
colorback (7) %<---- (Same as below)
color (10) %<---- Because this only needs to be called once (unless you are changing the colour), I moved it before the loop
var x, y : int
var a : string (1)
x := maxx div 2
y := maxy div 2
var chars : array char of boolean
loop
cls %<---- cls should be at the top of the loop, before you draw anything to the screen (it will wipe the screen clear)
drawbox (0, 0, maxx, maxy, 10)
drawbox (0, 0, 195, 195, 10)
drawbox (0, maxy, 195, maxy - 195, 10)
drawbox (maxx, 0, maxx - 195, 195, 10)
drawbox (maxx, maxy, maxx - 195, maxy - 195, 10)
drawbox (200, 0, maxx - 200, 100, 10)
drawbox (200, maxy - 100, maxx - 200, maxy, 10)
Input.KeyDown (chars )
if x > 5 and x < 635 and y > 5 and y < 395 then
if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if
elsif x < 6 or x > 636 or y < 6 or y > 396 then
x := maxx div 2
y := maxy div 2
end if
drawoval (x, y, 4, 4, 10)
delay (10)
put x, " " ..
put y
View.Update %<---- View.Update goes at the end of the loop, after you have drawn everything
end loop
|
Hope that helps you. |