Commit a7bc7d6a authored by DIDON Maya's avatar DIDON Maya

Ajout d'une fonctionnalité score

parent 84f32fb0
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:/raylib/raylib/src/**",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"GRAPHICS_API_OPENGL_33",
"PLATFORM_DESKTOP"
],
"compilerPath": "C:/raylib/mingw/bin/gcc.exe",
"cStandard": "c99",
"cppStandard": "c++14",
"intelliSenseMode": "gcc-x64"
},
{
"name": "Mac",
"includePath": [
"<path_to_raylib>/src/**",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"GRAPHICS_API_OPENGL_33",
"PLATFORM_DESKTOP"
],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "clang-x64"
},
{
"name": "Linux",
"includePath": [
"<path_to_raylib>/src/**",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"GRAPHICS_API_OPENGL_33",
"PLATFORM_DESKTOP"
],
"compilerPath": "usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/game",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"windows": {
"miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe",
},
"osx": {
"MIMode": "lldb"
},
"linux": {
"miDebuggerPath": "/usr/bin/gdb",
},
"preLaunchTask": "build debug"
},
{
"name": "Run",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"program": "${workspaceFolder}/game",
"MIMode": "gdb",
"windows": {
"program": "${workspaceFolder}/game.exe",
"miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe"
},
"osx": {
"MIMode": "lldb"
},
"linux": {
"miDebuggerPath": "/usr/bin/gdb"
},
"preLaunchTask": "build release",
}
]
}
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/*.o": true,
"**/*.exe": true,
}
}
\ No newline at end of file
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build debug",
"type": "process",
"command": "make",
"args": [
"PLATFORM=PLATFORM_DESKTOP",
"BUILD_MODE=DEBUG"
],
"windows": {
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
"args": [
"RAYLIB_PATH=C:/raylib/raylib",
"PROJECT_NAME=${fileBasenameNoExtension}",
],
},
"osx": {
"args": [
"RAYLIB_PATH=<path_to_raylib>/raylib"
],
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "build release",
"type": "process",
"command": "make",
"args": [
"PLATFORM=PLATFORM_DESKTOP",
],
"windows": {
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
"args": [
"RAYLIB_PATH=C:/raylib/raylib",
"PROJECT_NAME=${fileBasenameNoExtension}",
],
},
"osx": {
"args": [
"RAYLIB_PATH=<path_to_raylib>/raylib",
],
},
"group": "build",
"problemMatcher": [
"$gcc"
]
}
]
}
This diff is collapsed.
This diff is collapsed.
/*******************************************************************************************
*
* raylib [core] example - Basic 3d example
*
* Welcome to raylib!
*
* To compile example, just press F5.
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib");
Camera camera = { 0 };
camera.position = (Vector3){ 10.0f, 10.0f, 8.0f };
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 60.0f;
camera.type = CAMERA_PERSPECTIVE;
SetCameraMode(camera, CAMERA_ORBITAL);
Vector3 cubePosition = { 0.0f };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("This is a raylib example", 10, 40, 20, DARKGRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
\ No newline at end of file
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.associations": {
"raylib.h": "c",
"math.h": "c",
"blocks.h": "c",
"stdio.h": "c",
"*.m": "c"
}
}
}
\ No newline at end of file
......@@ -71,6 +71,7 @@ static bool lineToDelete = false;
// Statistics
static int level = 1;
static int lines = 0;
static int score = 0;
// Counters
static int gravityMovementCounter = 0;
......@@ -100,7 +101,7 @@ static bool ResolveLateralMovement();
static bool ResolveTurnMovement();
static void CheckDetection();
static void CheckCompletion();
static void DeleteCompleteLines();
static int DeleteCompleteLines();
//------------------------------------------------------------------------------------
// Program main entry point
......@@ -109,7 +110,7 @@ int main(void)
{
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "sample game: tetris");
InitWindow(screenWidth, screenHeight, "tetris - revamped");
InitGame();
......@@ -148,6 +149,7 @@ void InitGame(void)
// Initialize game statistics
level = 1;
lines = 0;
score = 0;
fadingColor = GRAY;
......@@ -279,11 +281,13 @@ void UpdateGame(void)
if (fadeLineCounter >= FADING_TIME)
{
DeleteCompleteLines();
static int nbDel;
nbDel=DeleteCompleteLines();
fadeLineCounter = 0;
lineToDelete = false;
lines++;
score=score+(nbDel*nbDel);
}
}
}
......@@ -386,6 +390,7 @@ void DrawGame(void)
DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY);
DrawText(TextFormat("LINES: %04i", lines), offset.x, offset.y + 20, 10, GRAY);
DrawText(TextFormat("SCORE: %04i", score), offset.x, offset.y + 30, 10, RED);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
}
......@@ -758,8 +763,10 @@ static void CheckCompletion(bool *lineToDelete)
}
}
static void DeleteCompleteLines()
//returns number of lines deleted
static int DeleteCompleteLines()
{
static int nbDel = 0;
// Erase the completed line
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
{
......@@ -769,6 +776,7 @@ static void DeleteCompleteLines()
{
grid[i][j] = EMPTY;
}
nbDel++;
for (int j2 = j-1; j2 >= 0; j2--)
{
......@@ -788,4 +796,5 @@ static void DeleteCompleteLines()
}
}
}
return(nbDel);
}
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment