-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
45 lines (34 loc) · 1000 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
44
45
#include <iostream>
#include <raylib.h>
using namespace std;
int main() {
Color Dark_Green = Color{ 20, 160, 133, 255 };
const int screenWidth = 800;
const int screenHeight = 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(screenWidth, screenHeight, "My first RAYLIB program!");
SetTargetFPS(60);
while (WindowShouldClose() == false) {
BeginDrawing();
ClearBackground(Dark_Green);
ball_x += ball_speed_x;
ball_y += ball_speed_y;
if (ball_x + ball_radius >= screenWidth || ball_x - ball_radius <= 0)
{
ball_speed_x *= -1;
}
if (ball_y + ball_radius >= screenHeight || ball_y - ball_radius <= 0)
{
ball_speed_y *= -1;
}
DrawCircle(ball_x, ball_y, ball_radius, WHITE);
EndDrawing();
}
CloseWindow();
return 0;
}