test snake
This commit is contained in:
51
src/main.c
51
src/main.c
@@ -10,6 +10,7 @@ by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit h
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "resource_dir.h" // utility header for SearchAndSetResourceDir
|
#include "resource_dir.h" // utility header for SearchAndSetResourceDir
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,15 @@ int main ()
|
|||||||
Texture2D emi = LoadTextureFromImage(image);
|
Texture2D emi = LoadTextureFromImage(image);
|
||||||
UnloadImage(image);
|
UnloadImage(image);
|
||||||
|
|
||||||
|
int HorizontalPosition = 400;
|
||||||
|
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
|
||||||
@@ -38,12 +48,45 @@ 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);
|
||||||
|
|
||||||
// draw our texture to the screen
|
DrawCircle(HorizontalPosition, VerticalPosition, 10, BLUE);
|
||||||
DrawTexture(emi, 800/2 - emi.width/2, 600/2 - emi.height/2, WHITE);
|
|
||||||
|
|
||||||
// draw some text using the default font
|
DrawCircle(positionYCollectible, positionXCollectible, 10, YELLOW);
|
||||||
DrawText("Ceci est un test de la branch dev", 200,50,20,PINK);
|
|
||||||
|
|
||||||
|
//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+1;
|
||||||
|
};
|
||||||
|
//down
|
||||||
|
if (IsKeyDown(75) && VerticalPosition != 0) {
|
||||||
|
VerticalPosition = VerticalPosition-1;
|
||||||
|
// draw some text using the default font
|
||||||
|
};
|
||||||
|
//left
|
||||||
|
if (IsKeyDown(72) && HorizontalPosition != 0) {
|
||||||
|
HorizontalPosition = HorizontalPosition-1;
|
||||||
|
// draw some text using the default font
|
||||||
|
};
|
||||||
|
//right
|
||||||
|
if (IsKeyDown(76)&& HorizontalPosition != 780) {
|
||||||
|
HorizontalPosition = HorizontalPosition+1;
|
||||||
|
// draw some text using the default font
|
||||||
|
};
|
||||||
|
|
||||||
|
if(point == 10){
|
||||||
|
DrawText("Emi la plus belle", 50,50,20,PINK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((positionXCollectible == VerticalPosition -10 || positionXCollectible == VerticalPosition +10)
|
||||||
|
&& (positionYCollectible == HorizontalPosition -10 || positionYCollectible == HorizontalPosition +10)){
|
||||||
|
positionXCollectible = GetRandomValue(0, 600);
|
||||||
|
positionYCollectible = GetRandomValue(0, 800);
|
||||||
|
point = point + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
// end the frame and get ready for the next one (display frame, poll input, etc...)
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|||||||
Reference in New Issue
Block a user