# How do I count solved

Get help using Construct 2

### » Mon Feb 19, 2018 6:49 pm

On start of layout i count all enemies in layout and add to global variable
for example globalvariable Oponents = 13

for example when i kill 10 enemies
counter should display 76.92% killed

how do that?
Last edited by IGDev on Mon Feb 26, 2018 8:24 am, edited 2 times in total.
B
26
S
8
Posts: 227
Reputation: 2,222

### » Mon Feb 19, 2018 7:07 pm

str(round(EnemiesKilled/Opponents*10000)/100)&"%"

Round(x *100)/100 is a good trick to have only two decimals left
B
6
Posts: 43
Reputation: 347

### » Mon Feb 19, 2018 7:20 pm

works! thank you so much

but sprite font dont display '%' ;/

Semoreh wrote:Make your counter display :
str(round(EnemiesKilled/Opponents*10000)/100)&"%"

Round(x *100)/100 is a good trick to have only two decimals left
B
26
S
8
Posts: 227
Reputation: 2,222

### » Mon Feb 19, 2018 7:32 pm

Semoreh wrote:Round(x *100)/100 is a good trick to have only two decimals left

Where i should put that code to have only two decimals?
B
26
S
8
Posts: 227
Reputation: 2,222

### » Mon Feb 19, 2018 7:33 pm

IGDev wrote:works! thank you so much

but sprite font dont display '%' ;/

you can edite the spritefont on a character that you don't use, here i have edited the / into %, so if you have to call the % you have to type /
"I'm a developer not a magician!!"
B
13
S
7
G
2
Posts: 130
Reputation: 2,141

### » Mon Feb 19, 2018 7:47 pm

IGDev wrote:Where i should put that code to have only two decimals?

It was just to explain you how it worked.

Just copy that :
str(round(EnemiesKilled/Opponents*10000)/100)&"%"

And edit the SpriteFont like RetroInsight said.
B
6
Posts: 43
Reputation: 347

### » Mon Feb 19, 2018 7:56 pm

Semoreh wrote:
IGDev wrote:
Just copy that :
str(round(EnemiesKilled/Opponents*10000)/100)&"%"

.

All works fine, but its possible to round up to receive 77% not 76.92% like before?

Sprite font need lot of space to display each character so if less its better to display
B
26
S
8
Posts: 227
Reputation: 2,222

### » Mon Feb 19, 2018 8:08 pm

Yup

str(round(EnemiesKilled/Opponents*100))&"%"
B
6
Posts: 43
Reputation: 347

### » Wed Feb 21, 2018 12:56 pm

Thank you Semoreh!
B
4
Posts: 1
Reputation: 204