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

0 favourites
  • 2 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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?

  • Try Construct 3

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

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

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