Computer Science Canada

Catch the Box Game

Author:  agent_orange444 [ Thu Jan 22, 2004 4:06 pm ]
Post subject:  Catch the Box Game

This is a game that i quikly made cause i was board (1 night). Your goal is to keep your mouse inside a randomly moving box. You click to start, and can click to reset. Enjoy!

code:

var x, x2, y, y2, mx, my, start, button, num, buttonnumber, score,
    buttonupdown, speed, size, change, maxspeed, minspeed,
    butx, buty : int
setscreen ("graphics:vga")
loop
    num := 10
    x2 := 1
    y2 := 1
    start := 1
    score := 0
    %size of the box (defualt = 10)
    size := 10
    %speed the box moves (75-125)
    maxspeed := 50
    minspeed := 125
    randint (x, 0, 625)
    randint (y, 0, 365)
    %optional set start location
    %x:=
    %y:=

    loop

        randint (change, 1, 10)
        drawline (0, 375, 625, 375, 7)
        randint (speed, maxspeed, minspeed)

        if num = 10 then
            randint (x2, - 1, 1)
            randint (y2, - 1, 1)
        end if

        drawfillbox (x, y, x + size, y + size, 3)
        delay (speed)

        if start = 1 then
            put "Click to Start - keep your mouse in the box"
            buttonwait ("down", butx, buty, buttonnumber, buttonupdown)
            start := start + 1
        end if

        drawfillbox (x, y, x + size, y + size, 0)
        num := num + change

        if num > 20 then
            num := 0
        end if

        x := x + x2
        y := y + y2

        if x = 0 then
            x := x + 1
        elsif x >= 625 then
            x := x - 1
        end if

        if y = 0 then
            y := y + 1
        elsif y >= 365 then
            y := y - 1
        end if

        mousewhere (mx, my, button)
        if mx > x - 1 and mx < x + size + 1 and my > y - 1 and my < y + size
                + 1 then
            score := score + 1
            locate (1, 1)
            put "score= ", score
        else
            cls
            exit
        end if
    end loop
    put "Game Over - Your Score was: ", score
    buttonwait ("down", butx, buty, buttonnumber, buttonupdown)
    cls
end loop


Author:  kalin [ Thu Jan 22, 2004 4:11 pm ]
Post subject: 

Hey, cool. I like it

Author:  agent_orange444 [ Thu Jan 22, 2004 4:13 pm ]
Post subject: 

thnx, i just had a cool idea to make the box move faster as you get higher scores! By the way my record is 205, try and beat it!

Author:  kalin [ Thu Jan 22, 2004 4:14 pm ]
Post subject: 

I have a hard time reaching 40.....But I'll try! And yeah, that is a cool idea.

[added] 230! yay, sheer determination!

Author:  shorthair [ Thu Jan 22, 2004 4:23 pm ]
Post subject: 

got to 48 max , just got lucky , very well done get some background music to keep you going , and mabye turn it into a level besed game , where the box gets smaller and it moves faster every say 50 points , that would be BIT worthy to me

Author:  agent_orange444 [ Thu Jan 22, 2004 4:28 pm ]
Post subject: 

thnx, i love that idea! im gonna get workin on it right away! But what do u mean by bit worthy?

Author:  shorthair [ Thu Jan 22, 2004 4:29 pm ]
Post subject: 

go look around the shop to ee what magical bits can do for you

Author:  kalin [ Thu Jan 22, 2004 4:31 pm ]
Post subject: 

lol. I still dont really get them, but whatever. Oh well. I think its actually kinmda cool as it is, but yeah. Make it a lvling game and such, it would be really cool after that.

Also, I dunno, do either of you know how to set a timer?? I looked and didn't see anything about that that would help. So, do either of you know. If not it's cool.

Author:  shorthair [ Thu Jan 22, 2004 4:45 pm ]
Post subject: 

A countdown timer , or a count up timer

Author:  kalin [ Thu Jan 22, 2004 4:49 pm ]
Post subject: 

count up.

Author:  shorthair [ Thu Jan 22, 2004 4:55 pm ]
Post subject: 

var timeRunning : int
loop
timeRunning := Time.Elapsed
locate (10 ,20)
put "This program has run ", timeRunning, " milliseconds"
end loop


can i have some bits Crying or Very sad im without , <---- Shocked just joking , enjoy it

Author:  kalin [ Thu Jan 22, 2004 4:59 pm ]
Post subject: 

thx. Hey, Orange, you should do that and have the score a little slower, and have it so that the person knows how long her lasted time wise too.... Just a though...

Author:  agent_orange444 [ Thu Jan 22, 2004 5:01 pm ]
Post subject: 

thnx for the suggestion but i already released the newer version! lol Don't forget to check it out! (the same name as this version but 2.0) and Enjoy!


: