Jump to content
  • Advertisement
Sign in to follow this  

Can anyone spot the problem?

This topic is 4808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if(bulletCreated) { if(shipBullet.bulletMissed()) { bulletCreated = false; updatePlayerScore(-100); } } why after a bullet has missed would 100 be taken off once and then once again when fire is next pressed if this is the only place that 100 is ever taken off the score? thanks to whoever can solve this, it is part of my mainloop in a game

Share this post


Link to post
Share on other sites
Advertisement
It seems like after you create that second bullet, shipBullet.bulletMissed() is still returning true. Is there something you need to do to update the value of bulletMissed? eg:


if(bulletCreated)
{
if(shipBullet.getBulletMissed())
{
bulletCreated = false;
updatePlayerScore(-100);
shipBullet.setBulletMissed(false);
}
}


Then of course setBulletMissed would have to affect the result of getBulletMissed...

Share this post


Link to post
Share on other sites
I can't exactly see what is wrong here, but I think you need to post more of your code. From what you've posted its hard to tell what is going on when the code exectutes.

-Limb

Share this post


Link to post
Share on other sites
if(bulletCreated)
{
if(hit an alien)
{
bulletCreated = false;
updatePlayerScore(1000);
}
if(shipBullet.bulletMissed())
{
bulletCreated = false;
updatePlayerScore(-100);
}
}

public void updatePlayerScore(int add)
{
playerScore += add;
if(playerScore > highScore) highScore = playerScore;
}

also have:

if(!fireKeyPressed) spaceReleased = true;
if(fireKeyPressed&&(!playerDead)&&spaceReleased&& !soundManager.isPlayingSound()&&(!bulletCreated))
{
boolean firePressed = true;
spaceReleased = false;
if(firePressed)
{
tryToFire();
}
}

and:

public void tryToFire()
{
shipBullet.renderBullet();
bulletCreated = true;
}

and that is all that is involved with it really!

Share this post


Link to post
Share on other sites
What compiler are you using?
Why dont you use the debugger and watch the code run. That is a 100% sure way to find out what is going on.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!