huge init

This commit is contained in:
_N3m0 2024-03-11 12:43:20 +01:00
commit 279eb78cd2
6 changed files with 163 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.wakatime-project

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
all:
gcc -Wall -Wextra -ggdb main.c -o mineur -lraylib
run: all
./mineur
clean:
rm -f mineur

69
main.c Normal file
View File

@ -0,0 +1,69 @@
#include "raylib.h"
static inline int min(int a, int b) {
return a < b ? a : b;
}
int screen_width = 500;
int screen_height = 550;
Rectangle menu;
int grid_len = 0;
int nb_cell = 16;
Rectangle grid = {0};
Image mine_image_orig = {0};
Texture mine_texture = {0};
void screen_resize_handle(void) {
screen_width = GetScreenWidth();
screen_height = GetScreenHeight();
menu.width = screen_width;
grid_len = min(screen_width, screen_height - menu.height);
grid = (Rectangle){(screen_width - grid_len) / 2,
screen_height - grid_len,
grid_len, grid_len};
Image mine_copy = ImageCopy(mine_image_orig);
ImageResize(&mine_copy, grid.width/nb_cell, grid.height/nb_cell);
mine_texture = LoadTextureFromImage(mine_copy);
}
int main(void) {
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
menu = (Rectangle){0, 0, screen_width, screen_height - screen_width};
mine_image_orig = LoadImage("ressources/mine.png");
InitWindow(screen_width, screen_height, "mineur");
screen_resize_handle();
while (!WindowShouldClose()) {
if (IsWindowResized())
screen_resize_handle();
BeginDrawing();
{
ClearBackground(RAYWHITE);
DrawRectangleRec(menu, RED);
DrawRectangleRec(grid, GRAY);
for (int x=0; x<nb_cell; x++) {
for (int y=0; y<nb_cell; y++) {
DrawTexture(mine_texture,
grid.x + grid.width/nb_cell * x,
grid.y + grid.height/nb_cell * y,
WHITE);
}
}
}
EndDrawing();
}
CloseWindow();
return 0;
}

BIN
mineur Executable file

Binary file not shown.

BIN
ressources/mine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

85
ressources/mine.svg Normal file
View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="500"
height="500"
viewBox="0 0 132.29167 132.29167"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="mine.svg"
inkscape:export-filename="mine.png"
inkscape:export-xdpi="42.760944"
inkscape:export-ydpi="42.760944"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.54866744"
inkscape:cx="-27.338965"
inkscape:cy="231.4699"
inkscape:window-width="1912"
inkscape:window-height="1047"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<linearGradient
id="linearGradient1502"
inkscape:swatch="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop1500" />
</linearGradient>
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<ellipse
style="fill:#000000;stroke:#000000;stroke-width:0.223074;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke fill markers"
id="path111"
cx="62.799694"
cy="72.270866"
rx="56.635628"
ry="54.199226" />
<path
sodipodi:type="spiral"
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:8.74093;stroke-dasharray:none;stroke-opacity:1"
id="path341"
sodipodi:cx="28.490538"
sodipodi:cy="45.3279"
sodipodi:expansion="1"
sodipodi:revolution="0.48942739"
sodipodi:radius="29.633478"
sodipodi:argument="-18.138201"
sodipodi:t0="0.43865359"
d="M 22.3788,56.800314 C 9.0687208,58.790669 1.8870045,43.112185 3.6587879,32.099198 3.9093976,30.541467 4.2971025,29.006294 4.8091046,27.514064"
transform="matrix(-0.43060005,0.65234095,-0.65851537,-0.4265626,146.99062,27.717028)" />
<rect
style="fill:#000000;stroke:#000000;stroke-width:0.294461;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect286"
width="32.785309"
height="14.191555"
x="78.330818"
y="-41.435642"
ry="0"
rx="0"
transform="matrix(0.8383838,0.54508037,-0.54856161,0.83611013,0,0)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB