How do I make Time score and throw object ?

0 favourites
  • 5 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi

    I know there is a tutorial for high score but what i want to do is to make a Time Score. counting the seconds and then show it as a high score (( who beat the enemy faster become in the top )) also he can write his name near it.

    and about the second problem. I want to make object throw things random for a small destiny (( see the pic that i upload it ))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On start of layout- Every x seconds (1) - Add 1 to variable (time). Then simply text box "Total Time: "&time.

    Although there is probably an internal way to grab time since start of layout... anyone?

    I am assuming on the second part you mean throw objects a random distance from a center point?

    You could spawn as many objects (even random amounts) at the center object that you want with bullet behaviors in them... set their bullet speed to 100, bullet angle to random(360), wait random(0.25,3), bullet stop.

    You could either set them visible when they spawn or after they stop... whatever effect your after.

    If you want it less random, more like the picture you could use choose instead, ie. random(choose 45,90,110,234,350) to have better control of what angles it can send objects in...

  • [quote:14kqrsq5]On start of layout- Every x seconds (1) - Add 1 to variable (time). Then simply text box "Total Time: "&time.

    i didn't understand the last part ? when i add the text box to the score layer near the time can the payer write his name and save it and every one on the world can see it ? this game is not multilayer.

    [quote:14kqrsq5]I am assuming on the second part you mean throw objects a random distance from a center point?

    You could spawn as many objects (even random amounts) at the center object that you want with bullet behaviors in them... set their bullet speed to 100, bullet angle to random(360), wait random(0.25,3), bullet stop.

    You could either set them visible when they spawn or after they stop... whatever effect your after.

    If you want it less random, more like the picture you could use choose instead, ie. random(choose 45,90,110,234,350) to have better control of what angles it can send objects in...

    I do it. now it's throw in random angle and then stop but it get back to move

    here is what happening

    Evey 10 second this object appear and throw things. this things move in different angle and stop. now the problem is when the next 10 second come the object appear and throw new things but also the old things moving again ? so how to stop it for ever

  • [quote:3opdfsg1]didn't understand the last part ? when i add the text box to the score layer near the time can the payer write his name and save it and every one on the world can see it ? this game is not multilayer.

    Not multilayer! Even free version gives you 3 layers.. that is like making apple pie without a crust...

    OK, what I meant by "Then simply text box "Total Time: "&time" was anywhere you needed to display the "time" variable you were filling with the time-since-start number... In order to do what you are wanting you would need to put a text box like I show ("Total Time: "&time) [The "Total Time" can be changed to anything you want between the ""] You would then need a blank type box object beside your text object if you want them to write their name. HOWEVER, unless you are storing both the name and time value in webstorage or some other method the data will be gone as soon as they close the game.

    I have done a tutorial on webstorage if it helps (https://www.scirra.com/tutorials/1152/introduction-to-webstorage-simplified).

    A better way would be to have to player input their name somewhere before the game starts and save it to a name variable, then at finish display both variables like so: "Awsome, "&name "you lasted "&time "seconds!" and then store these to a persistent website location (several tutorials out there for this type thing).

    [quote:3opdfsg1]here is what happening

    Evey 10 second this object appear and throw things. this things move in different angle and stop. now the problem is when the next 10 second come the object appear and throw new things but also the old things moving again ? so how to stop it for ever

    This is happening because Construct2 doesn't know which instance of the object you are wanting to perform actions on. You will need to "pick" the newly spawned objects and not the old ones. In order to "pick" an instance it must be referenced in the Conditions portion of the event.

    An easy way off the top of my head is to put an Instance variable inside the spawned object and say call it "finished = 0", now right after your stop action after they have spawned and run their course you would add a set Instance variable action to finished=1. Now in your initial spawning Conditions you would add a (object type)-instance variable finished (doesnot) = 1 (or either = 0 your preference).

  • [quote:3slv3ahi]Not multilayer! Even free version gives you 3 layers.. that is like making apple pie without a crust...

    OK, what I meant by "Then simply text box "Total Time: "&time" was anywhere you needed to display the "time" variable you were filling with the time-since-start number... In order to do what you are wanting you would need to put a text box like I show ("Total Time: "&time) [The "Total Time" can be changed to anything you want between the ""] You would then need a blank type box object beside your text object if you want them to write their name. HOWEVER, unless you are storing both the name and time value in webstorage or some other method the data will be gone as soon as they close the game.

    I have done a tutorial on webstorage if it helps ().

    A better way would be to have to player input their name somewhere before the game starts and save it to a name variable, then at finish display both variables like so: "Awsome, "&name "you lasted "&time "seconds!" and then store these to a persistent website location (several tutorials out there for this type thing).

    This is what i exactly thinking for now. I will do my best to make it in my game

    [quote:3slv3ahi]This is happening because Construct2 doesn't know which instance of the object you are wanting to perform actions on. You will need to "pick" the newly spawned objects and not the old ones. In order to "pick" an instance it must be referenced in the Conditions portion of the event.

    An easy way off the top of my head is to put an Instance variable inside the spawned object and say call it "finished = 0", now right after your stop action after they have spawned and run their course you would add a set Instance variable action to finished=1. Now in your initial spawning Conditions you would add a (object type)-instance variable finished (doesnot) = 1 (or either = 0 your preference).

    Now i solve the time problem but still i have problem with throwing object. now i change my mind i want to throw different kind of objects with that same before conditions. I think Array will solve my issue but i don't know how to use it. do you know how ?

    Thank you for the information and all details that you wrote it for me. it's really helped me and i am sure that many other will see it helpful

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