Computer Science Canada Frogger Game |
Author: | Jessica359 [ 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 thanks |
Author: | metachief [ 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. |
Author: | Jessica359 [ 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. |
Author: | metachief [ 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. |
Author: | Jessica359 [ 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? |
Author: | S_Grimm [ 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)
the location is the x,y co-ordinates |
Author: | Jessica359 [ Thu May 01, 2008 12:35 pm ] |
Post subject: | RE:Frogger Game |
Awesome that makes much more sense! Thanks for your help guys |
Author: | Jessica359 [ 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.
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 |
Author: | S_Grimm [ Thu May 01, 2008 12:57 pm ] |
Post subject: | RE:Frogger Game |
ok, what is your variable for Frog? |
Author: | Jessica359 [ 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)
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. |
Author: | Sean [ Thu May 01, 2008 2:06 pm ] | ||
Post subject: | RE:Frogger Game | ||
Change the cls to an exit
|
Author: | Jessica359 [ 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. |
Author: | Sean [ 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. |
Author: | petree08 [ 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 |
Author: | Asherel [ 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. |
Author: | Jessica359 [ Mon May 05, 2008 9:16 am ] |
Post subject: | RE:Frogger Game |
Ok so i got the cars to keep moving except when i put my overall program in a loop the game doesn't work or doesn't even start. |
Author: | S_Grimm [ Mon May 05, 2008 10:38 am ] |
Post subject: | RE:Frogger Game |
Can you post the updated version with the modifications you made, so we can take another look at it? |
Author: | Jessica359 [ Mon May 05, 2008 11:18 am ] |
Post subject: | Re: Frogger Game |
Here is what I have so far |
Author: | S_Grimm [ Mon May 05, 2008 11:57 am ] | ||||
Post subject: | Re: Frogger Game | ||||
ok, I took a look and determined this : 1) Exit does not work. 2) Boolean statements do. I'm posting a modified version of the game that has my boolean statements in it. Basically what i did is this: when your code says
then at the bottom of your code,
It works, and it's increadably clean. Ps. I didn't try to get the cars to loop yet. |
Author: | Jessica359 [ Tue May 06, 2008 8:05 am ] |
Post subject: | 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!" ? |
Author: | S_Grimm [ Tue May 06, 2008 10:24 am ] |
Post subject: | 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 |
Author: | Jessica359 [ Thu May 08, 2008 10:02 am ] | ||
Post subject: | Re: Frogger Game | ||
It tells me that the 100 has to be of a boolean type? |
Author: | S_Grimm [ Fri May 09, 2008 11:00 am ] |
Post subject: | 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 |
Author: | Jessica359 [ Mon May 12, 2008 8:59 am ] |
Post subject: | 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? |
Author: | Jessica359 [ Mon May 12, 2008 9:21 am ] |
Post subject: | RE:Frogger Game |
Scratch that last comment i got it to work, it was my stupid mistake lol thnxs |
Author: | S_Grimm [ Mon May 12, 2008 11:20 am ] |
Post subject: | RE:Frogger Game |
no problem great work on the program by the way. |
Author: | Jessica359 [ Mon May 12, 2008 11:25 am ] |
Post subject: | RE:Frogger Game |
lol thanks i'll be needing much more help though! lol so far no bugs lol |
Author: | Jessica359 [ Tue May 13, 2008 7:41 am ] | ||
Post subject: | Re: Frogger Game | ||
Well here another problem 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?
|
Author: | S_Grimm [ Tue May 13, 2008 10:50 am ] |
Post subject: | 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) |
Author: | Jessica359 [ Tue May 13, 2008 11:16 am ] |
Post subject: | 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 |
Author: | S_Grimm [ Tue May 13, 2008 11:26 am ] |
Post subject: | RE:Frogger Game |
it might not work, i've yet to try it. |
Author: | Jessica359 [ Wed May 14, 2008 4:16 pm ] | ||
Post subject: | 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.
Heres the entire program if you need it. |
Author: | S_Grimm [ Fri May 16, 2008 10:22 am ] |
Post subject: | Re: Frogger Game |
You needed to use a if carhitw = false statement to make it move up. ill post it here for you |
Author: | Jessica359 [ Fri May 16, 2008 7:34 pm ] |
Post subject: | RE:Frogger Game |
ok cool, i forgot to write that i had alreadu figured it out but i got the excat same thing lol thxs though lol ;p Now i have one more question and this should be one of my last ones lol how would i interconnect all my lelves. cuz when i put them in procedure they mess up? thnxs |
Author: | S_Grimm [ Sat May 17, 2008 11:36 am ] |
Post subject: | RE:Frogger Game |
can u post all the lvls in a zip folder for me? i need to have the differences to work with. |
Author: | Sean [ Sat May 17, 2008 11:51 am ] | ||
Post subject: | Re: Frogger Game | ||
You can make a variable for levels, and then if a person beats a level then it increases and goes to next.
This is how we used to do it in the days of Mario. Mackie and I devised this ages ago, however we never moved onto a further one. Secondly, I bet there is a more efective way, however this is one way to do it. |
Author: | riveryu [ Sat May 17, 2008 12:32 pm ] | ||
Post subject: | RE:Frogger Game | ||
also, just a suggestion. If your levels only involve very simple changes then you can write a procedure to create levels for you. If dont know already, try to learn to use arrays. Tutorial here http://compsci.ca/v3/viewtopic.php?t=14333 A very simple example here...
Correct me if im wrong somewhere... |
Author: | Jessica359 [ Sun May 18, 2008 7:20 pm ] |
Post subject: | Re: Frogger Game |
Alright so heres the 3 levels i have. |
Author: | Jessica359 [ Wed May 21, 2008 4:58 pm ] |
Post subject: | RE:Frogger Game |
is this any help? :s |
Author: | Jessica359 [ Wed May 21, 2008 5:16 pm ] |
Post subject: | Re: Frogger Game |
ok so i tried this method here, exept it gives me an error of "'procedure' may only be declared at the program, module, or monitor level." wat can i do? |
Author: | S_Grimm [ Thu May 22, 2008 10:43 am ] |
Post subject: | RE:Frogger Game |
i'm trying, but it eludes me. It keeps bypassing the second and third levels and finishing the program |
Author: | Jessica359 [ Thu May 22, 2008 3:49 pm ] |
Post subject: | RE:Frogger Game |
ah ok thxs for trying, does any1 else know by any chance? |
Author: | riveryu [ Fri May 23, 2008 10:56 pm ] |
Post subject: | RE:Frogger Game |
I've looked at your program. Heres a few comments according to ur latest uploaded version, "FROGGER put together.t" - do not loop decalartions of anything such as vars, procedures etc.. i killed that loop u had and it worked -also, procedure can abbreviated as "proc" -you can set everything for View.Set or setscreen in one call. ex. View.Set ("graphics:700;600,offscreenonly") |
Author: | Jessica359 [ Thu May 29, 2008 9:22 am ] |
Post subject: | Re: Frogger Game |
Ok so I got it to change levels with the "include" function. So when you click on the intro screen it should start the program except it goes to "lvl1" and gives me an error on the first 2 procedures. Is there something i'm doing wrong? thnxs |
Author: | S_Grimm [ Fri May 30, 2008 10:36 am ] |
Post subject: | RE:Frogger Game |
your procedures are all named the same (frog). "frog" has already been declared by the first level. call the other procedures something else. |
Author: | Jessica359 [ Fri May 30, 2008 1:35 pm ] |
Post subject: | RE:Frogger Game |
k i fixed it its all good now |