Ratios in a Single Line with % [C2] [SOLVED]

Just started using Construct 2? Post your questions here

Post » Sun Jul 23, 2017 5:30 pm

Hey, guys.

Got a question.

How would I code something in a single line to be able to control various percentages of the ships which spawn on screen?

Currently I have this set up as:

set type (local variable) to choose (1,1) or choose (1,2,3,4,5...) etc, but no idea how to even set this up to accurately control spawn ratios of different ships on screen.

Basically I have a lot of different ship types, but rather than just revealing them all at once in a random version, I found that a slower timed reveal works better, feels
way more video gamy.

There's generally about 10 ships total on screen at a time with the spawner I have set up.

I have a time variable TimeCount

so let's say TimeCount>5

spawn just 1 ship type
--
TimeCount>200

spawn 1 ship of Ship Type 2 for every 9 ships of Ship Type 1

TimeCount>400

say spawn 3 ships of Ship Type 5 for every 7 ships of Ship Type 3 etc etc

Basically, it gets pretty hard to do with the choose expression.

Something with percentages that's very compact that could fit in a single line of code (maybe with calls, functions, etc.) that works well with a For Each X element of an array loop would be great here.

?

Any ideas?
Last edited by AmpedRobot on Sun Jul 23, 2017 6:15 pm, edited 1 time in total.
B
33
S
18
G
12
Posts: 228
Reputation: 9,515

Post » Sun Jul 23, 2017 6:15 pm

Addendum

I figured this out with a multi-line function calling from the For X loop, but if anybody has any cool code they want to share, let's go for it!

Basically, my current spawn ratios rely on randomness which means the correct spawn ratio does not always get called.

I did controlled chaos before (within a range).

I'd probably want a call to an array for exact spawn ratios and it'd be nice if the sequencing was random.

But this post is solved for all intents and purposes for now.
B
33
S
18
G
12
Posts: 228
Reputation: 9,515


Return to Beginner's Questions

Who is online

Users browsing this forum: davidbox and 1 guest