Animation workshop : Mirror dots


Functions:


FunctionsDesc
bool IsMouseButtonPressed(int button) Check if a mouse button has been pressed once
bool IsMouseButtonDown(int button) Check if a mouse button is being pressed
bool IsMouseButtonReleased(int button) Check if a mouse button has been released once
bool IsMouseButtonUp(int button) Check if a mouse button is NOT being pressed
int GetMouseX(void) Get mouse position X
int GetMouseY(void) Get mouse position Y
Vector2 GetMousePosition(void) Get mouse position XY
void DrawCircle(int centerX, int centerY, float radius, Color color) Draw a color-filled circle

Constants:


MOUSE_BUTTON_LEFT

MOUSE_BUTTON_RIGHT


Structures:


Vector2



  #include "raylib.h"
  
  int main(void){
      const int scr_width=600;
      const int scr_height=450;
      const float radias = 4.0f;
      
      InitWindow(scr_width,scr_height,"2 Dots");
      Vector2 mouse_pos = (Vector2){0,0};
      SetTargetFPS(20);
      
      while(!WindowShouldClose()){
          ClearBackground(WHITE);
          if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)){
          	mouse_pos = GetMousePosition();
          }
          BeginDrawing();                      
           DrawCircle(mouse_pos.x,mouse_pos.y,radias,RED);
           DrawCircle(mouse_pos.y,mouse_pos.x,radias,GREEN);
          EndDrawing(); 
      }
      CloseWindow();
      return 0;
  }
  

ความคิดเห็น