Computer Science Canada

Hide and Seek

Author:  chipanpriest [ Sun Dec 18, 2011 4:26 pm ]
Post subject:  Hide and Seek

Simple game I created Smile enjoy! oh, also, when you get one box, you can sometimes see the next one come up and idk why, so if anyone wants to give some help, thanks

Turing:

var mousex, mousey, click, boxx, boxy, col, score, timevar, font1, font2 : int

View.Set ("graphics:1000;600,offscreenonly")
font1 := Font.New ("Comic Sans MS:30")
font2 := Font.New ("Comic Sans MS:15")

loop

    timevar := 0
    score := 0
    loop
        randint (col, 1, 15)
        randint (boxx, 20, maxx - 20)
        randint (boxy, 20, maxy - 120)

        loop
            cls
            mousewhere (mousex, mousey, click)
            drawfilloval (mousex, mousey, 50, 50, 0)
            drawfillbox (0, 500, maxx, maxy, 0)
            drawfillbox (boxx - 10, boxy - 10, boxx + 10, boxy + 10, col)
            drawline (0, 500, maxx, 500, 7)
            colourback (0)
            put "score: ", score
            locate (1, 50)
            put timevar
            colourback (col)
            View.Update
            if timevar = 5000 then
                exit
            end if
            timevar := timevar + 1
            if mousex >= boxx - 10 and mousex <= boxx + 10 and mousey >= boxy - 10 and mousey <= boxy + 10 and click = 1 then
                score := score + 1
                exit
            end if
            delay (10)
        end loop
        if timevar = 5000 then
            exit
        end if
    end loop
    colourback (0)
    cls

    Font.Draw ("Game Over", 400, 400, font1, col)
    Font.Draw ("Score: ", 400, 100, font1, 7)
    Font.Draw (intstr (score), 550, 100, font1, 7)
    Font.Draw ("Again?", 850, 100, font2, 7)
    Font.Draw ("Yes", 800, 25, font2, 7)
    Font.Draw ("No", 950, 25, font2, 7)
    drawfillbox (800, 50, 825, 75, 12)
    drawfillbox (950, 50, 975, 75, 12)
    View.Update

    loop
        mousewhere (mousex, mousey, click)
        if click = 1 then
            exit
        end if
    end loop
    if mousex >= 950 and mousex <= 975 and mousey >= 50 and mousey <= 75 then
        cls
        exit
    end if
end loop


Author:  Aange10 [ Sun Dec 18, 2011 6:10 pm ]
Post subject:  RE:Hide and Seek

It's because your drawing the box before the rest of the screen is done.

The entire bottom portion isn't drawn untill the second round, giving a 10ms delay where you can see the box.


: