-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathmain.cpp
43 lines (32 loc) · 951 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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 = 5;
int ball_speed_y = 5;
int ball_radius = 15;
cout << "Hello World" << endl;
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "My first RAYLIB program!");
SetTargetFPS(60);
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(BLACK);
DrawCircle(ball_x,ball_y,ball_radius, WHITE);
EndDrawing();
}
CloseWindow();
}