You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.9 KiB
67 lines
1.9 KiB
#include "buttons.h"
|
|
#include "../game.h"
|
|
#include "screenIDs.h"
|
|
#include "stdio.h"
|
|
#include "raylib.h"
|
|
|
|
void executeButton(Button *button, Game *game){
|
|
button->state = 0;
|
|
switch(button->id){
|
|
case 0: // continue game
|
|
if(game->screen == SCREEN_PAUSE){
|
|
game->screen = SCREEN_GAME;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void drawButton(Button * button){
|
|
printf("%d\n", button->state);
|
|
updateButtonState(button);
|
|
printf("DRAW JETZT\n");
|
|
DrawTexture(*button->textures[button->state], button->position.x, button->position.y, WHITE);
|
|
printf("funktioniert\n");
|
|
}
|
|
|
|
int updateButtonState(Button * button){
|
|
if(GetMouseX() > button->position.x &&
|
|
GetMouseX() < button->position.x + button->textures[button->state]->width &&
|
|
GetMouseY() > button->position.y &&
|
|
GetMouseY() < button->position.y + button->textures[button->state]->height
|
|
){
|
|
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){
|
|
button->state = 2;
|
|
return 2;
|
|
}
|
|
button->state = 1;
|
|
return 1;
|
|
}
|
|
button->state = 0;
|
|
return 0;
|
|
}
|
|
|
|
int isButtonHovered(Button * button){
|
|
if(GetMouseX() > button->position.x &&
|
|
GetMouseX() < button->position.x + button->textures[0]->width &&
|
|
GetMouseY() > button->position.y &&
|
|
GetMouseY() < button->position.y + button->textures[0]->height
|
|
){
|
|
return button->state = 1;
|
|
}
|
|
return button->state = 0;
|
|
}
|
|
|
|
int isButtonPressed(Button * button){
|
|
if(GetMouseX() > button->position.x &&
|
|
GetMouseX() < button->position.x + button->textures[0]->width &&
|
|
GetMouseY() > button->position.y &&
|
|
GetMouseY() < button->position.y + button->textures[0]->height
|
|
){
|
|
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
|
return button->state = 2;
|
|
}
|
|
}
|
|
return button->state = 0;
|
|
}
|
|
|