how to make coins each time you add built

Get help using Construct 2

Post » Wed Jun 13, 2012 8:40 pm

Buenas he conseguido hacer en el juego que me sume coins si hago una casa, pero no se hacer para que me sume coins cada vez que construyo una casa nueva sin tener que poner 1 evento para cada vez que hago una casa que me aada los coins que corresponden.

system houses=1     ------------------ system add 1 to coins
system every 10.0seconds

system houses=2     ------------------ system add 2 to coins
system every 10.0seconds

adjunto las imagenes para que lo entendais mejor a ver si me podeis ayudar

Good I managed to do in the game I add coins if I make a house but do not add coins to me every time I build a new house without having to put an event for each time I make a house that I add the coins which they correspond.

system houses=1     ------------------ system add 1 to coins
system every 10.0seconds

system houses=2     ------------------ system add 2 to coins
system every 10.0seconds

attached images to understand it better and see if you can help me


B
10
S
1
Posts: 9
Reputation: 960

Post » Wed Jun 13, 2012 9:56 pm

Do you mean like this?

[code]System: Every 10 seconds
-> Add houses to coins[/code]
If you have X houses, it will add X coins every 10 seconds.Nimtrix2012-06-13 21:57:04
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Wed Jun 13, 2012 10:26 pm

yes

but x coins will be for example

1 house-------1coins------every 10 seconds

2 houses------2coins------every 10 seconds

3 houses -----3coins------every 10 seconds

so on


with other building

1 flat-------10coins------every 10 seconds

2 flats------20coins------every 10 seconds

3 flats -----30coins------every 10 seconds

so on

as it would have to do? not how


javiusdey2012-06-13 22:33:08
B
10
S
1
Posts: 9
Reputation: 960

Post » Thu Jun 14, 2012 2:06 am

i'm not sure about this but you can make a global variable for example "builds" and when you built a house or flat it add the point to the global for example for example you built 2 houses,1flat so 1+1+10 so the global will be 12point then every 10seconds add "build" to cions...

B
45
S
15
G
6
Posts: 795
Reputation: 11,935

Post » Thu Jun 14, 2012 2:35 am

It's perhaps a little bit more difficult ... do you really want to add coins every 10 secs or add for example 1 coin for 1 house 10 seconds after "this" house have been built and then 10 seconds after etc ... ?

In this last case seems the better way is to use instance variables for objet "house" and "flat" and use this instance variables as timers for each element built ...

I saw a recent post about someone requesting help to make ennemy fire X seconds after "spawn" and not all at the same time and seems someone give him a good commented answer ... 10 seconds i'm searching ;-p

Found ! answer comes from "R0J0hound"

Consider rhouse and rflat as sprite objects ... (in fact here "rhouse=realhouse") you have many instances of rhouse built and many instances of rflat too ... each objet have a instance variable called "timer" set to 10 by default (10 seconds) .... also a global variable "coins" to count "coins" ;-p

on every tick

--- For each rhouse
-------- rhouse : timer > 0
----------- rhouse : Subtract dt from timer
-------- rhouse : timer <= 0
------------ add 1 to coins
-------------rhouse : Set timer to 10

--- For each rflat
-------- rflat : timer > 0
----------- rflat : Subtract dt from timer
-------- rflat : timer <= 0
------------ add 10 to coin
-------------rflat : Set timer to 10

and so on for each type of built element ...

C2 is very powerful ! ... you can also create a instance variable to manage delay after which a element begin to get old and make earn less coin or will be destroyed !

But perhaps the more interesting feature is that rhouse timer and rflat timer can to set to different values ...

-------------

But if you only wanted a simple 10 seconds timer for all elements managed with the same is simply

--- Every 10 seconds
------- system : add houses + (flats*10) to coins

(where houses flats and coins are global variables)

simply add "+ (numberofnewconstructtype * newconstructtypegivehowmanycoineach10)" for each type of construct you will have to this formula

-------------

Don't be afraid by number of events spend to release the heart of your game ... because this part will make your game interesting or not .... your don't have to repeat "on every tick" or "on every 10 seconds" each time spending 1 event for nothing, try grouping events using the same condition.

Good sim city like project ! ;-p

ENjoy !naelian2012-06-14 05:15:55
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Thu Jun 14, 2012 2:09 pm

I'll stay for now with the second option
it seems easier for me I'm newbie
I have tested and working properly! you're a genius!
not think it was so easy
thank you very much
I put the example of the system add

1 house-------5coins------every 10 seconds
1 flat-----------40coins-----every 10 seconds

(houses*5)+(flats*40)



Me quedare de momento con la segunda opcion
que parece mas facil para mi que soy novato

la he probado y funciona correctamente!!! eres un genio!!!

no pensaba que era tan facil
muchas gracias

Dejo el ejemplo de que el sistema aada

1 house-------5coins------cada 10 seconds
1 flat-----------40coins-----cada 10 seconds

(houses*5)+(flats*40)
B
10
S
1
Posts: 9
Reputation: 960

Post » Fri Jun 15, 2012 9:35 pm

Good !

Yes i understand the second option will be our choice ;-p and it's a good choice for a beginner.

But when your game will be finished you will be a "pro" ;-p so try creating a second version using the first option ... sure it will be more interesting for players and give you a lot of way and new ideas to improve your game.

Don't forget to give us a link to test your game when finished ok ?

So waiting for you soon in "Your creations" part of the forum ;-p
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Sun Jun 17, 2012 9:56 am

yes
I hope to get finished a version 0.1 xdxd
and upload it to be seen
B
10
S
1
Posts: 9
Reputation: 960


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, michaelverdi and 18 guests