random spawn and set number

Get help using Construct 2

Post » Sat May 30, 2015 6:42 am

so i want to make a tree grow and when its grown i wanna harvest it, i wanna be able to click and destroy the tree and then spawn at random point the number of trees i destroyd, for exemple, i destroy 2 trees i spawn 2 trees, but whats happening is , i destroy 1 tree it spawns on all spawn points. i want to be able to control how many trees i ahve in the game so i tryed adding treecount to the sprite variable but i cant seem to understand how it works, can someone help me and maybe send me a capx to understand better
B
5
S
1
Posts: 77
Reputation: 754

Post » Sat May 30, 2015 7:53 am

I''m not quite sure what you want here. Are you saying you want to destroy your tree and spawn another one when you destroy it, or do you want to spawn one at a later time ?
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sat May 30, 2015 8:04 am

well, i think you have to save the number of trees you've destroyed in a variable
set an ammount of time (or ticks) for the new tree to sprout
set sprout locations
pick a randmo sproutlocation instance
sprout! (create object(tree) instance at sprout location instance which was randomly picked)
substract 1 from the trees to sprout/spawn
be awesome!
harvest
destroy that mofo
add 1 to the trees to be spawned

hope it helps
B
7
S
1
Posts: 28
Reputation: 481

Post » Sat May 30, 2015 8:50 am

paulscottrobson wrote:I''m not quite sure what you want here. Are you saying you want to destroy your tree and spawn another one when you destroy it, or do you want to spawn one at a later time ?

yes i want to destroy one tree and right after that another one spawns, also appart from that i want to be able to plant my own tree... how can i say this... i want 2 trees to always spawn when i destroy them, and to be able to plant more trees if i want to,you getting this?
B
5
S
1
Posts: 77
Reputation: 754

Post » Sat May 30, 2015 9:03 am

BelphegorH wrote:well, i think you have to save the number of trees you've destroyed in a variable
set an ammount of time (or ticks) for the new tree to sprout
set sprout locations
pick a randmo sproutlocation instance
sprout! (create object(tree) instance at sprout location instance which was randomly picked)
substract 1 from the trees to sprout/spawn
be awesome!
harvest
destroy that mofo
add 1 to the trees to be spawned

hope it helps


hmm i dont get it, i get the concept but i dont know the tools very well from construct.. maybe in more detail? or with a capx.. thanks anyways
B
5
S
1
Posts: 77
Reputation: 754

Post » Sat May 30, 2015 3:15 pm

Something like this http://www.viewtalker.co.uk/c2/Trees.capx - maintains a count of how many trees there are and makes them to order at a random choice from a spawning point ?

NB: It would be really handy if I could upload files rather than FTP them ....
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sat May 30, 2015 10:31 pm

ok, its something like

-0--0--0--0--0--0--0
-0--0--0--0--0--0--0
-0--0--0--0--0--0--0
-0--0--0--0--0--0--0

all the 0's are the spawnpoints, which are instances of an object (a sprite for example)
you have to Pick Random Instance of Sprout Point, and when you do, destroy the SproutPoint
then, when you destroy the tree, create a SproutPoint where it was
when you destroy the three, set a global Variable with the numbers of threes you've destroyed

Tree ~double click then
Create Objet Sprout Point @ tree.x tree.y tree.layer
destroy tree
set TreesToSprout = TreesToSprout +1

every N ticks (where N is the numer of time elapsed)
pick random SproutPoint
create object Tree @SproutPoint.x SproutPoint.Y SproutPoint.layer
destroy SproutPoint
set TreesToSprout = TreesTo Sprout -1

its the most simple i can explain, hope you got it
B
7
S
1
Posts: 28
Reputation: 481

Post » Sun May 31, 2015 4:58 am

paulscottrobson wrote:Something like this http://www.viewtalker.co.uk/c2/Trees.capx - maintains a count of how many trees there are and makes them to order at a random choice from a spawning point ?

NB: It would be really handy if I could upload files rather than FTP them ....

yes! this is it, thanks a bunch!
i can do something with this now, really thanksfull
B
5
S
1
Posts: 77
Reputation: 754

Post » Tue Jun 02, 2015 1:44 am

kionysan wrote:
paulscottrobson wrote:Something like this http://www.viewtalker.co.uk/c2/Trees.capx - maintains a count of how many trees there are and makes them to order at a random choice from a spawning point ?

NB: It would be really handy if I could upload files rather than FTP them ....

yes! this is it, thanks a bunch!
i can do something with this now, really thanksfull



btw it seems like sometimes it spawns on the same spot, how do i make it so it doesnt spawn on the same place ?
B
5
S
1
Posts: 77
Reputation: 754

Post » Tue Jun 02, 2015 7:38 am

Can't try it at the moment, but could do it with tree collides with tree - don't know if this works,if it does reposition it,or in my example deleting the tree will make it appear elsewhere, also this will help balance trees at sdpawn points
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests