0% found this document useful (0 votes)
3 views1 page

Proiect 1 Raylib

This C++ program uses the raylib library to create a simple graphical application that displays a bouncing ball on the screen. The ball moves within a defined window and reverses direction upon hitting the edges. The program initializes a window, sets the frame rate, and continuously updates the ball's position while drawing it on a blue background.

Uploaded by

ionsins809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Proiect 1 Raylib

This C++ program uses the raylib library to create a simple graphical application that displays a bouncing ball on the screen. The ball moves within a defined window and reverses direction upon hitting the edges. The program initializes a window, sets the frame rate, and continuously updates the ball's position while drawing it on a blue background.

Uploaded by

ionsins809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <iostream>

#include <raylib.h>

using namespace std;

int main () {

const int SCREEN_WIDTH = 800;


const int SCREEN_HEIGHT = 600;
int ball_x = 100;
int ball_y = 100;
int ball_speed_x = 10;
int ball_speed_y = 10;
int ball_radius = 35;

cout << "Hello World" << endl;

InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "M1hn3a e shaorma");


SetTargetFPS(60);

int i = 0;

while (WindowShouldClose() == false){

ball_x += ball_speed_x;
ball_y += ball_speed_y;

if(ball_x + ball_radius >= SCREEN_WIDTH || ball_x - ball_radius <= 0)


{
ball_speed_x *= -1;

if(ball_y + ball_radius >= SCREEN_HEIGHT || ball_y - ball_radius <= 0)


{
ball_speed_y *= -1;

BeginDrawing();
ClearBackground(BLUE);
DrawCircle(ball_x,ball_y,ball_radius, WHITE);

EndDrawing();

CloseWindow();
}

You might also like