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

Username:   Password: 
 RegisterRegister   
 Simple Frogger Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
agent_orange444




PostPosted: Mon Jan 19, 2004 3:55 pm   Post subject: Simple Frogger Game

This is just a simple 1 level frogger game that I made in my spare time. Enjoy!

code:

var x, y, x1, x2, x3, x4, x5, x0, num, col, win, score : int
var chars : array char of boolean

x := 0
y := 0
x0 := 0
x1 := 0
x2 := 0
x3 := 0
x4 := 0
x5 := 0
win := 0
score := 10000

drawfillbox (50, 0, 650, 50, 7)
drawfillbox (0, 351, 50, 400, 7)
drawfillbox (100, 351, 650, 400, 7)
drawfillbox (x, y, x + 50, y + 50, 5)

loop

    if x = 50 and y = 350 then
        win := 1
        exit
    end if

    drawline(0,100,650,100,7)
    drawline(0,150,650,150,7)
    drawline(0,200,650,200,7)
    drawline(0,250,650,250,7)
    drawline(0,300,650,300,7)
   
    Input.KeyDown (chars)
    locate (1, 1)

    if chars (KEY_UP_ARROW) and x = 50 and y = 300 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        y := y + 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)

    elsif chars (KEY_UP_ARROW) and y <= 250 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        y := y + 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)

    elsif chars (KEY_RIGHT_ARROW) and x <= 520 and y >= 50 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        x := x + 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)

    elsif chars (KEY_LEFT_ARROW) and x >= 50 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        x := x - 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)

    elsif chars (KEY_DOWN_ARROW) and x < 50 and y > 0 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        y := y - 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)

    elsif chars (KEY_DOWN_ARROW) and y > 50 then
        drawfillbox (x, y, x + 50, y + 50, 0)
        y := y - 50
        drawfillbox (x, y, x + 50, y + 50, 5)
        delay (51)
    end if
    delay (50)

    randint (num, 0, 6)

    if num = 0 then
        drawfillbox (x0, 50, x0 + 100, 100, 2)
        drawfillbox (x0 - 300, 50, x0 + 100 - 300, 100, 1)
        drawfillbox (x0 - 600, 50, x0 + 100 - 600, 100, 45)
        if x >= x0 - 50 and y >= 50 and x + 50 <= x0 + 100 and y <= 99 then
            exit
        elsif x > x0 - 400 and y >= 50 and x + 50 <= x0 + 100 - 300 and y <= 99 then
            exit
        elsif x > x0 - 700 and y >= 50 and x + 50 <= x0 + 100 - 600 and y <= 99 then
            exit
        end if
        x0 := x0 + 50
        drawfillbox (x0 - 50, 50, x0 - 100, 100, 0)
        drawfillbox (x0 - 50 - 300, 50, x0 - 100 - 300, 100, 0)
        drawfillbox (x0 - 50 - 600, 50, x0 - 100 - 600, 100, 0)
        delay (5)
        if x0 >= 1270 then
            x0 := 0
        end if

    elsif num = 1 then
        drawfillbox (x1, 100, x1 + 100, 150, 3)
        drawfillbox (x1 - 300, 100, x1 + 100 - 300, 150, 4)
        drawfillbox (x1 - 600, 100, x1 + 100 - 600, 150, 3)
        if x >= x1 - 50 and y >= 100 and x + 50 <= x1 + 150 and y <= 149 then
            exit
        elsif x > x1 - 400 and y >= 100 and x + 50 <= x1 + 150 - 300 and y <= 149 then
            exit
        elsif x > x1 - 700 and y >= 100 and x + 50 <= x1 + 150 - 600 and y <= 149 then
            exit
        end if
        x1 := x1 + 50
        drawfillbox (x1 - 50, 100, x1 - 100, 150, 0)
        drawfillbox (x1 - 50 - 300, 100, x1 - 100 - 300, 150, 0)
        drawfillbox (x1 - 50 - 600, 100, x1 - 100 - 600, 150, 0)
        delay (5)
        if x1 >= 1270 then
            x1 := 0
        end if

    elsif num = 2 then
        drawfillbox (x2, 150, x2 + 100, 200, 94)
        drawfillbox (x2 - 300, 150, x2 + 100 - 300, 200, 78)
        drawfillbox (x2 - 600, 150, x2 + 100 - 600, 200, 68)
        if x >= x2 - 50 and y >= 150 and x + 50 <= x2 + 150 and y <= 199 then
            exit
        elsif x > x2 - 400 and y >= 150 and x + 50 <= x2 + 150 - 300 and y <= 199 then
            exit
        elsif x > x2 - 700 and y >= 150 and x + 50 <= x2 + 150 - 600 and y <= 199 then
            exit
        end if
        x2 := x2 + 50
        drawfillbox (x2 - 50, 150, x2 - 100, 200, 0)
        drawfillbox (x2 - 50 - 300, 150, x2 - 100 - 300, 200, 0)
        drawfillbox (x2 - 50 - 600, 150, x2 - 100 - 600, 200, 0)
        delay (5)
        if x2 >= 1270 then
            x2 := 0
        end if

    elsif num = 3 then
        drawfillbox (x3, 200, x3 + 100, 250, 6)
        drawfillbox (x3 - 300, 200, x3 + 100 - 300, 250, 38)
        drawfillbox (x3 - 600, 200, x3 + 100 - 600, 250, 97)
        if x >= x3 - 50 and y >= 200 and x + 50 <= x3 + 150 and y <= 249 then
            exit
        elsif x > x3 - 400 and y >= 200 and x + 50 <= x3 + 150 - 300 and y <= 249 then
            exit
        elsif x > x3 - 700 and y >= 200 and x + 50 <= x3 + 150 - 600 and y <= 249 then
            exit
        end if
        x3 := x3 + 50
        drawfillbox (x3 - 50, 200, x3 - 100, 250, 0)
        drawfillbox (x3 - 50 - 300, 200, x3 - 100 - 300, 250, 0)
        drawfillbox (x3 - 50 - 600, 200, x3 - 100 - 600, 250, 0)
        delay (5)
        if x3 >= 1270 then
            x3 := 0
        end if

    elsif num = 4 then
        drawfillbox (x4, 250, x4 + 100, 300, 9)
        drawfillbox (x4 - 300, 250, x4 + 100 - 300, 300, 10)
        drawfillbox (x4 - 600, 250, x4 + 100 - 600, 300, 9)
        if x >= x4 - 50 and y >= 250 and x + 50 <= x4 + 150 and y <= 299 then
            exit
        elsif x > x4 - 400 and y >= 250 and x + 50 <= x4 + 150 - 300 and y <= 299 then
            exit
        elsif x > x4 - 700 and y >= 250 and x + 50 <= x4 + 150 - 600 and y <= 299 then
            exit
        end if
        x4 := x4 + 50
        drawfillbox (x4 - 50, 250, x4 - 100, 300, 0)
        drawfillbox (x4 - 50 - 300, 250, x4 - 100 - 300, 300, 0)
        drawfillbox (x4 - 50 - 600, 250, x4 - 100 - 600, 300, 0)
        delay (5)
        if x4 >= 1270 then
            x4 := 0
        end if

    elsif num = 5 then
        drawfillbox (x5, 300, x5 + 100, 350, 57)
        drawfillbox (x5 - 300, 300, x5 + 100 - 300, 350, 3)
        drawfillbox (x5 - 600, 300, x5 + 100 - 600, 350, 50)
        if x >= x4 - 50 and y >= 300 and x + 50 <= x4 + 150 and y <= 349 then
            exit
        elsif x > x5 - 400 and y >= 300 and x + 50 <= x5 + 150 - 300 and y <= 349 then
            exit
        elsif x > x5 - 700 and y >= 300 and x + 50 <= x5 + 150 - 600 and y <= 349 then
            exit
        end if
        x5 := x5 + 50
        drawfillbox (x5 - 50, 300, x5 - 100, 350, 0)
        drawfillbox (x5 - 50 - 300, 300, x5 - 100 - 300, 350, 0)
        drawfillbox (x5 - 50 - 600, 300, x5 - 100 - 600, 350, 0)
        delay (5)
        if x5 >= 1270 then
            x5 := 0
        end if

    end if
    if score > 0 then
        score := score - 1
    end if

end loop

delay (500)
cls

if win = 1 then
    put "You Win! Your Score was: ", score
else
    put "Game Over"
end if
Sponsor
Sponsor
Sponsor
sponsor
poly




PostPosted: Mon Jan 19, 2004 4:47 pm   Post subject: (No subject)

who are we, the white block or the purple block? and how do we move?
agent_orange444




PostPosted: Mon Jan 19, 2004 5:31 pm   Post subject: (No subject)

oops... sry. This was my first post so i forgot to include that kinda info. You are the purple square in the bottom left corner and must reach the white square at the top by using the arrowkeys. My record score is 9965, see if you can beat it! Smile
sport




PostPosted: Mon Jan 19, 2004 7:14 pm   Post subject: (No subject)

Nice game, but it moves too fast and you get killed if you pop up behind one of the squares. Great start.
shorthair




PostPosted: Mon Jan 19, 2004 7:29 pm   Post subject: (No subject)

Wow , how long have you been programming , this game would be so cool if you imported a from picture for the player
agent_orange444




PostPosted: Wed Jan 21, 2004 4:39 pm   Post subject: (No subject)

well...i've been programming in turing for bout a year. I was gonna add pic (i actually got some from the net) but then i got lazy and stopped. I only made the game cause i was watching the scienfield episode bout frogger (did it in 1 night). Im trying to post an absolutly amazing game that a made few months back, but im having trouble finding the disk it's on. Don't forget to check it out when i do find though!
juniorspank




PostPosted: Wed Jan 21, 2004 10:54 pm   Post subject: (No subject)

It's too easy to run right through the whole thing. I got a score of 9991.
DanShadow




PostPosted: Thu Jan 22, 2004 12:36 am   Post subject: (No subject)

yeah... true. My Score=9990 Very Happy
Neat game though!
+6 Bits
Sponsor
Sponsor
Sponsor
sponsor
kalin




PostPosted: Thu Jan 22, 2004 8:17 am   Post subject: (No subject)

it is really actually quite easy...i forget my score, but well, yeah
this_guy




PostPosted: Thu Jun 10, 2004 7:25 pm   Post subject: (No subject)

i think if u make each "car" a process and fork all of them, den get them to delay randomly before moving, that would make the program easier to rite.
but that would also make it lack a lot.
marijuana




PostPosted: Thu Jun 10, 2004 10:58 pm   Post subject: (No subject)

Its a good idea to process and fork for this program. The better way in approaching it though is using the hexadecimal format. Although the link DFP may be invalid or glorped, it creates a second modifier for the constructors. I know you got lazy with the pictures but using the access folder technique, (if you have the red turing guide book refer to chapter 16) where you enable yourself in adding picture files anywhere in your hardrive, and yes this works for animated .gif's too!!! Very Happy Since you made this in one day I say you did a fairly good job. Calculations do need to be made for complexity. Use the switch and sprite techniques for it. Keep up the good work!!!
the_short1




PostPosted: Wed Jun 16, 2004 10:05 pm   Post subject: (No subject)

what... tur9ing wont let u use .gifs....

unless u read my tutorial on how to do it manually.... but still cant do it DIRECTLY...

that post of urs is really consufing Eh


scienfeild.. hahahahah yea i remember that episode.. it was great!

btw: very good game...
kinda easy... but good...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: