My Drawbackround Procedure is not working properly
Author |
Message |
DanceMacabre
|
Posted: Sun May 07, 2006 10:06 pm Post subject: My Drawbackround Procedure is not working properly |
|
|
I made a procedure that draws my backround, which is black with a brightblue grid. My procedure seems to only draw the black backround and the y grid lines but not the x grid lines. I don't know how to fix this!
I'll give you the part of my code that actually matters.
code: |
var gridx : int := 0
var gridy : int := maxy
procedure drawback(var gridx:int, var gridy:int)
Draw.FillBox (0, 0, maxx, maxy, black)
loop
drawfillbox (gridx, 0, gridx - 1, maxy, brightblue)
gridx := gridx + 25
exit when gridx > maxx
end loop
gridx := 0
loop
drawfillbox (0, gridy, maxx, gridy - 1, brightblue)
gridy := gridy - 25
exit when gridy < 0
end loop
gridy := maxy
end drawback
cls
drawback(gridx,gridy)
var x1, y1 := 250
var keys : array char of boolean
var direction := 'r'
const speed := 1
loop
Input.KeyDown (keys)
if keys (KEY_DOWN_ARROW) then
direction := 'd'
elsif keys (KEY_UP_ARROW) then
direction := 'u'
elsif keys (KEY_LEFT_ARROW) then
direction := 'l'
elsif keys (KEY_RIGHT_ARROW) then
direction := 'r'
end if
% I'd use a case construct here, but I don't think I remember the syntax quite right
if direction = 'u' then
y1 += speed
elsif direction = 'd' then
y1 -= speed
elsif direction = 'l' then
x1 -= speed
elsif direction = 'r' then
x1 += speed
end if
Draw.FillOval (x1, y1, 5, 5, brightred)
delay (10)
end loop
|
Thanks alot |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sun May 07, 2006 10:36 pm Post subject: (No subject) |
|
|
replace your procedure with
code: |
procedure drawback(var gridx:int, var gridy:int)
Draw.FillBox (0, 0, maxx, maxy, black)
loop
drawfillbox (gridx, 0, gridx - 1, maxy, brightblue)
delay(100)
gridx := gridx + 25
exit when gridx > maxx
end loop
gridx := 0
loop
drawfillbox (0, gridy, maxx, gridy - 1, brightblue)
delay(100)
gridy := gridy - 25
exit when gridy < 0
end loop
gridy := maxy
end drawback
|
This should give you a better ideas as to what you're telling your program to do, and then how to fix it |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|
|