Compare commits

...

8 Commits

Author SHA1 Message Date
056cdf9799 Merge branch 'features/character-movement'
This is for my sanity
2026-04-21 13:27:20 +02:00
a385a24d0f test movement du personnage 2026-04-21 13:19:08 +02:00
93bca5b327 ajout du sprite dans la ressource 2026-04-21 12:52:38 +02:00
Émi Lefèvre
873c3d3e3d Add mrsh sprite 2026-04-21 12:41:38 +02:00
Émi Lefèvre
5fc8c8f94f Add windows makefile 2026-04-21 11:18:45 +02:00
Émi Lefèvre
e1c3fea1f0 Ignore Windows specific changes 2026-04-21 11:18:45 +02:00
3d3c028997 Merge pull request 'ajout end game' (#2) from dev into main
Reviewed-on: #2
2026-04-21 07:12:30 +00:00
4071b771e4 ajout end game 2026-04-21 09:07:46 +02:00
6 changed files with 71 additions and 47 deletions

8
.gitignore vendored
View File

@@ -405,4 +405,12 @@ Makefile
*.swp *.swp
*.swo *.swo
*.swn *.swn
/build/compile_commands.json /build/compile_commands.json
raylib.make
raylib.vcxproj
raylib.vcxproj.filters
test-game.make
test-game.vcxproj
test-game.vcxproj.filters
raylib.make

BIN
raw/mrsh.ase Normal file

Binary file not shown.

24
raw/mrsh.json Normal file
View File

@@ -0,0 +1,24 @@
{ "frames": {
"mrsh.ase": {
"frame": { "x": 0, "y": 0, "w": 16, "h": 16 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 16 },
"sourceSize": { "w": 16, "h": 16 },
"duration": 100
}
},
"meta": {
"app": "https://github.com/LibreSprite/LibreSprite/",
"version": "1.2-973d0e3d-SDL",
"image": "C:\\Code\\test-game\\raw\\mrsh.png",
"format": "RGBA8888",
"size": { "w": 16, "h": 16 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
]
}
}

BIN
raw/mrsh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

BIN
resources/mrsh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

View File

@@ -12,6 +12,17 @@ by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit h
#include "resource_dir.h" // utility header for SearchAndSetResourceDir #include "resource_dir.h" // utility header for SearchAndSetResourceDir
#include <stdlib.h> #include <stdlib.h>
typedef struct Player {
Vector2 position;
Vector2 size;
int life;
} Player;
static Player player = {0};
static void characterMovement(void);
int main () int main ()
{ {
// Tell the window to use vsync and work on high DPI displays // Tell the window to use vsync and work on high DPI displays
@@ -24,21 +35,13 @@ int main ()
SearchAndSetResourceDir("resources"); SearchAndSetResourceDir("resources");
// Load a texture from the resources directory // Load a texture from the resources directory
Image image = LoadImage("emi.png"); Image image = LoadImage("mrsh.png");
Texture2D emi = LoadTextureFromImage(image); Texture2D emi = LoadTextureFromImage(image);
UnloadImage(image); UnloadImage(image);
int HorizontalPosition = 400; int HorizontalPosition = 400;
int VerticalPosition = 300; int VerticalPosition = 300;
int point = 0;
//Start point of the colectible
int positionXCollectible = GetRandomValue(0, 600);
int positionYCollectible = GetRandomValue(0, 800);
// game loop // game loop
while (!WindowShouldClose()) // run the loop until the user presses ESCAPE or presses the Close button on the window while (!WindowShouldClose()) // run the loop until the user presses ESCAPE or presses the Close button on the window
{ {
@@ -48,47 +51,12 @@ int main ()
// Setup the back buffer for drawing (clear color and depth buffers) // Setup the back buffer for drawing (clear color and depth buffers)
ClearBackground(BLACK); ClearBackground(BLACK);
DrawCircle(HorizontalPosition, VerticalPosition, 10, BLUE); // DrawRectangle(HorizontalPosition, VerticalPosition, 10, 10, BLUE);
DrawTexture(emi, player.position.x, player.position.y, WHITE);
DrawCircle(positionXCollectible, positionYCollectible, 10, YELLOW); characterMovement();
//draw score
DrawText(TextFormat("score : %d", point), 500,50,20,PINK);
//up
if (IsKeyDown(74) && VerticalPosition != 580 ) {
// draw some text using the default font
VerticalPosition = VerticalPosition+10;
};
//down
if (IsKeyDown(75) && VerticalPosition != 0) {
VerticalPosition = VerticalPosition-10;
// draw some text using the default font
};
//left
if (IsKeyDown(72) && HorizontalPosition != 0) {
HorizontalPosition = HorizontalPosition-10;
// draw some text using the default font
};
//right
if (IsKeyDown(76)&& HorizontalPosition != 780) {
HorizontalPosition = HorizontalPosition+10;
// draw some text using the default font
};
if(point == 10){
DrawText("Emi la plus belle", 50,50,20,PINK);
}
if (abs(positionXCollectible - HorizontalPosition) < 10 &&
abs(positionYCollectible - VerticalPosition) < 10){
positionXCollectible = GetRandomValue(0, 800);
positionYCollectible = GetRandomValue(0, 600);
point = point + 1;
}
// end the frame and get ready for the next one (display frame, poll input, etc...)
EndDrawing(); EndDrawing();
} }
@@ -100,3 +68,27 @@ int main ()
CloseWindow(); CloseWindow();
return 0; return 0;
} }
void characterMovement(void){
//up
if (IsKeyDown(74) ) {
// draw some text using the default font
player.position.y = player.position.y+10;
};
//down
if (IsKeyDown(75) ) {
player.position.y = player.position.y-10;
// draw some text using the default font
};
//left
if (IsKeyDown(72) ) {
player.position.x = player.position.x-10;
// draw some text using the default font
};
//right
if (IsKeyDown(76)) {
player.position.x = player.position.x+10;
// draw some text using the default font
};
}