# math trick needed

0 favourites
• 6 posts
From the Asset Store
Aliens are invading our planet! Solve the math question, and attack the alien with your laser. Covers addition, subtract
• Hi my project have text object to display sum of variables

Global variable called 'percent'

Player sprite have two instance variables:

Strenght physical 'SP'

Strenghth mental 'SM'

NEXT

Text object should display global variable 'percent' (SP + SM in percents %)

Important thing

when SP is X and SM is X

on start of layout Text object should display this sum as 100%

• On start:

set percent to int(100*(SP+SM)/(2*X))

set text to percent&"%"

On any trigger event where SP or SM change:

set percent to int(100*(SP+SM)/(2*X))

set text to percent&"%"

This assumes that X is the maximum value that SP and SM can have.

• On start:

set percent to int(100*(SP+SM)/(2*X))

What is 'X' in your formula?

(2*X)) ?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• X is the maximum value of SP and SM e.g.

If SP and SM can each have a maximum value of 150 each then the equation would be:

int(100*(SP+SM)/300)

ideally you would hold those max values in variables, so the equation would be:

int(100*(SP+SM)/(SPmax+SMmax))

• X is the maximum value of SP and SM e.g.

If SP and SM can each have a maximum value of 150 each then the equation would be:

int(100*(SP+SM)/300)

ideally you would hold those max values in variables, so the equation would be:

int(100*(SP+SM)/(SPmax+SMmax))

Text object show me on preview

'Infinity %'

• Here's an example:

https://www.dropbox.com/s/ss9xlbwj1rmqv ... .capx?dl=0

Left or right click on the bars to change the values.

• 6 posts