Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My Drawbackround Procedure is not working properly
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DanceMacabre




PostPosted: 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 Crying or Very sad
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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 Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: