Added the SFML vector class. Need to extend it to have

the vector operations I want
 Changes to be committed:
	modified:   CMakeLists.txt
	modified:   README.md
	renamed:    src/Curses.h -> include/Curses.h
	new file:   include/Vector3.h
	new file:   src/Vector3.cpp
master
mitchellhansen 8 years ago
parent c5858bca3e
commit bf45af9bab

@ -2,11 +2,11 @@ set(PNAME Game)
set(SFML_ROOT root CACHE STRING "User specified path")
set(SFML_VERSION 2.3)
set(SFML_VERSION 2.1)
set(SFML_COMPONENTS graphics window system network audio)
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
project(${PNAME})
@ -16,7 +16,7 @@ include_directories(${SFML_INCLUDE_DIR}/include)
include_directories(include)
file(GLOB SOURCES "src/*.cpp")
add_executable(${PNAME} ${SOURCES})
add_executable(${PNAME} ${SOURCES} include/Vector3.cpp include/Vector3.h)
target_link_libraries(${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})

@ -1,3 +1,30 @@
# Install instructions :
# SFML Template for Windows, Mac, and Linux
### Requirements
* SFML files for your OS. Found [here](http://www.sfml-dev.org/download.php)
* CMake
#### Clone the Repo
```git clone https://github.com/MitchellHansen/SFML_CMake_Template```
### Windows
* Open the CMake GUI and under "Where is the source code" enter the path that you cloned the repo into. For example ```C:/Users/mrh/Desktop/SFML_CMake_Template```
* Under "Where to build the binaries" enter the destination you want you project to build to. Traditionally this is placed in /build. For example ```C:/Users/mrh/Desktop/SFML_CMake_Template/build```
* Hit the configure button and choose from the dropdown box your generator. As this is on Windows I'll assume you're using Visual Studio, select your version and the platform you want to build for. ```Visual Studio VV YYYY``` (32 bit) or ```Visual Studio VV YYYY 64``` (64 bit). Press Finish when done.
* If at any time you want to re-enter this infomation, hit file -> delete cache and then press configure again.
* CMake will now complain about an error in the configuration process as it can't find where you downloaded SFML to. I usually place libs in a seperate drive, so I would replace ```root``` in the ```SFML_ROOT``` row with ```Z:/cpp_libs/SFML-2.3.2-windows-vc14-32-bit```
* Press Generate and CMake will now generate and place all the files required by Visual Studio in your ```build``` directory
* Open up this directory in your file explorer and open ```Game.sln```
* In your solution explorer set Game as the starup project and hit F5 to run the project!
When I get the chance to write them

@ -0,0 +1,140 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef GAME_VECTOR3_H
#define GAME_VECTOR3_H
template <typename T>
class Vector3
{
public:
// Default constructor
// Creates a Vector3(0, 0, 0).
Vector3();
// Construct the vector from its coordinates
Vector3(T X, T Y, T Z);
// Construct the vector from another type of vector
// This constructor doesn't replace the copy constructor,
// it's called only when U != T.
// A call to this constructor will fail to compile if U
// is not convertible to T.
template <typename U>
explicit Vector3(const Vector3<U>& vector);
// Member data
T x;
T y;
T z;
};
// Vector3
// Overload of unary operator -
// left Vector to negate
// Memberwise opposite of the vector
template <typename T>
Vector3<T> operator -(const Vector3<T>& left);
// Overload of binary operator +=
// This operator performs a memberwise addition of both vectors,
// and assigns the result to left.
// returns Reference to left
template <typename T>
Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right);
// Overload of binary operator -=
// This operator performs a memberwise subtraction of both vectors,
// and assigns the result to left.
// returns Reference to left
template <typename T>
Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right);
// Overload of binary operator +
// returns Memberwise addition of both vectors
template <typename T>
Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right);
// Overload of binary operator -
// returns Memberwise subtraction of both vectors
template <typename T>
Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right);
// Overload of binary operator *
// returns Memberwise multiplication by right
template <typename T>
Vector3<T> operator *(const Vector3<T>& left, T right);
// Overload of binary operator *
// returns Memberwise multiplication by left
template <typename T>
Vector3<T> operator *(T left, const Vector3<T>& right);
// Overload of binary operator *=
// This operator performs a memberwise multiplication by right,
// and assigns the result to left.
// returns Reference to left
template <typename T>
Vector3<T>& operator *=(Vector3<T>& left, T right);
// Overload of binary operator /
// returns Memberwise division by right
template <typename T>
Vector3<T> operator /(const Vector3<T>& left, T right);
// Overload of binary operator /=
// This operator performs a memberwise division by right,
// and assigns the result to left.
// returns Reference to left
template <typename T>
Vector3<T>& operator /=(Vector3<T>& left, T right);
// Overload of binary operator ==
// This operator compares strict equality between two vectors.
// returns True if left is equal to right
template <typename T>
bool operator ==(const Vector3<T>& left, const Vector3<T>& right);
// Overload of binary operator !=
// This operator compares strict difference between two vectors.
// returns True if left is not equal to right
template <typename T>
bool operator !=(const Vector3<T>& left, const Vector3<T>& right);
#include <SFML/System/Vector3.inl>
// Define the most common types
typedef Vector3<int> Vector3i;
typedef Vector3<float> Vector3f;
}
#endif
};
#endif

@ -0,0 +1,5 @@
//
// Created by Mitchell Hansen on 8/7/16.
//
#include "Vector3.h"
Loading…
Cancel
Save