Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <raylib.h>
- #include <iostream>
- #include <vector>
- #include <cmath>
- std::vector<Rectangle> player1_rectangles;
- std::vector<Rectangle> player2_rectangles;
- int main(){
- int WINDOW_WIDTH = 720;
- int WINDOW_HEIGHT = 720;
- InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "....");
- SetTargetFPS(10);
- Vector2 linetop; linetop.x = WINDOW_WIDTH/2; linetop.y = 0;
- Vector2 linebottom; linebottom.x = WINDOW_WIDTH/2; linebottom.y = WINDOW_HEIGHT;
- int board1_posx = WINDOW_WIDTH/20; int board1_posy = WINDOW_HEIGHT/8;
- int board1_width = WINDOW_WIDTH/2.5; int board1_height = WINDOW_WIDTH/2.5;
- float small_rec_len = (board1_width-11.0f)/10.0f; int small_rec_height = (board1_height-11.0f)/10.0f;
- for(int n = 0; n < 2; n++){
- for(int j = 0; j < 10; j++){
- for(int i = 0; i < 10; i++){
- if(n == 0){
- float posx = (board1_posx+1)+small_rec_len*i+1*i;
- float posy = (board1_posy+1)+small_rec_height*j+1*j;
- float width = small_rec_len;
- float height = small_rec_height;
- player1_rectangles.push_back(Rectangle{posx, posy, width, height});
- }
- else
- 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});
- }
- }
- }
- while(!WindowShouldClose()){
- BeginDrawing();
- ClearBackground({100,100,100,60});
- for(int n = 0; n < 2; n++){
- DrawRectangle(board1_posx+(WINDOW_WIDTH/2)*n, board1_posy, board1_width, board1_height, SKYBLUE);
- }
- for(Rectangle const &each : player1_rectangles){
- DrawRectangle(static_cast<int>(each.x), static_cast<int>(each.y), static_cast<int>(each.width), static_cast<int>(each.height), BROWN);
- }
- for(Rectangle const &each : player2_rectangles){
- DrawRectangle(each.x, each.y, each.width, each.height, BROWN);
- }
- // a line for center
- DrawLineEx(linetop, linebottom, WINDOW_WIDTH/72, PINK);
- EndDrawing();
- DrawFPS(10, 10);
- }
- CloseWindow();
- }
Advertisement
Add Comment
Please, Sign In to add comment