Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sem2/BoykoAK/Practice/Button.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Button.h"

Button::Button() {};


void Button::SetButtonSprite(sf::Texture t) {
B_Sprite.setTexture(t);
}

bool Button::IsMouseOverButton(sf::RenderWindow& window) {
float btnX = B_Sprite.getPosition().x;
float btnY = B_Sprite.getPosition().y;

float btnX_1 = B_Sprite.getPosition().x + B_Sprite.getLocalBounds().width;
float btnY_1 = B_Sprite.getPosition().y + B_Sprite.getLocalBounds().height;


float mouseX = sf::Mouse::getPosition(window).x;
float mouseY = sf::Mouse::getPosition(window).y;

if (mouseX < btnX_1 && mouseX > btnX && mouseY < btnY_1 && mouseY > btnY) {
return true;
}
return false;
}
18 changes: 18 additions & 0 deletions sem2/BoykoAK/Practice/Button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <iostream>
#include <SFML/Graphics.hpp>

class Button
{
public:
sf::Texture B_Texture;
sf::Sprite B_Sprite;

Button();


void SetActivity(bool n); // { isActive = n; }
void SetButtonSprite(sf::Texture t); //{B_Sprite.setTexture(t);}
bool IsMouseOverButton(sf::RenderWindow& window);
};

Loading