How do I can i use a random spawn?

Just started using Construct 2? Post your questions here

Post » Thu Aug 14, 2014 8:18 am

Hi :)
Im not rly good at English so forgive me.

Im just Learning construct2 to creat a basic video games for a young person. It's a labyrinth where he'll have to get treasure. When he catch one, i'd like it to spawn on another random place (on the player way, not in a wall) but i don't understand how to make it.

Actually, i just tried to creat 10 sprite wich will be join by the treasure one after one but always in the same order...Just boring!

Thanks for your help
B
2
Posts: 3
Reputation: 150

Post » Thu Aug 14, 2014 12:00 pm

Do you want to spawn them absolutely anywhere in the labyrinth or a list of spawn points would do?

How are you creating your labyrinth? Is it tile-based? If it is, you can just select a random floor tile and spawn the treasure at its position.

If you give us a bit more information to work with or a capx, it would help to find the best solution.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Thu Aug 14, 2014 7:38 pm

Hi

I need a list of spawn because the treasure shouldn't be able to spawn in a wall.

Yes it is tile-based if you mean i use a grid.

The spawn even sheet should be based on the treasure and not in a tile isn't it?
B
2
Posts: 3
Reputation: 150

Post » Thu Aug 14, 2014 11:27 pm

This could be an option:

If you have a list you could use the choose() expression to decide what place should be picked

set variable spawnplace to choose(1,2,3,4,5,6,7,8,9)

if spawnplace =1 spawn at x=whatever, y=whatever
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 15, 2014 1:42 pm

If i understood well, i should creat a sprite in each square named 1,2,3....

Then i've to add a variable but i don't know where i should write choose(1,2,3..)

And then i've to set the x and y of each spawnplace

I just descover the interface so i don't rly know what to use and where. That's a real roblem :D
B
2
Posts: 3
Reputation: 150

Post » Sat Aug 16, 2014 9:33 am

i also have some trouble with my random spawning system.
im using this way but it spawns the enemies even in the middle of the layout and in the corners... dunno why
Image
the result of this code is :
Image
and yes those pink squares are my spawners
B
27
S
7
G
3
Posts: 300
Reputation: 4,573

Post » Sat Aug 16, 2014 9:41 am

@burningcake

Your code makes it possible to spawn at x=spawner1.x y=spawner3.y, so the result is as expected..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Aug 16, 2014 10:01 am

LittleStain wrote:@burningcake

Your code makes it possible to spawn at x=spawner1.x y=spawner3.y, so the result is as expected..


how to change that then?
B
27
S
7
G
3
Posts: 300
Reputation: 4,573

Post » Sat Aug 16, 2014 10:19 am

Well, I wouldn't use spawner1, spawner2 etcetera, but just one spawner sprite..

system pick random instance spawner - system create enemy at spawner.x, spawner.y
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Aug 16, 2014 10:24 am

LittleStain wrote:Well, I wouldn't use spawner1, spawner2 etcetera, but just one spawner sprite..

system pick random instance spawner - system create enemy at spawner.x, spawner.y


i just really dunno what you mean...
i only can use system-> create object
nothing with instance

EDIT : damn i see what you mean thanks!
B
27
S
7
G
3
Posts: 300
Reputation: 4,573


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests