every 100 Coins = 1 life (mario bros)

Get help using Construct 2

Post » Fri Feb 19, 2016 2:44 am

Hello :D

English

Hello good, I wanted to know how I can perform the command every 100 coins or points 1 life is added, if they could help me thanks and regards

Español

Hola buenas, queria saber como puedo realizar el comando de que cada 100 monedas o puntos se agregue 1 vida, si me podrian ayudar gracias y saludos

:)
B
20
S
6
G
1
Posts: 50
Reputation: 1,867

Post » Fri Feb 19, 2016 2:48 am

I assume your coins and life are already variables.

Condition
System - Compare two values: CoinsVariable = 100

Action
Add 1 to LifeVariable
Set CoinsVariable to 0
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Fri Feb 19, 2016 10:30 am

I guess you already have a variable for coins. What you have to do now, is this: one way is to use modulo. I think that's the simplest, because you don't need any additional variables.
Add an event:
System|Compare two values: Coin%100 = 0 (and) Trigger once while true -> System|Add 1 to Life

(Assuming Coin is the variable for coins and Life for lifes)
https://www.dropbox.com/s/yyaxf6pw0emqt ... o.jpg?dl=0

Maybe you may want to add another condition: Coin /= 0, so 1 life isn't added on start when you have 0 coins.
https://www.dropbox.com/s/gyhd4vxhz3u6y ... 2.jpg?dl=0


What is modulo?
Modulo is actually the remain of dividing. In C2, it is represented with percent sign (%).
Example:
50%100 = 50 (50/100 = 0, 50 remains)
100%100 = 0 (100/100 = 1, 0 remains)
200%100 = 0 (200/100 = 2, 0 remains)
B
32
S
7
G
4
Posts: 398
Reputation: 4,591

Post » Sat Feb 20, 2016 7:10 pm

Thank you very much friend, but finished before yesterday, a friend helped me a tutorial, but equal to I made something similar oosyrag. :D


-------------------------------------------------------------------------------------
Add variable global: variable number|Extras = 100

And In Add Event: System|Monedas = Extras | system add 1 life -->(compare variable: monedas = Extras)
| system add 100 extras
-------------------------------------------------------------------------------------

and thereby completing 100 coins system adds 1 life and 100 extras, so to reach 200 coins 1 life and 100 extras, and so on is added: D Thanks alike, if it serves this would be great :D


Thank You Friends :D
Last edited by Totimundo on Sat Feb 20, 2016 7:20 pm, edited 1 time in total.
B
20
S
6
G
1
Posts: 50
Reputation: 1,867

Post » Sat Feb 20, 2016 7:13 pm

See also, as one can reset a global variable, and no reset all?
B
20
S
6
G
1
Posts: 50
Reputation: 1,867

Post » Sun Feb 21, 2016 10:17 pm

Totimundo wrote:See also, as one can reset a global variable, and no reset all?

I guess the only way to do that is System|Set value to 0 (or whatever you have at start).
B
32
S
7
G
4
Posts: 398
Reputation: 4,591

Post » Mon Feb 22, 2016 6:34 pm

thank you friend grigrizljac and the others, greeting
B
20
S
6
G
1
Posts: 50
Reputation: 1,867


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests