
-----------------------------------
Jessica359
Wed Apr 30, 2008 12:37 pm

Frogger Game
-----------------------------------
Allo...again  :lol: 
I am making a frogger game as an end of year project. This is what I have so far and I need advice.

1. I don't know how to get the program to exit out when the green circle hits one of the boxes.
2. Does anyone have any suggestions on how to improve it or what would be cool to put in it or why are you doing this game its too easy lol i dunno anything :)

thanks 

:)

-----------------------------------
metachief
Wed Apr 30, 2008 12:58 pm

RE:Frogger Game
-----------------------------------
weird game...
first of all do  you know how to use whatdotcolor function?
or do you know how to find the distance between two objects?
you could use the formula :distance = sqrt ((x2-x1)**2+(y2-y1)**2)
to find the distance between your circle and the boxes, but that would take too long assuming yu don't know arrays yet. Therefore I suggest using "whatdotcolor" eventhough it is inefficient way of doing it.
If you don't know how to use whatdotcolor then search for a tutorial, I think someone made one for it. Also I suggest learning about arrays.
Oh and make the boxes go the opposite way when they reach the end of the screen, or make new ones appear.

-----------------------------------
Jessica359
Wed Apr 30, 2008 1:03 pm

RE:Frogger Game
-----------------------------------
hey,

it might be a wierd game but its awesome :)

I researched whatdotcolor i put it into my program but it didn't do anything. Also we did learn about arrays and 2 dimensional arrays.
i'm just not sure were to start.

-----------------------------------
metachief
Wed Apr 30, 2008 1:59 pm

RE:Frogger Game
-----------------------------------
an array is very simple: instead of one variable representing one thing, an array variable represents as many as you put.
For example:
var number : array 1..10 of int
what that does is the variable number can now store 10 intergers in it and you select each one by having a subscript of number. For eaxample number (2) will give you the 2nd number.
You can specify the numbers by doing this:
var number : array 1..10 of int:=init (2,21,43,12,12,34,23,54,56,76)
So now if you say number (2) it will give you 21 scince that is the second number in your array that you specified.

-----------------------------------
Jessica359
Thu May 01, 2008 7:44 am

RE:Frogger Game
-----------------------------------
ok ya we learned that but how is that suppose to help me get its to exit when it hits the cars? 

:)

-----------------------------------
S_Grimm
Thu May 01, 2008 10:39 am

Re: Frogger Game
-----------------------------------
My best advice is to use something like this: (sorry, i can't really give specifics, had a hard time figuring out code)


if (location of box1 = location of frog) or (location of box2 = location of frog) or ...........................  then
put "You Got Run Over"
end game
else
REST OF YOUR CODE
end if


the location is the x,y co-ordinates

-----------------------------------
Jessica359
Thu May 01, 2008 12:35 pm

RE:Frogger Game
-----------------------------------
Awesome that makes much more sense!
Thanks for your help guys :)

-----------------------------------
Jessica359
Thu May 01, 2008 12:53 pm

Re: Frogger Game
-----------------------------------
Alright so another thing came up.
I took you idea of putting and if statement in.


if x = boxx and y = boxy and x=boxy and y=boxx then
cls
put"GAME OVER"
end if


But its not working?
My teacher told me something about keeping track of the x and y coordinates of the frog and boxes and something else about global declaration. Its just confusing  :? 

Any other sujestions on how to tell it to quit when it hits a box?

thnxs  :)

-----------------------------------
S_Grimm
Thu May 01, 2008 12:57 pm

RE:Frogger Game
-----------------------------------
ok, what is your variable for Frog?

-----------------------------------
Jessica359
Thu May 01, 2008 1:32 pm

RE:Frogger Game
-----------------------------------
Its ok i got it to work by putting this in (the frog is x,y)


     if x >= boxx and x = boxy and y = boxx and x = boxy and y  10 then
        y := y - 5
    end if
    if chars (KEY_RIGHT_ARROW) and x < 700 then
        x := x + 5
    end if
    if chars (KEY_LEFT_ARROW) and x > 10 then
        x := x - 5
    end if
    Pic.Draw (back, 0, 0, picCopy)
    frog
    View.Update
    exit when gameover = true
end loop


It works, and it's increadably clean.


Ps. I didn't try to get the cars to loop yet.

-----------------------------------
Jessica359
Tue May 06, 2008 8:05 am

Re: Frogger Game
-----------------------------------
Hello,
AWESOME! It works really well, also how so u set boundaries? Like when the frog hits the blue water the game will freeze and tell it "You have Won!" ?

-----------------------------------
S_Grimm
Tue May 06, 2008 10:24 am

RE:Frogger Game
-----------------------------------
determine the y position of the water and put in
CODE:
var waterhit : boolean := false
if y => (y co-ordinite of water) then
waterhit := true


then in the loop type
CODE:
exit when waterhit = true

outside of the loop
CODE:
if watertrue = true then
cls
put "You Win!"
end if

-----------------------------------
Jessica359
Thu May 08, 2008 10:02 am

Re: Frogger Game
-----------------------------------

if y => 100 then 


It tells me that the 100 has to be of a boolean type? :?

-----------------------------------
S_Grimm
Fri May 09, 2008 11:00 am

RE:Frogger Game
-----------------------------------
to correct my mistake it has to be


y >= 100 then 

its the greater than sign then the equals sign. My bad. srry

-----------------------------------
Jessica359
Mon May 12, 2008 8:59 am

RE:Frogger Game
-----------------------------------
its ok :)

so i put the equation in and all and the game is working except it doesn't do anything when 
y>=100 
is the 100 wrong or the y isn't the right variable?

-----------------------------------
Jessica359
Mon May 12, 2008 9:21 am

RE:Frogger Game
-----------------------------------
Scratch that last comment i got it to work, it was my stupid mistake :) lol
thnxs

-----------------------------------
S_Grimm
Mon May 12, 2008 11:20 am

RE:Frogger Game
-----------------------------------
no problem
great work on the program by the way.

-----------------------------------
Jessica359
Mon May 12, 2008 11:25 am

RE:Frogger Game
-----------------------------------
lol thanks i'll be needing much more help though! lol :)
so far no bugs lol :)

-----------------------------------
Jessica359
Tue May 13, 2008 7:41 am

Re: Frogger Game
-----------------------------------
Well here another problem  :lol: 
This is mythird level and I have the cars changing lanes except i want it that when the car hits the water or the grass it will just bonce off. What can I use to do that?



View.Set ("graphics, offscreenonly")
setscreen ("graphics:720;450")

var font1 : int
font1 := Font.New ("Castellar:50")

var x, y : int := 20
var chars : array char of boolean
var anglex : int := 135
var angley : int := 225
var frog2 : boolean := true
var score : int := 3
var back : int := Pic.FileNew ("background.bmp")
var waterhit : boolean := false


var boxx : int := 600
var boxy : int := 40
var boxx2 : int := 600
var boxy2 : int := 125
var boxx3 : int := 0
var boxy3 : int := 210
var boxx4 : int := 0
var boxy4 : int := 285
var boxx5 : int := 750
var boxy5 : int := 40
var boxx6 : int := 600
var boxy6 : int := 125
var boxx7 : int := 0
var boxy7 : int := 285
var boxx8 : int := 0
var boxy8 : int := 210

var gameover : boolean := false


procedure last
    drawfill (50, 50, 7, 7)
end last


procedure frog
    if frog2 then
        %exit when anglex = 135 and angley = 225
        Draw.FillOval (x, y, 20, 20, green)
        anglex := anglex - 1
        angley := angley + 1
        delay (20)
        if anglex = 135 and angley = 225 then
            frog2 := true
        end if
    end if


    % Boxes
    drawfillbox (boxx, boxy, boxx + 80, boxy + 60, 0)
    delay (12)
    boxx := boxx - 15


    drawfillbox (boxx2, boxy2, boxx2 + 80, boxy2 + 60, 59)
    delay (12)
    boxx2 := boxx2 - 4

    drawfillbox (boxx3, boxy3, boxx3 + 80, boxy3 + 60, 37)
    delay (12)
    boxx3 := boxx3 + 10

    drawfillbox (boxx4, boxy4, boxx4 + 80, boxy4 + 60, 45)
    delay (12)
    boxx4 := boxx4 + 9

    drawfillbox (boxx5, boxy5, boxx5 + 80, boxy5 + 60, 40)
    delay (12)
    boxx5 := boxx5 - 7

    drawfillbox (boxx6, boxy6, boxx6 + 80, boxy6 + 60, 7)
    delay (12)
    boxx6 := boxx6 - 10
    drawfillbox (boxx7, boxy7, boxx7 + 80, boxy7 + 60, 52)
    delay (12)
    boxx7 := boxx7 + 5

    drawfillbox (boxx8, boxy8, boxx8 + 80, boxy8 + 60, 101)
    delay (12)
    boxx8 := boxx8 + 30
    
    boxy8:= boxy8 +2


    % Boxes Moving
    if x = boxx then
        if y = boxy then
            score := score - 1
        end if
    end if

    if x = boxx2 then
        if y = boxy2 then
            score := score - 1
        end if
    end if

    if x = boxx3 then
        if y = boxy3 then
            score := score - 1
        end if
    end if

    if x = boxx4 then
        if y = boxy4 then
            score := score - 1
        end if
    end if

    if x = boxx5 then
        if y = boxy5 then
            score := score - 1
        end if
    end if

    if x = boxx6 then
        if y = boxy6 then
            score := score - 1
        end if
    end if

    if x = boxx7 then
        if y = boxy7 then
            score := score - 1
        end if
    end if

    if x = boxx8 then
        if y = boxy8 then
            score := score - 1
        end if
    end if



    % Boxes keep coming on the screen.
    if (boxx + boxy) < 1 then
        boxx := maxx
    elsif (boxx - boxy) > maxx then
        boxx := 1
    end if

    if (boxx2 + boxy2) < 1 then
        boxx2 := maxx
    elsif (boxx2 - boxy2) > maxx then
        boxx2 := 1
    end if

    if (boxx3 + boxy3) < 1 then
        boxx3 := maxx
    elsif (boxx3 - boxy3) > maxx then
        boxx3 := 1
    end if

    if (boxx4 + boxy4) < 1 then
        boxx4 := maxx
    elsif (boxx4 - boxy4) > maxx then
        boxx4 := 1
    end if

    if (boxx5 + boxy5) < 1 then
        boxx5 := maxx
    elsif (boxx5 - boxy5) > maxx then
        boxx5 := 1
    end if

    if (boxx6 + boxy6) < 1 then
        boxx6 := maxx
    elsif (boxx6 - boxy6) > maxx then
        boxx6 := 1
    end if

    if (boxx7 + boxy7) < 1 then
        boxx7 := maxx
    elsif (boxx7 - boxy7) > maxx then
        boxx7 := 1
    end if

    if (boxx8 + boxy8) < 1 then
        boxx8 := maxx
    elsif (boxx8 - boxy8) > maxx then
        boxx8 := 1
    end if

    %When the frog hits the boxes the game exits.
    if y >= 340 then
        waterhit := true
    end if


    if x >= boxx and x = boxy and y = boxx2 and x = boxy2 and y = boxx3 and x = boxy3 and y = boxx4 and x = boxy4 and y = boxx5 and x = boxy5 and y = boxx6 and x = boxy6 and y = boxx7 and x = boxy7 and y = boxx8 and x = boxy8 and y  10 then
        y := y - 5
    end if
    if chars (KEY_RIGHT_ARROW) and x < 700 then
        x := x + 5
    end if
    if chars (KEY_LEFT_ARROW) and x > 10 then
        x := x - 5
    end if
    Pic.Draw (back, 0, 0, picCopy)
    frog
    View.Update
    exit when waterhit = true
    exit when gameover = true




end loop


-----------------------------------
S_Grimm
Tue May 13, 2008 10:50 am

RE:Frogger Game
-----------------------------------
again, ill use sudocode for this. take the algorithim that moves the car across the lane and add this:

if car = water then
reverse direction of car
end if
if car = grass then
reverse direction of car
end if


use the y co-ordinates for the grass and water and for the reversal or car just use opposites (ie if your movement is y +2 then turn it to y-2)

-----------------------------------
Jessica359
Tue May 13, 2008 11:16 am

Re: Frogger Game
-----------------------------------
Ah that makes much more sense then wat i was told to do. :)
sry if i'm bugging u with questions lol :)

-----------------------------------
S_Grimm
Tue May 13, 2008 11:26 am

RE:Frogger Game
-----------------------------------
it might not work, i've yet to try it.

-----------------------------------
Jessica359
Wed May 14, 2008 4:16 pm

Re: Frogger Game
-----------------------------------
This time it has to do with boundaries. I'm getting my gars to change lanes for my third level so I got it that when it hits the water it bounces off except I can't get it to do the same when it comes to hit that grass, i have it bouncing iff but it just keeps bouncing back its not going back up. Here the specific lines.

     boxy8 := boxy8 + 2
    
            if boxy8 >= 285 then
        carhitw := true
end if

    if carhitw = true and boxy8 >= 50 then
     boxy8 := boxy8 - 5
     elsif carhitw = true and boxy8 