Skip to content

Commit

Permalink
more features
Browse files Browse the repository at this point in the history
  • Loading branch information
OetkenPurveyorOfCode committed Jul 9, 2024
1 parent b392242 commit bf66206
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ A C Sierpinski thingy
| E | Quad Scale I |
| R | Quad Scale II |
| U | Quad Vertscale|
| P | Pentagon |
| P | Penta Mode |
| O | Penta Nodouble|

### Scale mode (Press S)
![Sierpinski Fractal](s.png)
Expand All @@ -37,6 +38,9 @@ A C Sierpinski thingy
### Quadscale II mode (Press R)
![Sierpinski Fractal](r.png)

### Penta Nodouble (Press O)
![Sierpinski Fractal](o.png)

## Building

Run the `build.bat` file.
Look at the `build.bat` file.
24 changes: 24 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ u32 get_color(isize i, bool enable_colors) {
break;case 1: return 0xFF00FF00;
break;case 2: return 0xFF0000FF;
break;case 3: return 0xFFFFFFFF;
break;case 4: return 0xFFFF00FF;
}
}
return 0xFFFFFFFF;
Expand All @@ -44,6 +45,7 @@ typedef enum {
RM_RSCALE,
RM_ZSCALE,
RM_PENTA,
RM_PENTA_NODOUBLE
} RenderMode;

typedef struct {
Expand Down Expand Up @@ -137,6 +139,9 @@ int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int
if (platform.keys['P'] == gbKeyState_Released) {
app.mode = RM_PENTA;
}
if (platform.keys['O'] == gbKeyState_Released) {
app.mode = RM_PENTA_NODOUBLE;
}

//render

Expand Down Expand Up @@ -304,6 +309,25 @@ int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int
gb_platform_update(&platform);
gb_platform_display(&platform);
}
break;case RM_PENTA_NODOUBLE: {
isize last_i = 0;
penta_xs[1] = (sin((double)counter)*(platform.window_width-1))/2+platform.window_width/2;
for(isize it = 0; it < 10000; it++) {
isize i = pcg32_boundedrand(5);
if (i != last_i) {
x = (x + penta_xs[i])/2;
y = (y + penta_ys[i])/2;
}
last_i = i;
if (0 <= x && x < platform.window_width && 0 <= y && y < platform.window_height) {
putpixel(&platform, x, y, get_color(i, app.enable_colors));
}
putpixel(&platform, pcg32_boundedrand(platform.window_width), pcg32_boundedrand(platform.window_height), 0);
};
counter += 1e-3;
gb_platform_update(&platform);
gb_platform_display(&platform);
}
}

};
Expand Down
Binary file added o.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bf66206

Please sign in to comment.