Algorithm for creating segmented, concentric rings a la Starcastle?

7936486--1014490--upload_2022-3-2_10-10-25.png

Greetings devs,

I was wondering if there is an algorithm I can steal to create segment concentric rings like those in the pasted image from Starcastle?

I’m envisioning a GameObject with a collection of children for the segments. The parent GameObject will rotate so of course the “ring” will rotate around it.

I’d like an algorithm that would calculate the size, position and rotation of the segments based on the diameter and resolution (number of segments) for the “ring”.

Thanks in advance,

Greg.

It is doubtful there is someone out there with a ready made script just for this issue. If you are able to break each straight segment, it seems like you just need something that first determines how big and then how many sides. Depending on the # of sides it creates an adjacent line at a certain angle. Aka, if octogonal, start first line at 0 degrees, then spawn a second one 45 degrees from that, and so on. Obviously, im simplifying a lot here but i think that is close to the route you want to go.

Check out this YT page with a bunch of math for game dev stuff, a video in there may be able to help:

Jorge Rodriguez - YouTube

1 Like

Thanks, I’ll check that out.

I like your choice of games: last month was Moon Patrol, now Star Castle… awesome!

That’s exactly what I would do… and…

Lol… “Akshually…”

https://gist.github.com/kurtdekker/efceb3fa007613be5494e51b4f6800c5

The coffee is working really well this morning… enjoy!

EDIT: just noticed this is posted in 2D… so replace the GameObjects (Cubes) with a 2D sprite and off you go!

1 Like

I can always count on you Kurt! :slight_smile:

1 Like

It’s a solid game mechanic… I’ve seen it in other games (SuperGoodPixel used it in Major Rocks) and I have actually used it a few times in a few of my games.

I used it on the level boss enemies in 2015 in my Tank Dynamaze2D game:

7936711--1014517--Screen Shot 2022-03-02 at 8.20.51 AM.jpg

You can play it here:

Apple iOS: https://itunes.apple.com/us/app/dynamaze-2d/id1019951912

Google Play: https://play.google.com/store/apps/details?id=com.plbm.dynamaze2d

Android TV: https://play.google.com/store/apps/details?id=com.plbm.dynamaze2dtv

1 Like

Very cool game. I like the way you implemented the controls for mobile. I really struggled to get controls that worked well for my Asteroids game.

Okay Kurt, here’s a quick prototype I whipped up using the algorithm you provided. It needs a lot of work but I think it’s a good start.

https://www.youtube.com/watch?v=sQcQKdn1Slk

AWESOME!! SHIP IT!! Glad that worked out.

This is my 1990s shareware version of it:

https://www.youtube.com/watch?v=yYVnZP-R1EA

2 Likes