This site requires JavaScript, please enable it in your browser!
Greenfoot back
Sebastiano
Sebastiano wrote ...

2019/12/29

How to add a score that is more than 1

Sebastiano Sebastiano

2019/12/29

#
I am creating Space invaders and i want it so that when i hit an invader i get 10 points however when i hit a UFO i get 100 points however i just have score ++; //this only adds one how can i make it add a certain amount over 1
danpost danpost

2019/12/29

#
Sebastiano wrote...
I am creating Space invaders and i want it so that when i hit an invader i get 10 points however when i hit a UFO i get 100 points however i just have score ++; //this only adds one how can i make it add a certain amount over 1
You can use, for example:
int scoredAmount = 10;
score += scoredAmount;
or just
score += 10;
which is equivalent to
score = score+10;
Out of curiosity, in what class is the given line placed?
Sebastiano Sebastiano

2019/12/30

#
Thankyou @danpost , helped alot however i have just published my space invaders game however the run button acts as if it is the act button and only executes the instruction once
danpost danpost

2019/12/30

#
Sebastiano wrote...
Thankyou @danpost , helped alot however i have just published my space invaders game however the run button acts as if it is the act button and only executes the instruction once
Re-publish it again. This time, check the Publish source code check box.
You need to login to post a reply.