Computer Science Canada helpppppp!!!! |
Author: | ahmhum [ Sat Jun 07, 2008 10:18 am ] |
Post subject: | helpppppp!!!! |
i am making a game for my ISU its a fighting game and when the hero punches the villian the villians points go down once but after that theres n end page that i made that shows up b4 the villians health points hits 0 or is less than 0 so i want mario to keep fighting the villian until the villian's health points are 0 or less than 0 so any1 help please and here's my code so far public static void marioFightSceneBombMushroomPower(int x, int y, int xP, int yP) { //Clear screens. d.clear(); c.clear(); //Set integers; goombaHealthPoints=60; marioHealthPoints=70; int health; //final int SENTINAL=0; health = (int) (Math.random () * 15) + 1; //Call upon the health points console. { healthPointsConsole(); } //Call upon the various initial setup methods. { backgroundC(x, y); backgroundD(x, y); marioVsGoombaTitle(); } //Call upon the grid method. { grid(); } //Ask user the first question. d.setTextBackgroundColor(Color.blue); d.setTextColor(Color.yellow); d.println(" Please choose your technique of fighting:"); d.println(" ---------------------------------------------------------------"); d.println(" * Please enter: *"); d.println(" * (1) to punch *"); d.println(" * (2) to kick *"); d.println(" * (3) to use your bomb *"); d.println(" ---------------------------------------------------------------"); d.print(" Please enter your choice now: "); d.setVisible(true); f.println("Goomba Health Points: " + goombaHealthPoints); f.println("Mario Health Points: " + marioHealthPoints); //Read input. String input = d.readLine(); //Declare integer. int fighting=0; /* Set up 'if' construct with try/catch to determine the next choice of action for the user.*/ try { fighting= Integer.parseInt(input); } catch (NumberFormatException e) { //User selects defaults to invalid entry. } //while (0>goombaHealthPoints) if(fighting==1) { f.clear(); goombaHealthPoints-=health ; f.println("Goomba Health Points: " + goombaHealthPoints); f.println("Mario Health Points: " + marioHealthPoints); c.setVisible(true); c.println("Hit Enter to Continue"); c.readChar(); goombaFightScene(x, y, xP ,yP); } if(fighting==2) { f.clear(); goombaHealthPoints=goombaHealthPoints-health; f.println("Goomba Health Points: " + goombaHealthPoints); f.println("Mario Health Points: " + marioHealthPoints); c.setVisible(true); c.println("Hit Enter to Continue"); c.readChar(); goombaFightScene(x, y, xP ,yP); } if(fighting==3) { f.clear(); goombaHealthPoints-=health; f.println("Goomba Health Points: " + goombaHealthPoints); f.println("Mario Health Points: " + marioHealthPoints); c.setVisible(true); c.println("Hit Enter to Continue"); c.readChar(); goombaFightScene(x, y, xP ,yP); } if (fighting==-1) { //create and close method. d.close(); c.close(); } if(-1>fighting||fighting==0||fighting>3) { //Call upon invalid entry. invalidEntry(xP, yP); //Creating the loop. marioFightSceneBombMushroomPower(x, y, xP, yP); } }//marioFightSceneBombMushroom method |
Author: | Aziz [ Sat Jun 07, 2008 11:29 am ] |
Post subject: | RE:helpppppp!!!! |
1) Sentences are your friend. 2) So are [code] tags 3) And you could try to point out where you think somethings is going wrong 4) Your topic needs a proper title 5) All of the above were posted in the FORUM RULES threads. I you would've just read the rules, you could get help! Either someone would be likely to help you, or you would come up with the answer in your new found divine knowledge. Yes, I'lm being an ass. I may look at the code, too, but not until tonight at least. |
Author: | ahmhum [ Sat Jun 07, 2008 12:00 pm ] |
Post subject: | Re: helpppppp!!!! |
ok heres my whole program |
Author: | HellblazerX [ Sat Jun 07, 2008 2:34 pm ] | ||
Post subject: | Re: helpppppp!!!! | ||
Using a while loop, keep looping your game until your villain's hp drops below 0. Once your game exits the loop, have the end page show up.
It looks like you were trying this, but be sure to remember that it should be goombaHealthPoints>0, and not the other way around. |
Author: | ahmhum [ Sat Jun 07, 2008 4:29 pm ] |
Post subject: | Re: helpppppp!!!! |
that did help me thnx |
Author: | ahmhum [ Sat Jun 07, 2008 10:22 pm ] |
Post subject: | RE:helpppppp!!!! |
ok now i want the question to show up after he punches, kicks, or bombs the villian in the first try so he can do something else again punch, kick or bomb |
Author: | ahmhum [ Sun Jun 08, 2008 11:34 am ] |
Post subject: | RE:helpppppp!!!! |
any1 |
Author: | ahmhum [ Sun Jun 08, 2008 12:11 pm ] |
Post subject: | RE:helpppppp!!!! |
ok now i want the question to show up after he punches, kicks, or bombs the villian in the first try so he can do something else again punch, kick or bomb int 2nd try and on and on until the villians hp hits 0 |
Author: | Saad [ Sun Jun 08, 2008 12:31 pm ] |
Post subject: | Re: helpppppp!!!! |
To remphasize Aziz's points. Follow the rules. There was no need to reply 4 times. People aren't always online, you need to have some patience with your questions. |
Author: | ahmhum [ Sun Jun 08, 2008 12:41 pm ] |
Post subject: | RE:helpppppp!!!! |
people should reply only when they know the answer |
Author: | ahmhum [ Sun Jun 08, 2008 12:42 pm ] |
Post subject: | RE:helpppppp!!!! |
not to state the obvious |
Author: | michaelp [ Sun Jun 08, 2008 1:03 pm ] |
Post subject: | RE:helpppppp!!!! |
And you should not use 2 post to put something that could have easily be put in one. They are only trying to help you get more and better answers. And don't triple post. |
Author: | apomb [ Sun Jun 08, 2008 1:05 pm ] |
Post subject: | RE:helpppppp!!!! |
you just blew my mind ahmhum. |
Author: | ahmhum [ Sun Jun 08, 2008 4:32 pm ] |
Post subject: | RE:helpppppp!!!! |
ok i would like to apologize for wat i said earlier i shouldn't have said it, i m truly sorry i hope u all forgive me:) |
Author: | HellblazerX [ Sun Jun 08, 2008 7:52 pm ] |
Post subject: | RE:helpppppp!!!! |
Just put the portion of code that displays the questions and gets the input from the user inside the loop. |
Author: | jeffgreco13 [ Mon Jun 09, 2008 8:40 am ] | ||
Post subject: | Re: helpppppp!!!! | ||
As far as i can tell this program is quite simple in the fact that its a simple back and fourth fighting game right? Mario gets a turn, then goomba gets a turn. There's probably about 100 ways to do this, and judging by your code structure you probably don't care for it to be too clean. So like Hellblazer said you have to put the chunk of code that requests input into a loop. May I suggest, putting ALL of those if statements into say a fightScene() method.
Then you can put fightScene(fighting); in a loop with all of the prompting text. To distinguish who's turn it is throw a counter in the loop, odd numbers are one guys turn evens are the other guys turn. BTW that code won't compile. You have to edit it, that's just a starter for you. P.s consider yourself lucky people even bothered to answer on this, because while this is an unbelievable community that loves to help people there are some simple rules that the administration requests you follow in order to keep these forums as effective as possible. And when someone points out your mistakes, put ur tail between ur legs and take it. Don't snap back. |
Author: | Aziz [ Mon Jun 09, 2008 9:12 am ] |
Post subject: | RE:helpppppp!!!! |
"the administration requests" Somehow "administration" doesn't fit Dan or Tony. I think "admin" has become a separate word rather than a shortform. :O "requests" is also not properly describing it ![]() |
Author: | jeffgreco13 [ Mon Jun 09, 2008 10:28 am ] |
Post subject: | Re: helpppppp!!!! |
Haha just trying to make seem as nice as possible... Obey the rules or f*** off!! Better? LOL |
Author: | Aziz [ Mon Jun 09, 2008 11:12 am ] |
Post subject: | RE:helpppppp!!!! |
Not so harsh. Most people (when they're feeling swell) give a couple chances ![]() |
Author: | jeffgreco13 [ Mon Jun 09, 2008 11:28 am ] |
Post subject: | Re: helpppppp!!!! |
dually noted... alright enough on this topic before we get smashed for spamming. |
Author: | ahmhum [ Mon Jun 09, 2008 6:08 pm ] |
Post subject: | RE:helpppppp!!!! |
is there a way to have two while statements in this because i want the game to shutdown after either mario or goomba hits 0 n right now i can only do goomba if i put mario in it doesn't work i hope wat i said makes sense |
Author: | OneOffDriveByPoster [ Mon Jun 09, 2008 6:18 pm ] |
Post subject: | Re: RE:helpppppp!!!! |
ahmhum @ Mon Jun 09, 2008 6:08 pm wrote: is there a way to have two while statements in this
While statements depend on a condition. If your condition deals with both cases (using Boolean operators such as AND and OR), then you can handle both cases with one while-loop.because i want the game to shutdown after either mario or goomba hits 0 n right now i can only do goomba if i put mario in it doesn't work i hope wat i said makes sense |
Author: | ahmhum [ Mon Jun 09, 2008 9:08 pm ] |
Post subject: | RE:helpppppp!!!! |
i did this while (goombaHealthPoints>=0||marioHealthPoints>=0) doesn't work though |
Author: | ahmhum [ Mon Jun 09, 2008 9:10 pm ] |
Post subject: | RE:helpppppp!!!! |
wait srry it was this while (goombaHealthPoints<=0||marioHealthPoints<=0) it closes b4 hp reaches 0 or a negative number for this one |
Author: | jeffgreco13 [ Tue Jun 10, 2008 8:16 am ] | ||
Post subject: | Re: helpppppp!!!! | ||
That should be your code. Place the fight scene in that loop. It will run coninuously until either of their health is less than or equal to 0 |
Author: | ahmhum [ Thu Jun 12, 2008 4:15 pm ] |
Post subject: | RE:helpppppp!!!! |
ok right now the problem is tht i can't get the punch kick n bomb to work again so suppose i punch kick or bomb the first try when i try the 2nd time n i choose another option different from the option b4 it repeats the same option previously used until hp hits 0, so if i choose star it keeps repeating to be star until hp is 0 |
Author: | HellblazerX [ Thu Jun 12, 2008 6:00 pm ] |
Post subject: | RE:helpppppp!!!! |
It's most likely you forgot to change the userInput variable inside your loop. |
Author: | ahmhum [ Thu Jun 12, 2008 7:13 pm ] |
Post subject: | Re: helpppppp!!!! |
no thts not it let me send the program |
Author: | HellblazerX [ Thu Jun 12, 2008 8:27 pm ] | ||
Post subject: | Re: helpppppp!!!! | ||
In your method marioFightSceneStarPower (int x, int y) and marioFightSceneMushroomBombPower (int x, int y) methods, you forgot to change the value of your fightning variable. In other words you forgot this:
|
Author: | ahmhum [ Thu Jun 12, 2008 9:09 pm ] |
Post subject: | RE:helpppppp!!!! |
wat i have that man it still doesn't work i rechecked |
Author: | jeffgreco13 [ Fri Jun 13, 2008 8:07 am ] |
Post subject: | Re: helpppppp!!!! |
so your saying that each time thru the loop its adding the new attach onto the previous ones? that just means that the variable you're setting isnt being cleared each time thru the loop |