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

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




PostPosted: Sun Apr 09, 2006 3:39 pm   Post subject: Frogger

code:

%Settings
setscreen ("graphics:830;600")
View.Set ("offscreenonly")
%Settings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Variables
var x, y, button : int %The User
var badx, bady, badx2, bady2, badx3, bady3, badx4, bady4, badx5, bady5, badx6, bady6, badx7, bady7 : int %Enemy
var chars : array char of boolean %To move box
var score : int := 60
var moneyx, moneyy : int
var money : int := 0
%Variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x := 220
%y := 540
y := 200
drawfillbox (x, y, x + 50, y + 50, 12)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc drawmap
    %Top
    drawfillbox (0, 510, 830, 610, green)
    %Top
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Top Road
    drawfillbox (-10, 510, 830, 280, 7)
    drawfillbox (10, 385, 150, 405, yellow)
    drawfillbox (180, 385, 320, 405, yellow)
    drawfillbox (350, 385, 490, 405, yellow)
    drawfillbox (520, 385, 670, 405, yellow)
    drawfillbox (700, 385, 830, 405, yellow)
    %Top Road
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Middle
    drawfillbox (-10, 280, 830, 240, 23)
    %Middle
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Bottom Road
    drawfillbox (-10, 240, 830, 0, 7)
    drawfillbox (10, 130, 150, 110, yellow)
    drawfillbox (180, 130, 320, 110, yellow)
    drawfillbox (350, 130, 490, 110, yellow)
    drawfillbox (520, 130, 670, 110, yellow)
    drawfillbox (700, 130, 830, 110, yellow)
    %Bottom Road
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end drawmap
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc hey
    %Random Spots For Boxes
    randint (badx, -50, -50)
    randint (bady, 5, 150)
    randint (badx2, 820, 820)
    randint (bady2, 5, 150)
    randint (badx3, 820, 820)
    randint (bady3, 280, 430)
    randint (badx4, -50, -50)
    randint (bady4, 280, 430)
    randint (badx5, -50, -50)
    randint (bady5, 5, 150)
    randint (badx6, 820, 820)
    randint (bady6, 280, 430)
    randint (badx7, 820, 820)
    randint (bady7, 280, 430)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    randint (moneyx, 100, 800)
    randint (moneyy, 0, 570)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Random Spots For Boxes
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    loop
        drawmap
        locate (1, 1)
        put "Life: ", score
        put "Cash: ", money
        drawfillbox (90, 511, 830, 610, green)
        drawfillbox (x, y, x + 50, y + 50, 12)
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            y := y + 4
        end if
        if chars (KEY_DOWN_ARROW) then
            y := y - 4
        end if
        if chars (KEY_LEFT_ARROW) then
            x := x - 4
        end if
        if chars (KEY_RIGHT_ARROW) then
            x := x + 4
        end if
        if x < 0 then
            x := x + 4
        end if
        if x > 778 then
            x := x - 4
        end if
        if y < 1 then
            y := y + 4
        end if
        if y > 547 then
            y := y - 4
        end if
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %Boxes Moving
        drawfillbox (badx, bady, badx + 80, bady + 80, 0)
        delay (12)
        badx := badx + 7
        drawfillbox (badx2, bady2, badx2 + 80, bady2 + 80, 0)
        delay (12)
        badx2 := badx2 - 6
        drawfillbox (badx3, bady3, badx3 + 80, bady3 + 80, 0)
        delay (12)
        badx3 := badx3 - 6
        drawfillbox (badx4, bady4, badx4 + 80, bady4 + 80, 54)
        delay (12)
        badx4 := badx4 + 5
        drawfillbox (badx5, bady5, badx5 + 80, bady5 + 80, 0)
        delay (12)
        badx5 := badx5 + 8
        drawfillbox (badx6, bady6, badx6 + 80, bady6 + 80, 0)
        delay (12)
        badx6 := badx6 - 8
        drawfillbox (badx7, bady7, badx7 + 80, bady7 + 80, 0)
        delay (12)
        badx7 := badx7 - 8
        exit when badx > 880 or badx2 < -60 or badx3 < -60 and badx4 < 880
        %Boxes Moving
        if x <= badx + 70 and x + 50 >= badx then
            if y <= bady + 70 and y + 50 >= bady then
                score := score - 1
            end if
        end if
        if x <= badx2 + 70 and x + 50 >= badx2 then
            if y <= bady2 + 70 and y + 50 >= bady2 then
                score := score - 1
            end if
        end if
        if x <= badx3 + 70 and x + 50 >= badx3 then
            if y <= bady3 + 70 and y + 50 >= bady3 then
                score := score - 1
            end if
        end if
        if x <= badx4 + 70 and x + 50 >= badx4 then
            if y <= bady4 + 70 and y + 50 >= bady4 then
                score := score - 1
            end if
        end if
        if x <= badx5 + 70 and x + 50 >= badx5 then
            if y <= bady5 + 70 and y + 50 >= bady5 then
                score := score - 1
            end if
        end if
        if x <= badx6 + 70 and x + 50 >= badx6 then
            if y <= bady6 + 70 and y + 50 >= bady6 then
                score := score - 1
            end if
        end if
        if x <= badx7 + 70 and x + 50 >= badx7 then
            if y <= bady7 + 70 and y + 50 >= bady7 then
                score := score - 1
            end if
        end if
        drawfillbox (moneyx, moneyy, moneyx + 20, moneyy + 20, 34)
        if x <= moneyx + 20 and x + 50 >= moneyx and y <= moneyy + 20 and y + 20 >= moneyy then
            money := money + 1
        end if
        View.Update
        exit when score <= 0
        exit when money >= 12
        cls
    end loop
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end hey
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
    exit when score <= 0
    exit when money >= 12
    hey
end loop
color (7)
put "You Lose!"
put ""
delay (1000)
put "Maybe next time!"
cls


Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Sun Apr 09, 2006 5:45 pm   Post subject: (No subject)

Not too bad, You've got the basics down, but there is much room for improvement.

First of all, investigate arrays. They will help out immensly.

Second, once you've got the arrays down, it would be really easy to make the enemies switch sides of the screen (Once they hit the left side of the screen, they move to the right) as opposed to just kinda randomly teleporting to the sides.

Third, try a more intuitive, or a more frogger-like scoring system. Currently, you just have to stand on the small blue box, and you gain points. If you had it so the blue box moved somewhere else on the screen once you stepped on it, it would make the game more challenging.

Fourth, differentiate between money and enemies (one of them is the same colour as the money)

Fifth, Rather than having like 5 different delays, have one delay at the end. Also, use the command
code:

Time.DelaySinceLast

instead of delay. Time.DelaySinceLast ensures that the program runs the same on all PCs

Sixth, you forgot a View.Update at the end of the program. We can't see the "You Lose", and the "Maybe next time" would dissapear instantly because of the cls.

Finally, Instructions wouldn't hurt (though it doesn't take too long to figure out.)

Good job on the roads, btw. Looks sexy Razz
MysticVegeta




PostPosted: Mon Apr 10, 2006 6:05 pm   Post subject: (No subject)

Its great to see you are off from using processes!!! Great job! Next step is arrays! Smile Good luck
Clayton




PostPosted: Mon Apr 10, 2006 6:16 pm   Post subject: (No subject)

Also, if you plan on going further with Turing, get familiar with Draw.Box(MapleLeaf,Oval etc.) commands as they can help you understand modules when you get into them
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  [ 4 Posts ]
Jump to:   


Style:  
Search: