GianaRect.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "raylib.h"
  2. void c64rectangle(int x, int y, int w, int h,int thick);
  3. int main(void)
  4. {
  5. // Initialization
  6. //--------------------------------------------------------------------------------------
  7. const int screenWidth = 800;
  8. const int screenHeight = 450;
  9. InitWindow(screenWidth, screenHeight, "raylib example.");
  10. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  11. //--------------------------------------------------------------------------------------
  12. // Main game loop
  13. while (!WindowShouldClose()) // Detect window close button or ESC key
  14. {
  15. // Update
  16. //----------------------------------------------------------------------------------
  17. //----------------------------------------------------------------------------------
  18. // Draw
  19. //----------------------------------------------------------------------------------
  20. BeginDrawing();
  21. ClearBackground(RAYWHITE);
  22. for(int y=0;y<screenHeight;y+=64){
  23. for(int x=0;x<screenWidth;x+=64){
  24. c64rectangle(x,y,64,64,4);
  25. }}
  26. for(int y=128;y<screenHeight-128;y+=32){
  27. for(int x=128;x<screenWidth-128;x+=32){
  28. c64rectangle(x,y,32,32,2);
  29. }}
  30. EndDrawing();
  31. //----------------------------------------------------------------------------------
  32. }
  33. // De-Initialization
  34. //--------------------------------------------------------------------------------------
  35. CloseWindow(); // Close window and OpenGL context
  36. //--------------------------------------------------------------------------------------
  37. return 0;
  38. }
  39. void c64rectangle(int x, int y, int w, int h,int thick){
  40. Color col1 = (Color){91,91,91,255};
  41. DrawRectangle(x,y,thick,thick,col1);
  42. DrawRectangle(x+w-thick,y,thick,thick,col1);
  43. Color col2 = (Color){120,120,120,255};
  44. DrawRectangle(x+thick,y,w-thick*2,thick,col2);
  45. Color col3 = (Color){105,105,105,255};
  46. DrawRectangle(x,y+thick,thick,h-thick*2,col3);
  47. Color col4 = (Color){114,114,114,255};
  48. DrawRectangle(x+thick*1,y+thick,thick,thick,col4);
  49. DrawRectangle(x+thick*1,y+h-thick*3,thick,thick,col4);
  50. Color col5 = (Color){79,79,79,255};
  51. DrawRectangle(x+thick*2,y+thick,w-thick*4,thick,col5);
  52. DrawRectangle(x+thick*1,y+thick*2,thick,h-thick*3,col5);
  53. Color col6 = (Color){0,0,0,255};
  54. // outside bottom and right black
  55. DrawRectangle(x,y+h-thick,w,thick,col6);
  56. DrawRectangle(x+w-thick,y+thick,thick,h-thick,col6);
  57. // inside black
  58. Color col7 = (Color){58,58,58,255};
  59. DrawRectangle(x+thick*2,y+thick*2,w-thick*4,thick,col6);
  60. DrawRectangle(x+thick*2,y+thick*2,thick,h-thick*4,col6);
  61. DrawRectangle(x+w-thick*2,y+thick*1,thick,thick,col7);
  62. DrawRectangle(x+thick*2,y+h-thick*2,thick,thick,col7);
  63. DrawRectangle(x+w-thick*2,y+h-thick*2,thick,thick,col7);
  64. // Inside area gray
  65. DrawRectangle(x+thick*3,y+thick*3,w-thick*6,h-thick*5,col1);
  66. //
  67. DrawRectangle(x+thick*3,y+h-thick*2,w-thick*5,thick,col3);
  68. DrawRectangle(x+w-thick*3,y+thick*3,thick,h-thick*5,col2);
  69. //
  70. DrawRectangle(x+w-thick*2,y+thick*2,thick,h-thick*4,col5);
  71. }