/******************************************************************************************* * * raylib [shapes] example - collision area * * Example originally created with raylib 2.5, last time updated with raylib 2.5 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software * * Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" #include // Required for: abs() //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ int main(void) { // Initialization //--------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area"); int r1 = 40; int c1x = 200; int c1y = 200; int r2 = 40; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //---------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { int c2x = GetMouseX(); int c2y = GetMouseY(); //----------------------------------------------------- // Draw //----------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); Color col = BLUE; if (CheckCollisionCircles((Vector2) { c1x, c1y }, r1, (Vector2) { c2x, c2y }, r2)) col = YELLOW; else col = BLUE; DrawCircle(c1x, c1y, r1, RED); DrawCircle(c2x, c2y, r2, col); DrawFPS(10, 10); EndDrawing(); //----------------------------------------------------- } // De-Initialization //--------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //---------------------------------------------------------- return 0; }