3 days ago I named some characters. And now quite by accident i see two of them. Strange feelings... Stunning planet textures. Clicking on random planet areas is a treat for the eyes.
let dt = 0.01; // stepsize
let t0 = random(0, TWO_PI); // random starting angle
let r; // star-positions in polar coordinates
let t; // as in: r * exp(t)
let x0 = width/2; // center of the galaxy
let y0 = height/2;
let scale = 40; // bigger numbers draw a bigger galaxy
let numberOfStars = 1000; // stars in one arm of the galaxy
// draw one spiral arm
for (let i = 0; i < numberOfStars; i++) {
// calculate polar coordinates of the next star to draw
t = t0 + i * dt;
let r = (t - t0) * scale;
let x = x0 + r * cos(t); // convert to cartesian coordinates
let y = y0 + r * sin(t);
let starRadius = 10;
DrawCircleAt(x, y, starRadius);
}
And then I have a for loop or whatever around this codeblock to draw as many spiral arms as I want. I also add some random noise to pretty much every calculation, just to make things seem a little more organic.
You can also squish the galaxy by deciding on some squishX and squishY factors before drawing any arms and then in your cartesian coordinate conversion you have
let x = x0 + (r/xSquish) * cos(t);
let y = y0 + (r/ySquish) * sin(t);
To make it more colorful, I pick a starting color and every time after I draw a star, I slightly change the color - I do the same after every spiral arm.
Hope that helps and thank you for checking it out and commenting:)
That was what I think of, cause that doesn't looks like a copy/paste bitmaps at all, way too organic. More galaxies types and/or variety would be great imo. Also you can easily pump that color randomization up, by generating a simple color palette to constraint color value, that cost nothing.
Comments
3 days ago I named some characters. And now quite by accident i see two of them. Strange feelings...
Stunning planet textures. Clicking on random planet areas is a treat for the eyes.
I'm really glad you enjoyed and especially that you came back to it :) It really does mean a lot to me.
I am also get a very particular feeling when stumbling upon any named creature at all... right now about 0.01% of all creatures have been named
Wait what, you mean everything is synchronized on a database why didn't you say it on the game page? That's make the thing even cooler !
Ummmm, I honestly don't know why I didn't say that :D
I'm glad you like the project tho :3
Amazing idea, very SPORE like, I wonder how you draw the galaxies.
very basically like this
And then I have a for loop or whatever around this codeblock to draw as many spiral arms as I want.I also add some random noise to pretty much every calculation, just to make things seem a little more organic.
You can also squish the galaxy by deciding on some squishX and squishY factors before drawing any arms and then in your cartesian coordinate conversion you have
To make it more colorful, I pick a starting color and every time after I draw a star, I slightly change the color - I do the same after every spiral arm.
Hope that helps and thank you for checking it out and commenting:)
That was what I think of, cause that doesn't looks like a copy/paste bitmaps at all, way too organic. More galaxies types and/or variety would be great imo. Also you can easily pump that color randomization up, by generating a simple color palette to constraint color value, that cost nothing.
I planned for different types of galaxies, but most of the time was spent on the generator when you zoom one level in from the planets.