Posted: Wed Apr 30, 2008 12:37 pm Post subject: Frogger Game
Allo...again
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
Posted: Wed Apr 30, 2008 12:58 pm Post subject: 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
Posted: Wed Apr 30, 2008 1:03 pm Post subject: 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
Posted: Wed Apr 30, 2008 1:59 pm Post subject: 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
Posted: Thu May 01, 2008 7:44 am Post subject: 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
Posted: Thu May 01, 2008 10:39 am Post subject: 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)
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
Posted: Thu May 01, 2008 12:35 pm Post subject: RE:Frogger Game
Awesome that makes much more sense!
Thanks for your help guys
Jessica359
Posted: Thu May 01, 2008 12:53 pm Post subject: Re: Frogger Game
Alright so another thing came up.
I took you idea of putting and if statement in.
code:
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
Sponsor Sponsor
S_Grimm
Posted: Thu May 01, 2008 12:57 pm Post subject: RE:Frogger Game
ok, what is your variable for Frog?
Jessica359
Posted: Thu May 01, 2008 1:32 pm Post subject: RE:Frogger Game
Its ok i got it to work by putting this in (the frog is x,y)
code:
if x >= boxx and x <= boxx +80 and y >= boxy and y <= boxy +80 then
cls
put "GAME OVER"
So now when it his teh white box it clears teh background and says game over but as soon as the box is pass the frog the game keeps going.
Sean
Posted: Thu May 01, 2008 2:06 pm Post subject: RE:Frogger Game
Change the cls to an exit
Turing:
if x >= boxx and x <= boxx + 80and y >= boxy and y <= boxy + 80then exit endif
Jessica359
Posted: Fri May 02, 2008 8:54 am Post subject: RE:Frogger Game
ya i thought of that except its not in a loop and when i put a loop in it messed up and doesn't even work.
Sean
Posted: Fri May 02, 2008 11:22 am Post subject: RE:Frogger Game
Your game should be in a loop, so you have constant movement of the picture.
petree08
Posted: Fri May 02, 2008 11:29 am Post subject: RE:Frogger Game
add this to keep your cars going
(mind this is genaric and not specific to your code)
if (CarX +CarLength ) < 1 then
CarX := maxx
elsif ( CarX -CarLength )> maxx then
CarX :=1
end if
Asherel
Posted: Fri May 02, 2008 2:22 pm Post subject: Re: Frogger Game
As Sean mentioned, your game should always be in a loop to allow continuous movement of your character, which happens to be Frogger.
There are ways to do it without loops, however since you're the one moving Frogger, you would have Input.KeyDown in your code.
Input.KeyDown allows you to manoeuver around the screen, if it is in a loop you can do this continuously until you meet a certain condition, or hit boundaries. Without the loop, one click and it stops completely.
When I have access to a computer that has my example program, I'll post it as an example. It has collision of dots, and then exits when the AI equals the Character.
So, to answer your question on how to exit it. Have a main program loop, and then when the condition of the two dots colliding is met, exit the program with the exit function.