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

Username:   Password: 
 RegisterRegister   
 helpppppp!!!!
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jeffgreco13




PostPosted: 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.

Java:

public static String fightScene(int userInput)
{

if(userInput==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(userInput==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(userInput==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 (userInput==-1)
{
//create and close method.
d.close();
c.close();
}

if(-1>userInput||userInput==0||userInput>3)
{
//Call upon invalid entry.
invalidEntry(xP, yP);
//Creating the loop.
marioFightSceneBombMushroomPower(x, y, xP, yP);
}
return fightSceneText;
}


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.
Sponsor
Sponsor
Sponsor
sponsor
Aziz




PostPosted: 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 Wink
jeffgreco13




PostPosted: 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
Aziz




PostPosted: 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 Smile thus why OP has gotten help so far.
jeffgreco13




PostPosted: Mon Jun 09, 2008 11:28 am   Post subject: Re: helpppppp!!!!

dually noted... alright enough on this topic before we get smashed for spamming.
ahmhum




PostPosted: 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
OneOffDriveByPoster




PostPosted: 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
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
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.
ahmhum




PostPosted: Mon Jun 09, 2008 9:08 pm   Post subject: RE:helpppppp!!!!

i did this
while (goombaHealthPoints>=0||marioHealthPoints>=0)

doesn't work though
Sponsor
Sponsor
Sponsor
sponsor
ahmhum




PostPosted: 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
jeffgreco13




PostPosted: Tue Jun 10, 2008 8:16 am   Post subject: Re: helpppppp!!!!

code:
while (marioHP > 0 && goombaHP > 0)


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
ahmhum




PostPosted: 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
HellblazerX




PostPosted: 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.
ahmhum




PostPosted: Thu Jun 12, 2008 7:13 pm   Post subject: Re: helpppppp!!!!

no thts not it
let me send the program



MarioChoicesAB.java
 Description:

Download
 Filename:  MarioChoicesAB.java
 Filesize:  56.32 KB
 Downloaded:  96 Time(s)

HellblazerX




PostPosted: 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:
Java:
try {
     fighting= Integer.parseInt(input); 
}
catch (NumberFormatException e) {
     //User selects defaults to invalid entry.
}       
ahmhum




PostPosted: Thu Jun 12, 2008 9:09 pm   Post subject: RE:helpppppp!!!!

wat
i have that man it still doesn't work
i rechecked
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 31 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: