From 7134b3ba35e3d3d755e4fc8bdbb15c596769991a Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 29 Aug 2024 23:34:31 +0200 Subject: [PATCH] Update Raylib examples to use Raylib5. --- .github/workflows/main.yml | 16 ++-- resources/examples/raylib/raylib_arkanoid.c3 | 46 ++++++------ resources/examples/raylib/raylib_snake.c3 | 46 ++++++------ resources/examples/raylib/raylib_tetris.c3 | 77 ++++++++++---------- 4 files changed, 90 insertions(+), 95 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cfb58d5aa..2744a0e97 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,15 +65,15 @@ jobs: - name: Vendor-fetch run: | - build\${{ matrix.build_type }}\c3c.exe vendor-fetch raylib + build\${{ matrix.build_type }}\c3c.exe vendor-fetch raylib5 - - name: Try raylib + - name: Try raylib5 run: | cd resources - ..\build\${{ matrix.build_type }}\c3c.exe vendor-fetch raylib - ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib --print-linking --wincrt=none examples\raylib\raylib_arkanoid.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib --print-linking --wincrt=none examples\raylib\raylib_snake.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib --print-linking --wincrt=none examples\raylib\raylib_tetris.c3 + ..\build\${{ matrix.build_type }}\c3c.exe vendor-fetch raylib5 + ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib5 --print-linking examples\raylib\raylib_arkanoid.c3 + ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib5 --print-linking examples\raylib\raylib_snake.c3 + ..\build\${{ matrix.build_type }}\c3c.exe compile --lib raylib5 --print-linking examples\raylib\raylib_tetris.c3 - name: run compiler tests run: | @@ -145,7 +145,7 @@ jobs: - name: Vendor-fetch run: | - ./build/c3c vendor-fetch raylib + ./build/c3c vendor-fetch raylib5 - name: Build testproject lib run: | @@ -607,7 +607,7 @@ jobs: - name: Vendor-fetch run: | - ./build/c3c vendor-fetch raylib + ./build/c3c vendor-fetch raylib5 - name: Compile and run some examples run: | diff --git a/resources/examples/raylib/raylib_arkanoid.c3 b/resources/examples/raylib/raylib_arkanoid.c3 index 8c3f20ed5..069e3cb46 100644 --- a/resources/examples/raylib/raylib_arkanoid.c3 +++ b/resources/examples/raylib/raylib_arkanoid.c3 @@ -1,5 +1,5 @@ module arkanoid; -import raylib; +import raylib5; import std::math; /** * @@ -72,15 +72,15 @@ fn void main() { // Initialization (Note windowTitle is unused on Android) //--------------------------------------------------------- - raylib::init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: arkanoid"); + rl::initWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: arkanoid"); init_game(); - raylib::set_target_fps(60); + rl::setTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop - while (!raylib::window_should_close()) // Detect window close button or ESC key + while (!rl::windowShouldClose()) // Detect window close button or ESC key { // Update and Draw //---------------------------------------------------------------------------------- @@ -91,7 +91,7 @@ fn void main() //-------------------------------------------------------------------------------------- unload_game(); // Unload loaded data (textures, sounds, models...) - raylib::close_window(); // Close window and OpenGL context + rl::closeWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- } @@ -103,7 +103,7 @@ fn void main() // Initialize game variables fn void init_game() { - brick_size = { (float)raylib::get_screen_width() / BRICKS_PER_LINE, 40 }; + brick_size = { (float)rl::getScreenWidth() / BRICKS_PER_LINE, 40 }; // Initialize player player.position = { SCREEN_WIDTH/2, SCREEN_HEIGHT * 7 / 8 }; @@ -134,25 +134,25 @@ fn void update_game() { if (game_over) { - if (raylib::is_key_pressed(keyboard::ENTER)) + if (rl::isKeyPressed(rl::KEY_ENTER)) { init_game(); game_over = false; } } - if (raylib::is_key_pressed((KeyboardKey)'P')) pause = !pause; + if (rl::isKeyPressed((KeyboardKey)'P')) pause = !pause; if (pause) return; // Player movement logic - if (raylib::is_key_down(keyboard::LEFT)) player.position.x -= 5; + if (rl::isKeyDown(rl::KEY_LEFT)) player.position.x -= 5; if ((player.position.x - player.size.x/2) <= 0) player.position.x = player.size.x/2; - if (raylib::is_key_down(keyboard::RIGHT)) player.position.x += 5; + if (rl::isKeyDown(rl::KEY_RIGHT)) player.position.x += 5; if ((player.position.x + player.size.x/2) >= SCREEN_WIDTH) player.position.x = SCREEN_WIDTH - player.size.x/2; // Ball launching logic if (!ball.active) { - if (raylib::is_key_pressed(keyboard::SPACE)) + if (rl::isKeyPressed(rl::KEY_SPACE)) { ball.active = true; ball.speed = { 0, -5 }; @@ -182,7 +182,7 @@ fn void update_game() } // Collision logic: ball vs player - if (raylib::check_collision_circle_rec(ball.position, ball.radius, + if (rl::checkCollisionCircleRec(ball.position, ball.radius, Rectangle{ player.position.x - player.size.x / 2, player.position.y - player.size.y / 2, player.size.x, player.size.y})) { if (ball.speed.y > 0) @@ -256,20 +256,20 @@ fn void update_game() // Draw game (one frame) fn void draw_game() { - raylib::begin_drawing(); - - raylib::clear_background(raylib::RAYWHITE); + rl::beginDrawing(); + defer rl::endDrawing(); + rl::clearBackground(rl::RAYWHITE); if (!game_over) { // Draw player bar - raylib::draw_rectangle((int)(player.position.x - player.size.x/2), (int)(player.position.y - player.size.y/2), (int)player.size.x, (int)player.size.y, raylib::BLACK); + rl::drawRectangle((int)(player.position.x - player.size.x/2), (int)(player.position.y - player.size.y/2), (int)player.size.x, (int)player.size.y, rl::BLACK); // Draw player lives - for (int i = 0; i < player.life; i++) raylib::draw_rectangle(20 + 40*i, SCREEN_HEIGHT - 30, 35, 10, raylib::LIGHTGRAY); + for (int i = 0; i < player.life; i++) rl::drawRectangle(20 + 40*i, SCREEN_HEIGHT - 30, 35, 10, rl::LIGHTGRAY); // Draw ball - raylib::draw_circle_v(ball.position, ball.radius, raylib::MAROON); + rl::drawCircleV(ball.position, ball.radius, rl::MAROON); // Draw bricks for (int i = 0; i < LINES_OF_BRICKS; i++) @@ -280,24 +280,22 @@ fn void draw_game() { if ((i + j) % 2 == 0) { - raylib::draw_rectangle((int)(brick[i][j].position.x - brick_size.x/2), (int)(brick[i][j].position.y - brick_size.y/2), (int)brick_size.x, (int)brick_size.y, raylib::GRAY); + rl::drawRectangle((int)(brick[i][j].position.x - brick_size.x/2), (int)(brick[i][j].position.y - brick_size.y/2), (int)brick_size.x, (int)brick_size.y, rl::GRAY); } else { - raylib::draw_rectangle((int)(brick[i][j].position.x - brick_size.x/2), (int)(brick[i][j].position.y - brick_size.y/2), (int)brick_size.x, (int)brick_size.y, raylib::DARKGRAY); + rl::drawRectangle((int)(brick[i][j].position.x - brick_size.x/2), (int)(brick[i][j].position.y - brick_size.y/2), (int)brick_size.x, (int)brick_size.y, rl::DARKGRAY); } } } } - if (pause) raylib::draw_text("GAME PAUSED", SCREEN_WIDTH/2 - raylib::measure_text("GAME PAUSED", 40)/2, SCREEN_HEIGHT/2 - 40, 40, raylib::GRAY); + if (pause) rl::drawText("GAME PAUSED", SCREEN_WIDTH/2 - rl::measureText("GAME PAUSED", 40)/2, SCREEN_HEIGHT/2 - 40, 40, rl::GRAY); } else { - raylib::draw_text("PRESS [ENTER] TO PLAY AGAIN", raylib::get_screen_width()/2 - raylib::measure_text("PRESS [ENTER] TO PLAY AGAIN", 20)/2, raylib::get_screen_height()/2 - 50, 20, raylib::GRAY); + rl::drawText("PRESS [ENTER] TO PLAY AGAIN", rl::getScreenWidth()/2 - rl::measureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, rl::getScreenHeight()/2 - 50, 20, rl::GRAY); } - - raylib::end_drawing(); } // Unload game variables diff --git a/resources/examples/raylib/raylib_snake.c3 b/resources/examples/raylib/raylib_snake.c3 index e92e5fee2..3843f2251 100644 --- a/resources/examples/raylib/raylib_snake.c3 +++ b/resources/examples/raylib/raylib_snake.c3 @@ -1,5 +1,5 @@ module snake; -import raylib; +import raylib5; /** * * raylib - classic game: snake @@ -53,18 +53,18 @@ int counter_tail = 0; fn void main() { - raylib::init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: snake"); + rl::initWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: snake"); init_game(); - raylib::set_target_fps(60); + rl::setTargetFPS(60); - while (!raylib::window_should_close()) // Detect window close button or ESC key + while (!rl::windowShouldClose()) // Detect window close button or ESC key { update_draw_frame(); } unload_game(); - raylib::close_window(); + rl::closeWindow(); } // Initialize game variables @@ -87,11 +87,11 @@ fn void init_game() if (i == 0) { - snake[i].color = raylib::DARKBLUE; + snake[i].color = rl::DARKBLUE; } else { - snake[i].color = raylib::BLUE; + snake[i].color = rl::BLUE; } } @@ -101,7 +101,7 @@ fn void init_game() } fruit.size = { SQUARE_SIZE, SQUARE_SIZE }; - fruit.color = raylib::SKYBLUE; + fruit.color = rl::SKYBLUE; fruit.active = false; } @@ -110,7 +110,7 @@ fn void update_game() { if (game_over) { - if (raylib::is_key_pressed(keyboard::ENTER)) + if (rl::isKeyPressed(rl::KEY_ENTER)) { init_game(); game_over = false; @@ -118,16 +118,16 @@ fn void update_game() return; } - if (raylib::is_key_pressed((KeyboardKey)'P')) pause = !pause; + if (rl::isKeyPressed((KeyboardKey)'P')) pause = !pause; if (pause) return; - if (raylib::is_key_pressed(keyboard::RIGHT) && allow_move) + if (rl::isKeyPressed(rl::KEY_RIGHT) && allow_move) { snake_direction = (SnakeDirection)((snake_direction.ordinal + 1) % 4); allow_move = false; } - if (raylib::is_key_pressed(keyboard::LEFT) && allow_move) + if (rl::isKeyPressed(rl::KEY_LEFT) && allow_move) { snake_direction = (SnakeDirection)((snake_direction.ordinal + 3) % 4); allow_move = false; @@ -179,13 +179,13 @@ fn void update_game() if (!fruit.active) { fruit.active = true; - fruit.position = { (float)raylib::get_random_value(0, (SCREEN_WIDTH / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.x / 2, (float)raylib::get_random_value(0, (SCREEN_HEIGHT / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.y / 2 }; + fruit.position = { (float)rl::getRandomValue(0, (SCREEN_WIDTH / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.x / 2, (float)rl::getRandomValue(0, (SCREEN_HEIGHT / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.y / 2 }; for (int i = 0; i < counter_tail; i++) { while ((fruit.position.x == snake[i].position.x) && (fruit.position.y == snake[i].position.y)) { - fruit.position = { (float)raylib::get_random_value(0, (SCREEN_WIDTH / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.x/2, (float)raylib::get_random_value(0, (SCREEN_HEIGHT / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.y / 2 }; + fruit.position = { (float)rl::getRandomValue(0, (SCREEN_WIDTH / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.x/2, (float)rl::getRandomValue(0, (SCREEN_HEIGHT / SQUARE_SIZE) - 1) * SQUARE_SIZE + offset.y / 2 }; i = 0; } } @@ -204,37 +204,37 @@ fn void update_game() // Draw game (one frame) fn void draw_game() { - raylib::begin_drawing(); + rl::beginDrawing(); - raylib::clear_background(raylib::RAYWHITE); + rl::clearBackground(rl::RAYWHITE); if (!game_over) { // Draw grid lines for (int i = 0; i < SCREEN_WIDTH / SQUARE_SIZE + 1; i++) { - raylib::draw_line_v({(float)SQUARE_SIZE * i + offset.x/2, offset.y/2}, {(float)SQUARE_SIZE * i + offset.x/2, SCREEN_HEIGHT - offset.y/2}, raylib::LIGHTGRAY); + rl::drawLineV({(float)SQUARE_SIZE * i + offset.x/2, offset.y/2}, {(float)SQUARE_SIZE * i + offset.x/2, SCREEN_HEIGHT - offset.y/2}, rl::LIGHTGRAY); } for (int i = 0; i < SCREEN_HEIGHT/SQUARE_SIZE + 1; i++) { - raylib::draw_line_v({offset.x/2, (float)SQUARE_SIZE * i + offset.y / 2 }, { SCREEN_WIDTH - offset.x/2, (float)SQUARE_SIZE * i + offset.y / 2 }, raylib::LIGHTGRAY); + rl::drawLineV({offset.x/2, (float)SQUARE_SIZE * i + offset.y / 2 }, { SCREEN_WIDTH - offset.x/2, (float)SQUARE_SIZE * i + offset.y / 2 }, rl::LIGHTGRAY); } // Draw snake - for (int i = 0; i < counter_tail; i++) raylib::draw_rectangle_v(snake[i].position, snake[i].size, snake[i].color); + for (int i = 0; i < counter_tail; i++) rl::drawRectangleV(snake[i].position, snake[i].size, snake[i].color); // Draw fruit to pick - raylib::draw_rectangle_v(fruit.position, fruit.size, fruit.color); + rl::drawRectangleV(fruit.position, fruit.size, fruit.color); - if (pause) raylib::draw_text("GAME PAUSED", SCREEN_WIDTH/2 - raylib::measure_text("GAME PAUSED", 40)/2, SCREEN_HEIGHT / 2 - 40, 40, raylib::GRAY); + if (pause) rl::drawText("GAME PAUSED", SCREEN_WIDTH/2 - rl::measureText("GAME PAUSED", 40)/2, SCREEN_HEIGHT / 2 - 40, 40, rl::GRAY); } else { - raylib::draw_text("PRESS [ENTER] TO PLAY AGAIN", raylib::get_screen_width()/2 - raylib::measure_text("PRESS [ENTER] TO PLAY AGAIN", 20)/2, raylib::get_screen_height()/2 - 50, 20, raylib::GRAY); + rl::drawText("PRESS [ENTER] TO PLAY AGAIN", rl::getScreenWidth()/2 - rl::measureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, rl::getScreenHeight()/2 - 50, 20, rl::GRAY); } - raylib::end_drawing(); + rl::endDrawing(); } // Unload game variables diff --git a/resources/examples/raylib/raylib_tetris.c3 b/resources/examples/raylib/raylib_tetris.c3 index c6dd3b35d..900a912aa 100644 --- a/resources/examples/raylib/raylib_tetris.c3 +++ b/resources/examples/raylib/raylib_tetris.c3 @@ -1,5 +1,5 @@ module tetris; -import raylib; +import raylib5; /** * raylib - classic game: tetris * @@ -83,15 +83,15 @@ fn void main() { // Initialization (Note windowTitle is unused on Android) //--------------------------------------------------------- - raylib::init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: tetris"); + rl::initWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "classic game: tetris"); init_game(); - raylib::set_target_fps(60); + rl::setTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop - while (!raylib::window_should_close()) // Detect window close button or ESC key + while (!rl::windowShouldClose()) // Detect window close button or ESC key { // Update and Draw //---------------------------------------------------------------------------------- @@ -102,7 +102,7 @@ fn void main() //-------------------------------------------------------------------------------------- unload_game(); // Unload loaded data (textures, sounds, models...) - raylib::close_window(); // Close window and OpenGL context + rl::closeWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- } @@ -118,7 +118,7 @@ fn void init_game() level = 1; lines = 0; - fading_color = raylib::GRAY; + fading_color = rl::GRAY; piece_position_x = 0; piece_position_y = 0; @@ -170,14 +170,14 @@ fn void update_game() { if (game_over) { - if (raylib::is_key_pressed(keyboard::ENTER)) + if (rl::isKeyPressed(rl::KEY_ENTER)) { init_game(); game_over = false; } return; } - if (raylib::is_key_pressed((KeyboardKey)'P')) pause = !pause; + if (rl::isKeyPressed((KeyboardKey)'P')) pause = !pause; if (pause) return; if (line_to_delete) @@ -185,7 +185,7 @@ fn void update_game() // Animation when deleting lines fade_line_counter++; - fading_color = fade_line_counter % 8 < 4 ? raylib::MAROON : raylib::GRAY; + fading_color = fade_line_counter % 8 < 4 ? rl::MAROON : rl::GRAY; if (fade_line_counter >= FADING_TIME) { @@ -213,11 +213,11 @@ fn void update_game() turn_movement_counter++; // We make sure to move if we've pressed the key this frame - if (raylib::is_key_pressed(keyboard::LEFT) || raylib::is_key_pressed(keyboard::RIGHT)) lateral_movement_counter = LATERAL_SPEED; - if (raylib::is_key_pressed(keyboard::UP)) turn_movement_counter = TURNING_SPEED; + if (rl::isKeyPressed(rl::KEY_LEFT) || rl::isKeyPressed(rl::KEY_RIGHT)) lateral_movement_counter = LATERAL_SPEED; + if (rl::isKeyPressed(rl::KEY_UP)) turn_movement_counter = TURNING_SPEED; // Fall down - if (raylib::is_key_down(keyboard::DOWN) && (fast_fall_movement_counter >= FAST_FALL_AWAIT_COUNTER)) + if (rl::isKeyDown(rl::KEY_DOWN) && (fast_fall_movement_counter >= FAST_FALL_AWAIT_COUNTER)) { // We make sure the piece is going to fall this frame gravity_movement_counter += gravity_speed; @@ -268,14 +268,13 @@ fn void update_game() // Draw game (one frame) fn void draw_game() { - raylib::begin_drawing(); - - raylib::clear_background(raylib::RAYWHITE); + rl::beginDrawing(); + defer rl::endDrawing(); + rl::clearBackground(rl::RAYWHITE); if (game_over) { - raylib::draw_text("PRESS [ENTER] TO PLAY AGAIN", raylib::get_screen_width() / 2 - raylib::measure_text("PRESS [ENTER] TO PLAY AGAIN", 20) / 2, raylib::get_screen_height() / 2 - 50, 20, raylib::GRAY); - raylib::end_drawing(); + rl::drawText("PRESS [ENTER] TO PLAY AGAIN", rl::getScreenWidth() / 2 - rl::measureText("PRESS [ENTER] TO PLAY AGAIN", 20) / 2, rl::getScreenHeight() / 2 - 50, 20, rl::GRAY); return; } @@ -296,22 +295,22 @@ fn void draw_game() switch (grid[i][j]) { case EMPTY: - raylib::draw_line(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, raylib::LIGHTGRAY ); - raylib::draw_line(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY ); - raylib::draw_line(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY ); - raylib::draw_line(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY ); + rl::drawLine(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, rl::LIGHTGRAY ); + rl::drawLine(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, rl::LIGHTGRAY ); + rl::drawLine(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, rl::LIGHTGRAY ); + rl::drawLine(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, rl::LIGHTGRAY ); offset.x += SQUARE_SIZE; case FULL: - raylib::draw_rectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, raylib::GRAY); + rl::drawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, rl::GRAY); offset.x += SQUARE_SIZE; case MOVING: - raylib::draw_rectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, raylib::DARKGRAY); + rl::drawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, rl::DARKGRAY); offset.x += SQUARE_SIZE; case BLOCK: - raylib::draw_rectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, raylib::LIGHTGRAY); + rl::drawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, rl::LIGHTGRAY); offset.x += SQUARE_SIZE; case FADING: - raylib::draw_rectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, fading_color); + rl::drawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, fading_color); offset.x += SQUARE_SIZE; default: } @@ -334,13 +333,13 @@ fn void draw_game() switch (incoming_piece[i][j]) { case EMPTY: - raylib::draw_line(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, raylib::LIGHTGRAY); - raylib::draw_line(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY); - raylib::draw_line(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY); - raylib::draw_line(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, raylib::LIGHTGRAY); + rl::drawLine(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, rl::LIGHTGRAY); + rl::drawLine(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, rl::LIGHTGRAY); + rl::drawLine(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, rl::LIGHTGRAY); + rl::drawLine(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, rl::LIGHTGRAY); offset.x += SQUARE_SIZE; case MOVING: - raylib::draw_rectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, raylib::GRAY); + rl::drawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, rl::GRAY); offset.x += SQUARE_SIZE; default: break; @@ -351,14 +350,13 @@ fn void draw_game() offset.y += SQUARE_SIZE; } - raylib::draw_text("INCOMING:", offset.x, offset.y - 100, 10, raylib::GRAY); - raylib::draw_text(raylib::text_format("LINES: %04i", lines), offset.x, offset.y + 20, 10, raylib::GRAY); + rl::drawText("INCOMING:", offset.x, offset.y - 100, 10, rl::GRAY); + rl::drawText(rl::textFormat("LINES: %04i", lines), offset.x, offset.y + 20, 10, rl::GRAY); if (pause) { - raylib::draw_text("GAME PAUSED", SCREEN_WIDTH / 2 - raylib::measure_text("GAME PAUSED", 40)/2, SCREEN_HEIGHT/2 - 40, 40, raylib::GRAY); + rl::drawText("GAME PAUSED", SCREEN_WIDTH / 2 - rl::measureText("GAME PAUSED", 40)/2, SCREEN_HEIGHT/2 - 40, 40, rl::GRAY); } - raylib::end_drawing(); } // Unload game variables @@ -415,7 +413,7 @@ fn bool create_piece() fn void get_random_piece() { - int random = raylib::get_random_value(0, 6); + int random = rl::getRandomValue(0, 6); for (int i = 0; i < 4; i++) { @@ -508,7 +506,7 @@ fn bool resolve_lateral_movement() bool collision = false; // Piece movement - if (raylib::is_key_down(keyboard::LEFT)) // Move left + if (rl::isKeyDown(rl::KEY_LEFT)) // Move left { // Check if is possible to move to left for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) @@ -542,7 +540,7 @@ fn bool resolve_lateral_movement() piece_position_x--; } } - else if (raylib::is_key_down(keyboard::RIGHT)) // Move right + else if (rl::isKeyDown(rl::KEY_RIGHT)) // Move right { // Check if is possible to move to right for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) @@ -587,7 +585,7 @@ fn bool resolve_lateral_movement() fn bool resolve_turn_movement() { // Input for turning the piece - if (raylib::is_key_down(keyboard::UP)) + if (rl::isKeyDown(rl::KEY_UP)) { GridSquare aux; bool checker = false; @@ -790,5 +788,4 @@ fn int delete_complete_lines() } } return lines_to_erase; -} - +} \ No newline at end of file