# Need Help With Random Positioning Of Asteroids...

0 favourites
• 3 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
• <font size="5">Need Help With Random Positioning Of Asteroids...</font>

Hi,

My first C2 game is almost finished.

It's an Asteroids remake.

I need help with the random positioning of new wave level asteroids.

Currently I do this to setup asteroids on a new game/wave level:

<img src="http://16bitsoft.com/V2/Files/RocksInSpace/Images/RIS_RandomPerimeterOnly-01.png" border="0" />

The above positions a new asteroid randomly anywhere on the screen.

What I need is to place the new asteroid on only the perimeters of the screen.

How would I create an event to do the above?

I know how to write it in C++, but am having great trouble in making it in events.

Perimeter would be:

(1) x = 0 & y = any

(2) x = 640 & y = any

(3) x = any & y = 0

(4) x = any & y = 480

Help would be greatly appreciated!

Thanks!

JeZ+Lee

• ## Try Construct 3

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

Construct 3 users don't see these ads
• x = width/2 + cos(random(angle)) * minimumDistance+random(maximumDistance)

y = height/2 + sin(random(angle)) * minimumDistance+random(maximumDistance)

• Wow, that is some crazy maths(I hate math).

Thanks!

JeZ+Lee

• 3 posts