Guest User

Untitled

a guest
Jul 15th, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include <raylib.h>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cmath>
  5.  
  6.  
  7. std::vector<Rectangle> player1_rectangles;
  8. std::vector<Rectangle> player2_rectangles;
  9.  
  10.  
  11.  
  12. int main(){
  13. int WINDOW_WIDTH = 720;
  14. int WINDOW_HEIGHT = 720;
  15. InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "....");
  16. SetTargetFPS(10);
  17.  
  18. Vector2 linetop; linetop.x = WINDOW_WIDTH/2; linetop.y = 0;
  19. Vector2 linebottom; linebottom.x = WINDOW_WIDTH/2; linebottom.y = WINDOW_HEIGHT;
  20.  
  21. int board1_posx = WINDOW_WIDTH/20; int board1_posy = WINDOW_HEIGHT/8;
  22. int board1_width = WINDOW_WIDTH/2.5; int board1_height = WINDOW_WIDTH/2.5;
  23. float small_rec_len = (board1_width-11.0f)/10.0f; int small_rec_height = (board1_height-11.0f)/10.0f;
  24.  
  25. for(int n = 0; n < 2; n++){
  26. for(int j = 0; j < 10; j++){
  27. for(int i = 0; i < 10; i++){
  28. if(n == 0){
  29. float posx = (board1_posx+1)+small_rec_len*i+1*i;
  30. float posy = (board1_posy+1)+small_rec_height*j+1*j;
  31. float width = small_rec_len;
  32. float height = small_rec_height;
  33. player1_rectangles.push_back(Rectangle{posx, posy, width, height});
  34. }
  35. else
  36. player2_rectangles.push_back(Rectangle{(board1_posx+(WINDOW_WIDTH/2.0f)*n)+small_rec_len*i, board1_posy+(small_rec_height*j)+j, small_rec_len, small_rec_height});
  37. }
  38. }
  39. }
  40.  
  41.  
  42. while(!WindowShouldClose()){
  43.  
  44. BeginDrawing();
  45. ClearBackground({100,100,100,60});
  46.  
  47. for(int n = 0; n < 2; n++){
  48. DrawRectangle(board1_posx+(WINDOW_WIDTH/2)*n, board1_posy, board1_width, board1_height, SKYBLUE);
  49. }
  50.  
  51. for(Rectangle const &each : player1_rectangles){
  52. DrawRectangle(static_cast<int>(each.x), static_cast<int>(each.y), static_cast<int>(each.width), static_cast<int>(each.height), BROWN);
  53. }
  54. for(Rectangle const &each : player2_rectangles){
  55. DrawRectangle(each.x, each.y, each.width, each.height, BROWN);
  56. }
  57.  
  58. // a line for center
  59. DrawLineEx(linetop, linebottom, WINDOW_WIDTH/72, PINK);
  60. EndDrawing();
  61. DrawFPS(10, 10);
  62. }
  63.  
  64. CloseWindow();
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment