Need Help With Random Positioning Of Asteroids...

Get help using Construct 2

Post » Sat Feb 16, 2013 12:53 am

Need Help With Random Positioning Of Asteroids...

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:



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
B
11
S
3
G
4
Posts: 105
Reputation: 2,950

Post » Sat Feb 16, 2013 1:58 am



x = width/2 + cos(random(angle)) * minimumDistance+random(maximumDistance)


y = height/2 + sin(random(angle)) * minimumDistance+random(maximumDistance)
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Feb 16, 2013 2:09 am

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

JeZ+Lee
B
11
S
3
G
4
Posts: 105
Reputation: 2,950


Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt and 13 guests