Remove Point2f, replace with Vector2f

This commit is contained in:
Bram Verhulst
2024-04-17 13:54:48 +02:00
parent 64e96ab209
commit db83ae5e13
42 changed files with 494 additions and 634 deletions

View File

@@ -1,6 +1,8 @@
#pragma once
#include <string>
#include "Vector2f.h"
struct Window
{
explicit Window( const std::string& title = "Title", float width = 320.0f,
@@ -12,45 +14,44 @@ struct Window
bool isVSyncOn;
};
struct Point2f
{
Point2f( );
explicit Point2f( float x, float y );
//Point2f(int x, int y); //Stupid fix for it giving an error
//operator
Point2f operator+( const Point2f& other ) const;
Point2f operator+=( const Point2f& other ) const;
Point2f operator*( float other ) const;
Point2f operator*( int other ) const;
Point2f operator*( const Point2f& other ) const;
Point2f operator/( float other ) const;
Point2f operator-( const Point2f& other ) const;
float x;
float y;
};
Point2f operator/(float right, const Point2f& left);
Point2f operator*(float right, const Point2f& left);
std::ostream& operator<<(std::ostream& os, const Point2f& p);
// struct Vector2f
// {
// Vector2f( );
// explicit Vector2f( float x, float y );
// //Vector2f(int x, int y); //Stupid fix for it giving an error
//
// //operator
// Vector2f operator+( const Vector2f& other ) const;
// Vector2f operator+=( const Vector2f& other ) const;
// Vector2f operator*( float other ) const;
// Vector2f operator*( int other ) const;
// Vector2f operator*( const Vector2f& other ) const;
// Vector2f operator/( float other ) const;
// Vector2f operator-( const Vector2f& other ) const;
//
//
// float x;
// float y;
// };
//
// Vector2f operator/(float right, const Vector2f& left);
// Vector2f operator*(float right, const Vector2f& left);
//
// std::ostream& operator<<(std::ostream& os, const Vector2f& p);
struct Rectf
{
Rectf( );
explicit Rectf( float left, float bottom, float width, float height );
Rectf(Point2f pos, Point2f size);
//explicit Rectf( int left, int bottom, int width, int height ); //Stupid fix for it giving an error (same as Point2f)
Rectf(Vector2f pos, Vector2f size);
//explicit Rectf( int left, int bottom, int width, int height ); //Stupid fix for it giving an error (same as Vector2f)
Point2f BottomLeft() const { return Point2f{ left, bottom }; }
Vector2f BottomLeft() const { return Vector2f{ left, bottom }; }
float left;
float bottom;
float width;
float height;
};
@@ -68,10 +69,10 @@ struct Color4f
struct Circlef
{
Circlef( );
explicit Circlef( const Point2f& center, float radius );
explicit Circlef( const Vector2f& center, float radius );
explicit Circlef( float centerX, float centerY, float radius );
Point2f center;
Vector2f center;
float radius;
};
@@ -79,10 +80,10 @@ struct Circlef
struct Ellipsef
{
Ellipsef( );
explicit Ellipsef( const Point2f& center, float radiusX, float radiusY );
explicit Ellipsef( const Vector2f& center, float radiusX, float radiusY );
explicit Ellipsef( float centerX, float centerY, float radiusX, float radiusY );
Point2f center;
Vector2f center;
float radiusX;
float radiusY;
};