how to make coins each time you add built

  • 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 a�ada 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

    <img src="http://laneura.usuarios.tvalmansa.com/scirra/6.jpg" border="0" />

    <img src="http://laneura.usuarios.tvalmansa.com/scirra/7.jpg" border="0" />

  • Do you mean like this?

    System: Every 10 seconds
    -> Add houses to coins

    If you have X houses, it will add X coins every 10 seconds.

  • 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

  • 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...

  • 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 !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)

    <img src="http://laneura.usuarios.tvalmansa.com/scirra/8.jpg" border="0" />

    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 a�ada

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

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

    (houses*5)+(flats*40)

  • 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

  • yes

    I hope to get finished a version 0.1 xdxd

    and upload it to be seen

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)