Painting with math

This is my attempt at using graphics and math! Don’t set the iteration speed to be too high, or…
gif
You know. For that reason I have set the max speed to be 3 digit, or 999 * 2 in the forever loop. Testing revealed that my computer could handle 10000 * 2 iterations but pretty laggy. I could even do more but really slowly. Try changing the colours in my very messy code to see some half colour light combination stuff happening. Enjoy!

9 Likes


woah i love it!!!

8 Likes

Thanks a lot!!! I love how it looks pink and I originally had read and green for a weird yellow

3 Likes

Update!!! This now gets different colour pallets and different colours every time it hits the outside bounds. This is made possible due to @UnsignedArduino and the ColourBlock extension!!! Try setting speed to 5000, 4000, 3000, or 2000, and click A to change colours! Also B pauses the game so try using that and then switching colours. This is me switching colours while paused!

6 Likes

yea cool i made a thing called making image out of array https://makecode.com/_YtPLgtczY8xg also you have to edit the array with number form 1-15

2 Likes

This is different though because it uses no sprites whatsoever, it is not creating a sprite for every pixel or making a sprite for the whole thing. I am just updating an image the is the background.

1 Like

oh (sentence)

1 Like


oooh i got a nice taiga biome, lots of savannah, some desert and snowy plains too + a sprinkle of deep ocean and plains

9 Likes

Haha this version is funny!

3 Likes

Imagine making a game where the stuff painted on the screen is the randomly generated tilemap you must advance through… crazy stuff…

3 Likes

Pretty cool how many methods of procedural generation there are, Perlin noise, wave function collapse, fractals etc

3 Likes

@BotWarrior this is so cool!

Here’s something similar I did a while back, drawing wavy lines:

For the randomness, it uses Fractal Brownian Motion - basically just a precalculated table of layered Perlin Noise. Total overkill for a simple effect like this, but it’s what I did :). A simpler approach might be to just stack and jitter a few sine waves at different frequencies.

4 Likes

Wow that is complicated! I just kind of exploded colour onto the screen! :rofl:
I play a game called rim world with a mod that allows you to create geographical landforms with periin noise and stuff. I understand how complicated that can all get. :smiley:


Sadly I couldn’t understand much of your code, (GRAY BLOCKS!!!) but I am very interested at using lines to draw to screen. I am currently trying to use math and lines to create a game, but since the screen moves, the image gets offset if you understand what I mean. Could you maybe take a look through this? (A to change which laser you are moving)

4 Likes

Ya the code behind my wavy lines is unreasonably complicated. What appears in the gray blocks is just test code. The code to draw the lines is in another file (switch to JavaScript to see that).

I had a look at your laser code, and you’re very close to having it working! I see that you’re creating a sprite for use as the laser, and drawing a line on its image every frame or so. That’s very clever as you can take advantage of Sprite’s per-pixel collision detection to detect when the laser intersects something! I also like how you’re using another sprite to center the camera on.

One thing I noticed is that the laser’s length can be longer than the screen size, so I ended up recreating the laser sprite each time to be the size of the line’s bounding box. Sometimes it will be smaller than the screen, sometimes larger, depending on where the fireballs are positioned.

Next issue is getting the line endpoints into the right coordinates for drawing to the laser sprite’s image. This is a bit tricky, because you’re mixing sprite and image coordinates, and the two have different origins. A sprite’s origin is in the center, whereas an image’s origin is in the upper-left corner. I added some code to calculate these coordinates.

Anyway, have a look and let me know what you think of the approach:

Sorry about all the renamed variables! I switched to JavaScript and made some edits, which replaced spaces with underscores.

2 Likes

Thank you so much!!! I was really stumped and was nearly ready to throw the project away. I love how it can manage of screen and diagonals, but at basically 180 degrees relative to one another, it cuts out some bits of the laser.


Do you know what could be causing this behaviour?

3 Likes

Oops! When the line is perfectly vertical, the width of the laser bounding box will be zero (and similarly for perfectly horizontal). Just need to make sure that can’t happen. Here’s one way to handle it:

2 Likes

Although, there may be an off-by-one error happening, so always adding 1 to laser_width and laser_height might be a better solution.

1 Like

Yep, this gives better results:

3 Likes

you
could
make
Guardian Stalker - Zelda Dungeon Wiki, a The Legend of Zelda wiki

2 Likes

Thanks a lot!

1 Like