mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2026-02-04 09:19:19 +01:00
Update Screen system
Added FuelScreen (Working buttons) Added SellScreen (Nothing working)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "base.h"
|
||||
#include "structs.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Window Constructors
|
||||
//-----------------------------------------------------------------
|
||||
@@ -52,6 +54,10 @@ Point2f operator/(float right, const Point2f& left) {
|
||||
Point2f operator*(float right, const Point2f& left) {
|
||||
return Point2f{ right * left.x, right * left.y };
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& os, const Point2f& p) {
|
||||
os << "Point2f( " << p.x << ", " << p.y << " )" << std::endl;
|
||||
return os;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// Rectf Constructors
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
@@ -26,6 +26,7 @@ struct Point2f
|
||||
Point2f operator*( const Point2f& other ) const;
|
||||
Point2f operator/( float other ) const;
|
||||
Point2f operator-( const Point2f& other ) const;
|
||||
|
||||
|
||||
float x;
|
||||
float y;
|
||||
@@ -34,6 +35,8 @@ struct Point2f
|
||||
Point2f operator/(float right, const Point2f& left);
|
||||
Point2f operator*(float right, const Point2f& left);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Point2f& p);
|
||||
|
||||
struct Rectf
|
||||
{
|
||||
Rectf( );
|
||||
|
||||
@@ -705,6 +705,17 @@ Point2f utils::GetMousePos() {
|
||||
//TODO: make the screen size a global or something
|
||||
return Point2f { float(x), float(500.f - y) };
|
||||
}
|
||||
bool utils::IsMouseButtonDown(int button) {
|
||||
const Uint32 pStates = SDL_GetMouseState(nullptr, nullptr);
|
||||
if (pStates & SDL_BUTTON(button)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static Point2f ViewportSize{ 900.f, 500.f }; //TODO: somehow move this (Ask teacher)
|
||||
Point2f utils::GetViewport() {
|
||||
return ViewportSize;
|
||||
}
|
||||
|
||||
bool utils::isMouseDown(int button) {
|
||||
const Uint32 pStates = SDL_GetMouseState(nullptr, nullptr);
|
||||
|
||||
@@ -112,5 +112,10 @@ namespace utils
|
||||
bool isKeyUp(int keycode);
|
||||
|
||||
Point2f GetMousePos();
|
||||
bool IsMouseButtonDown(int button);
|
||||
|
||||
|
||||
Point2f GetViewport();
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user