-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (32 loc) · 1 KB
/
Copy pathmain.cpp
File metadata and controls
39 lines (32 loc) · 1 KB
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
#include <raylib.h>
#include <iostream>
#include "button.hpp"
int main()
{
InitWindow(800, 600, "Raylib Buttons Tutorial");
SetTargetFPS(60);
Texture2D background = LoadTexture("Graphics/background.png");
Button startButton{"Graphics/start_button.png", {300, 150}, 0.65};
Button exitButton{"Graphics/exit_button.png", {300, 300}, 0.65};
bool exit = false;
while(WindowShouldClose() == false && exit == false)
{
Vector2 mousePosition = GetMousePosition();
bool mousePressed = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
if(startButton.isPressed(mousePosition, mousePressed))
{
std::cout << "Start Button Pressed" << std::endl;
}
if(exitButton.isPressed(mousePosition, mousePressed))
{
exit = true;
}
BeginDrawing();
ClearBackground(BLACK);
DrawTexture(background, 0, 0, WHITE);
startButton.Draw();
exitButton.Draw();
EndDrawing();
}
CloseWindow();
}