So I am currently making this game for a school project and I wanted to increase my score by increments of 1000 because one of the objectives of my game is to collect money. I wanted the score to increase by 1000 because the money is worth $1000. Right now with my code it increases by 1.
If there is any way of doing this?
Also, I realised that the score doesn't show until I collect money. Is there a way of showing the score before I collect any money? eg. Player 1 Score: $0
Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public class Player_1 extends Actor { private int score; public void act() { collectMoney(); } public void increaseScore() { score++; showStatus(); } public void collectMoney() { if (isTouching(Money. class )) { removeTouching(Money. class ); increaseScore(); World world = getWorld(); world.addObject( new Money(), Greenfoot.getRandomNumber( 1690 ), Greenfoot.getRandomNumber( 900 )); } } public void showStatus() { getWorld().showText( "Player 1 Score : $" +score, 70 , 560 ); getWorld().showText( "Player 1 Death : " +score2, 70 , 540 ); } |