From b4472061c4c23b59a6d4c52e34eb38e68d766807 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 13 Jun 2010 16:04:40 +0200 Subject: Added wriggle. Moved vector- and matrix-classes to wriggle. --- .gitmodules | 3 ++ SConstruct | 12 +++-- engine/bulletpattern.cpp | 2 +- engine/bulletpattern.h | 2 +- engine/config.h | 4 +- engine/enemy.h | 2 +- engine/matrix.cpp | 45 ---------------- engine/matrix.h | 26 --------- engine/vector.cpp | 133 ----------------------------------------------- engine/vector.h | 58 --------------------- wriggle | 1 + 11 files changed, 18 insertions(+), 270 deletions(-) create mode 100644 .gitmodules delete mode 100644 engine/matrix.cpp delete mode 100644 engine/matrix.h delete mode 100644 engine/vector.cpp delete mode 100644 engine/vector.h create mode 160000 wriggle diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..aabe04f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "wriggle"] + path = wriggle + url = git://git.jvnv.net/wriggle diff --git a/SConstruct b/SConstruct index 1a49017..7054033 100644 --- a/SConstruct +++ b/SConstruct @@ -12,9 +12,9 @@ AddOption('--profiling', action = 'store_true') if env['PLATFORM'] == 'darwin': env.Append(CPPFLAGS = '') env.Append(LINKFLAGS = '') - env.Append(CPPPATH = ['/opt/local/include', '/opt/local/include/freetype2']) + env.Append(CPPPATH = ['.', '/opt/local/include', '/opt/local/include/freetype2']) env.Append(LIBS = ['ftgl']) - env.Append(LIBPATH = ['/opt/local/lib']) + env.Append(LIBPATH = ['.', '/opt/local/lib']) env.Append(FRAMEWORKS = ['SDL', 'SDL_image', 'Cocoa', 'OpenGL', 'AppKit']) engine.append('engine/SDLMain.m') else: @@ -29,6 +29,12 @@ if GetOption('profiling'): env.Append(CPPFLAGS = ['-pg']) env.Append(LINKFLAGS = ['-pg']) -env.Program('foo', ['main.cpp'] + engine) +env.Library('wriggle', Glob('wriggle/*.cpp')) +env.Append(LIBS = ['wriggle']) + +env.Library('engine', engine) +env.Append(LIBS = ['engine']) + +env.Program('foo', ['main.cpp']) # vim: syn=python diff --git a/engine/bulletpattern.cpp b/engine/bulletpattern.cpp index 39f6742..eabf554 100644 --- a/engine/bulletpattern.cpp +++ b/engine/bulletpattern.cpp @@ -1,6 +1,6 @@ #include #include "bulletpattern.h" -#include "matrix.h" +#include BulletPattern1::BulletPattern1(const Vector2& initpos) { num_bullets = steps = 0; diff --git a/engine/bulletpattern.h b/engine/bulletpattern.h index ab87635..5656680 100644 --- a/engine/bulletpattern.h +++ b/engine/bulletpattern.h @@ -1,7 +1,7 @@ #ifndef BULLETPATTERN_H #define BULLETPATTERN_H -#include "vector.h" +#include #include "struct.h" #include diff --git a/engine/config.h b/engine/config.h index 6884b1a..cae33b4 100644 --- a/engine/config.h +++ b/engine/config.h @@ -2,8 +2,8 @@ #define CONFIG_H namespace Config { - const unsigned int window_w = 1280; - const unsigned int window_h = 800; + const unsigned int window_w = 1440; + const unsigned int window_h = 1080; const float viewport_x = 15.0 / 1080.0; const float viewport_y = 15.0 / 1080.0; diff --git a/engine/enemy.h b/engine/enemy.h index 7396b55..ae8e599 100644 --- a/engine/enemy.h +++ b/engine/enemy.h @@ -1,7 +1,7 @@ #ifndef ENEMY_H #define ENEMY_H -#include "vector.h" +#include #include "texture.h" #include "bulletpattern.h" diff --git a/engine/matrix.cpp b/engine/matrix.cpp deleted file mode 100644 index 5970123..0000000 --- a/engine/matrix.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "matrix.h" - -#include - -Matrix2::Matrix2() { - m[0][0] = m[0][1] = - m[1][0] = m[1][1] = 0; -} - -Matrix2::Matrix2(float m00, float m01, float m10, float m11) { - m[0][0] = m00; - m[0][1] = m01; - m[1][0] = m10; - m[1][1] = m11; -} - -Matrix2 Matrix2::operator*(const Matrix2& mat) { - return Matrix2( - m[0][0] * mat.m[0][0] + m[0][1] * mat.m[1][0], - m[0][0] * mat.m[0][1] + m[0][1] * mat.m[1][1], - m[1][0] * mat.m[0][0] + m[1][1] * mat.m[1][0], - m[1][0] * mat.m[0][1] + m[1][1] * mat.m[1][1]); -} - -Matrix2 Matrix2::operator*(float f) { - return Matrix2( - m[0][0] * f, - m[0][1] * f, - m[1][0] * f, - m[1][1] * f); -} - -Vector2 Matrix2::operator*(const Vector2& v) { - return Vector2( - m[0][0] * v.x + m[0][1] * v.y, - m[1][0] * v.x + m[1][1] * v.y); -} - -Matrix2 rotation_matrix(float rot) { - float s = sinf(rot); - float c = cosf(rot); - return Matrix2( - c, -s, - s, c); -} \ No newline at end of file diff --git a/engine/matrix.h b/engine/matrix.h deleted file mode 100644 index 8be483a..0000000 --- a/engine/matrix.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MATRIX_H -#define MATRIX_H - -#include "vector.h" - -template -class Matrix { - public: - float m[M][N]; -}; - -class Matrix2 : Matrix<2, 2> { - public: - Matrix2(); - Matrix2(float m00, float m01, float m10, float m11); - - Matrix2 operator*(const Matrix2& mat); - - Matrix2 operator*(float f); - - Vector2 operator*(const Vector2& v); -}; - -Matrix2 rotation_matrix(float rot); - -#endif diff --git a/engine/vector.cpp b/engine/vector.cpp deleted file mode 100644 index 6c71991..0000000 --- a/engine/vector.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "vector.h" - -Vector2::Vector2() { - x = y = 0; -} - -Vector2::Vector2(float p1, float p2) { - x = p1; - y = p2; -} - -Vector2::Vector2(const Vector2& v) { - x = v.x; - y = v.y; -} - -Vector2& Vector2::operator=(const Vector2& v) { - x = v.x; - y = v.y; - return *this; -} - -Vector2& Vector2::operator+=(const Vector2& v) { - x += v.x; - y += v.y; - return *this; -} - -Vector2& Vector2::operator+(const Vector2& v) { - return Vector2(*this) += v; -} - -Vector2& Vector2::operator-=(const Vector2& v) { - x -= v.x; - y -= v.y; - return *this; -} - -Vector2& Vector2::operator-(const Vector2& v) { - return Vector2(*this) -= v; -} - -Vector3::Vector3() : Vector2() { - z = 0; -} - -Vector3::Vector3(float p1, float p2, float p3) { - x = p1; - y = p2; - z = p3; -} - -Vector3::Vector3(const Vector3& v) { - x = v.x; - y = v.y; - z = v.z; -} - -Vector3& Vector3::operator=(const Vector3& v) { - x = v.x; - y = v.y; - z = v.z; - return *this; -} - -Vector3& Vector3::operator+=(const Vector3& v) { - x += v.x; - y += v.y; - z += v.z; - return *this; -} - -Vector3& Vector3::operator+(const Vector3& v) { - return Vector3(*this) += v; -} - -Vector3& Vector3::operator-=(const Vector3& v) { - x -= v.x; - y -= v.y; - z -= v.z; - return *this; -} - -Vector3& Vector3::operator-(const Vector3& v) { - return Vector3(*this) -= v; -} - -Vector4::Vector4() : Vector3() { - w = 0; -} - -Vector4::Vector4(float p1, float p2, float p3, float p4) : Vector3(p1, p2, p3) { - w = p4; -} - -Vector4::Vector4(const Vector4& v) { - x = v.x; - y = v.y; - z = v.z; - w = v.w; -} - -Vector4& Vector4::operator=(const Vector4& v) { - x = v.x; - y = v.y; - z = v.z; - w = v.w; - return *this; -} - -Vector4& Vector4::operator+=(const Vector4& v) { - x += v.x; - y += v.y; - z += v.z; - w += v.w; - return *this; -} - -Vector4& Vector4::operator+(const Vector4& v) { - return Vector4(*this) += v; -} - -Vector4& Vector4::operator-=(const Vector4& v) { - x -= v.x; - y -= v.y; - z -= v.z; - w -= v.w; - return *this; -} - -Vector4& Vector4::operator-(const Vector4& v) { - return Vector4(*this) -= v; -} diff --git a/engine/vector.h b/engine/vector.h deleted file mode 100644 index 8d85684..0000000 --- a/engine/vector.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _VECTOR_H_ -#define _VECTOR_H_ - -class Vector2 { - public: - union { - float x, r; - }; - union { - float y, g; - }; - - Vector2(); - Vector2(float p1, float p2); - Vector2(const Vector2& v); - - Vector2& operator=(const Vector2& v); - Vector2& operator+=(const Vector2& v); - Vector2& operator+(const Vector2& v); - Vector2& operator-=(const Vector2& v); - Vector2& operator-(const Vector2& v); -}; - -class Vector3 : public Vector2 { - public: - union { - float z, b; - }; - - Vector3(); - Vector3(float p1, float p2, float p3); - Vector3(const Vector3& v); - - Vector3& operator=(const Vector3& v); - Vector3& operator+=(const Vector3& v); - Vector3& operator+(const Vector3& v); - Vector3& operator-=(const Vector3& v); - Vector3& operator-(const Vector3& v); -}; - -class Vector4 : public Vector3 { - public: - union { - float w, a; - }; - - Vector4(); - Vector4(float p1, float p2, float p3, float p4); - Vector4(const Vector4& v); - - Vector4& operator=(const Vector4& v); - Vector4& operator+=(const Vector4& v); - Vector4& operator+(const Vector4& v); - Vector4& operator-=(const Vector4& v); - Vector4& operator-(const Vector4& v); -}; - -#endif diff --git a/wriggle b/wriggle new file mode 160000 index 0000000..f1c0772 --- /dev/null +++ b/wriggle @@ -0,0 +1 @@ +Subproject commit f1c0772af07f0339bda5a9abeaf4f869de9868e1 -- cgit v1.2.3