#include "stdio.h" #include "raylib.h" // You can get this file at https://www.raylib.com/ int main() { int left_height = 80; int right_height = 80; int debug_mode = 0; int ball_posx = 320; int ball_posy = 240; float ball_movx = -1; float ball_movy = 1; int score1 = 0; int score2 = 0; InitWindow(640,480,"Test Window"); SetTargetFPS(60); SetExitKey(0); while(!WindowShouldClose()) { //Check for all keys if(IsKeyDown(83) && left_height < 390) { left_height += 10; } if(IsKeyDown(87) && left_height > 10) { left_height -= 10; } if(IsKeyDown(75) && right_height < 390) { right_height += 10; } if(IsKeyDown(73) && right_height > 10) { right_height -= 10; } if(IsKeyPressed(81)) { debug_mode = 1 - debug_mode; } //Move ball if(ball_posy <= 5 || ball_posy >= 475) {ball_movy=-ball_movy;} if(ball_posx <= 10 && left_height <= ball_posy && left_height + 80 >= ball_posy) {ball_movx=-1.05*ball_movx;}; if(ball_posx >= 630 && right_height <= ball_posy && right_height + 80 >= ball_posy) {ball_movx=-1.05*ball_movx;}; if(ball_posx <= 0 || ball_posx >= 640) { if(ball_posx <=0) {score2++;} else {score1++;} ball_posx = 320; ball_posy = 240; ball_movx = -1; ball_movy = 1; } ball_posx += 5 * ball_movx; ball_posy += 5 * ball_movy; BeginDrawing(); ClearBackground(BLACK); if(debug_mode){DrawFPS(0,0);} DrawRectangle(0,left_height,10,80,WHITE); DrawRectangle(630,right_height,10,80,WHITE); DrawRectangle(ball_posx-5,ball_posy-5,10,10,WHITE); DrawText(TextFormat("%i",score1),50,0,20,WHITE); DrawText(TextFormat("%i",score2),640-50,0,20,WHITE); EndDrawing(); if(IsKeyPressed(70)) { ToggleFullscreen(); } } CloseWindow(); return 0; }