From: Patrik Gornicz Date: Fri, 1 May 2009 23:10:29 +0000 (-0400) Subject: Merge branch 'master' into libpg X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?p=physics.git;a=commitdiff_plain;h=41379c9cf8b7128f23a9c285d3e50cad0d5d2de4;hp=d68972132cd142a12dddbc952c095931a2e0a1c6 Merge branch 'master' into libpg Conflicts: Makefile --- diff --git a/Makefile b/Makefile index 9d523b5..6faa1df 100644 --- a/Makefile +++ b/Makefile @@ -13,15 +13,19 @@ else LIBGL := -lGL -lGLU LIBSDL := `sdl-config --libs` endif -LIBS := ${LIBSDL} ${LIBGL} - +LIBMY := -lpg +LIBS := ${LIBSDL} ${LIBGL} ${LIBMY} OPTFLAGS := -O2 DBGFLAGS := -ggdb PRFFLAGS := ${DBGFLAGS} -pg MYFLAGS := -Wall -pedantic -ansi +RPATH := libs/ + VALFLAGS := --leak-check=full +LNKFLAGS := -Wl,-rpath,${RPATH} + ifeq (${WIN32},1) CXXFLAGS := ${OPTFLAGS} else ifeq (${FINAL},1) @@ -36,7 +40,7 @@ else CXX := g++ endif -DIRS := # := start +DIRS := # := start SRCSDIR := src/ SRCS := # := start @@ -73,8 +77,9 @@ CFGS := # := start CFGS += keys.cfg CFGS := $(addprefix ${DSTCFGDIR},${CFGS}) -SRCLIBSDIR := libs/ -DSTLIBSDIR := ${WORKINGDIR} +LIBSDIRNAME := libs/ +SRCLIBSDIR := ${LIBSDIRNAME} +DSTLIBSDIR := ${WORKINGDIR}${LIBSDIRNAME} LIBSTXT := # := start LIBSTXT += COPYING-SDL @@ -86,7 +91,8 @@ LIBSCPY := # := start ifeq (${WIN32},1) LIBSCPY += SDL.dll else - LIBSCPY += libSDL.so + LIBSCPY += libSDL-1.2.so.0 + LIBSCPY += libpg.so.0 endif LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY}) @@ -107,9 +113,16 @@ TARGET := ${WORKINGDIR}${TARGETNAME} DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS}) OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS}) -BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR} + +BLDDIRS := # := start +BLDDIRS += ${OBJSBLDDIRS} +BLDDIRS += ${DEPSBLDDIRS} +BLDDIRS += ${WORKINGDIR} +BLDDIRS += ${DSTCFGDIR} +BLDDIRS += ${DSTLIBSDIR} INCDIRS := ${SRCSDIR} +INCFLAGS := $(addprefix -I, ${INCDIRS}) PRNTFMT := printf "%-5s: %s\n" @@ -137,7 +150,7 @@ all: ${TARGET} ${CFGS} ${LIBSTXT} ${LIBSCPY} ${TXT} # how to link the main target ${TARGETTMP}: ${OBJS} ${Q1}${PRNTFMT} "${CXX}" "$@" - ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} + ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS} # rule to copy tmp target to working directory ${TARGET}: ${TARGETTMP} | ${WORKINGDIR} @@ -167,14 +180,14 @@ ${BLDDIRS}: # rule to make an object file from a .cpp ${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $$(dir $$@) ${Q1}${PRNTFMT} "${CXX}" "$@" - ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< -I "${INCDIRS}" + ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS} # rule to make a depend file from a .cpp # be clever and escape the / chars in file paths # DON'T simply use another sed delimiter or it can't appear in the file paths ${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $$(dir $$@) ${Q1}${PRNTFMT} "DEP" "$@" - ${Q2}${CXX} -MM ${CXXFLAGS} $< -I "${INCDIRS}" | \ + ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \ sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@ CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall diff --git a/libs/libSDL.so b/libs/libSDL-1.2.so.0 similarity index 100% rename from libs/libSDL.so rename to libs/libSDL-1.2.so.0 diff --git a/libs/libpg.so.0 b/libs/libpg.so.0 new file mode 120000 index 0000000..6b17e3b --- /dev/null +++ b/libs/libpg.so.0 @@ -0,0 +1 @@ +/usr/lib/libpg.so.0 \ No newline at end of file diff --git a/src/CollisionInfo.h b/src/CollisionInfo.h index 5d9f1f4..c81888b 100644 --- a/src/CollisionInfo.h +++ b/src/CollisionInfo.h @@ -19,7 +19,7 @@ #ifndef COLLISIONINFO_H #define COLLISIONINFO_H -#include "Vector2.h" +#include /// ***** Header Class ***** diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h index bdf8eb8..9829919 100644 --- a/src/Effects/Effect.h +++ b/src/Effects/Effect.h @@ -18,7 +18,7 @@ #ifndef EFFECT_H #define EFFECT_H -#include "Vector2.h" +#include // Mutual headers ... diff --git a/src/Effects/Gravity.h b/src/Effects/Gravity.h index 91be413..0b7815d 100644 --- a/src/Effects/Gravity.h +++ b/src/Effects/Gravity.h @@ -18,8 +18,9 @@ #ifndef GRAVITY_H #define GRAVITY_H +#include + #include "Effect.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Effects/GravityWell.h b/src/Effects/GravityWell.h index ffbd120..443512d 100644 --- a/src/Effects/GravityWell.h +++ b/src/Effects/GravityWell.h @@ -18,8 +18,9 @@ #ifndef GRAVITYWELL_H #define GRAVITYWELL_H +#include + #include "Effect.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Effects/Screen.h b/src/Effects/Screen.h index 8ed0091..b572593 100644 --- a/src/Effects/Screen.h +++ b/src/Effects/Screen.h @@ -18,8 +18,9 @@ #ifndef SCREEN_H #define SCREEN_H +#include + #include "Effect.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Entities/Ball.cpp b/src/Entities/Ball.cpp index 517c67a..d0563d7 100644 --- a/src/Entities/Ball.cpp +++ b/src/Entities/Ball.cpp @@ -16,9 +16,10 @@ */ #include "Ball.h" -#include "debug.h" -#include "Vector2.h" +#include +#include + #include "graphics/graphics.h" diff --git a/src/Entities/Ball.h b/src/Entities/Ball.h index 4e3219b..e4267e8 100644 --- a/src/Entities/Ball.h +++ b/src/Entities/Ball.h @@ -18,8 +18,9 @@ #ifndef BALL_H #define BALL_H +#include + #include "PhysicsEntity.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 847254a..09e27ab 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -17,7 +17,7 @@ #include "Entity.h" -#include "Vector2.h" +#include /// ***** Constructors/Destructors ***** diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 14242bc..e59f4fd 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -18,7 +18,7 @@ #ifndef ENTITY_H #define ENTITY_H -#include "Vector2.h" +#include /// ***** Header Class ***** diff --git a/src/Entities/Line.cpp b/src/Entities/Line.cpp index 3be227a..793b3cf 100644 --- a/src/Entities/Line.cpp +++ b/src/Entities/Line.cpp @@ -17,7 +17,7 @@ #include "Line.h" -#include "Vector2.h" +#include /// ***** Constructors/Destructors ***** diff --git a/src/Entities/Line.h b/src/Entities/Line.h index e6159d1..a4f94e7 100644 --- a/src/Entities/Line.h +++ b/src/Entities/Line.h @@ -18,8 +18,9 @@ #ifndef LINE_H #define LINE_H +#include + #include "Particle.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Entities/Particle.cpp b/src/Entities/Particle.cpp index 1d7472d..97cbafb 100644 --- a/src/Entities/Particle.cpp +++ b/src/Entities/Particle.cpp @@ -17,7 +17,7 @@ #include "Particle.h" -#include "Vector2.h" +#include /// ***** Constructors/Destructors ***** diff --git a/src/Entities/Particle.h b/src/Entities/Particle.h index 87b53ac..251c8ef 100644 --- a/src/Entities/Particle.h +++ b/src/Entities/Particle.h @@ -18,8 +18,9 @@ #ifndef PARTICLE_H #define PARTICLE_H +#include + #include "Entity.h" -#include "Vector2.h" /// NOTE to SELF diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index d42d271..d20f671 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -16,10 +16,11 @@ */ #include "PhysicsEntity.h" -#include "debug.h" + +#include +#include #include "effectManager.h" -#include "Vector2.h" /// ***** Constructors/Destructors ***** diff --git a/src/Entities/PhysicsEntity.h b/src/Entities/PhysicsEntity.h index 8e83266..e6f2f36 100644 --- a/src/Entities/PhysicsEntity.h +++ b/src/Entities/PhysicsEntity.h @@ -18,8 +18,9 @@ #ifndef PHYSICS_H #define PHYSICS_H +#include + #include "Entity.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Entities/Point.cpp b/src/Entities/Point.cpp index 3031c6f..7083ba2 100644 --- a/src/Entities/Point.cpp +++ b/src/Entities/Point.cpp @@ -17,7 +17,7 @@ #include "Point.h" -#include "Vector2.h" +#include /// ***** Constructors/Destructors ***** diff --git a/src/Entities/Point.h b/src/Entities/Point.h index e0277f7..3845e5a 100644 --- a/src/Entities/Point.h +++ b/src/Entities/Point.h @@ -18,8 +18,9 @@ #ifndef POINT_H #define POINT_H +#include + #include "Particle.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Entities/Polygon.cpp b/src/Entities/Polygon.cpp index 06955c3..9f2eff6 100644 --- a/src/Entities/Polygon.cpp +++ b/src/Entities/Polygon.cpp @@ -16,9 +16,9 @@ */ #include "Polygon.h" -#include "debug.h" -#include "Vector2.h" +#include +#include #include "graphics/graphics.h" diff --git a/src/Entities/Polygon.h b/src/Entities/Polygon.h index 5f3781d..6b115fc 100644 --- a/src/Entities/Polygon.h +++ b/src/Entities/Polygon.h @@ -18,8 +18,9 @@ #ifndef POLYGON_H #define POLYGON_H +#include + #include "PhysicsEntity.h" -#include "Vector2.h" #include using std::vector; diff --git a/src/Entities/WindParticle.cpp b/src/Entities/WindParticle.cpp index bd866ab..dc1274a 100644 --- a/src/Entities/WindParticle.cpp +++ b/src/Entities/WindParticle.cpp @@ -17,7 +17,7 @@ #include "WindParticle.h" -#include "Vector2.h" +#include /// ***** Constructors/Destructors ***** diff --git a/src/Entities/WindParticle.h b/src/Entities/WindParticle.h index d50fbe7..11ddedd 100644 --- a/src/Entities/WindParticle.h +++ b/src/Entities/WindParticle.h @@ -18,8 +18,9 @@ #ifndef WINDPARTICLE_H #define WINDPARTICLE_H +#include + #include "Point.h" -#include "Vector2.h" /// ***** Header Class ***** diff --git a/src/Vector2.cpp b/src/Vector2.cpp deleted file mode 100644 index 2a8c8af..0000000 --- a/src/Vector2.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "Vector2.h" -#include "debug.h" - -#include "mathw.h" - -/// ***** Constructors/Destructors ***** - -Vector2::Vector2() - : m_fX(0), m_fY(0) -{ - -} -Vector2::Vector2(float fX, float fY) - : m_fX(fX), m_fY(fY) -{ - -} - -/// ***** Public Class Methods ***** - -void Vector2::zero() -{ - m_fX = 0; - m_fY = 0; -} -void Vector2::unit() -{ - float fLen = length(); - - m_fX /= fLen; - m_fY /= fLen; -} - -float Vector2::angle() const -{ - //TODO - DASSERT(false); - //return atan2A(m_fY,m_fX); - return 0; -} -float Vector2::length() const -{ - return sqrt(sqrLength()); -} -float Vector2::sqrLength() const -{ - return this->dot(*this); -} - -float Vector2::dot(const Vector2& vec) const -{ - return m_fX * vec.m_fX + m_fY * vec.m_fY; -} - - -string Vector2::toString() const -{ - // long just to be safe - char rgchars[100]; - - sprintf(rgchars, "Vector2 X: %f, Y: %f", m_fX, m_fY); - - return rgchars; -} -void Vector2::print() const -{ - printf("%s\n", toString().c_str()); -} - - -Vector2 Vector2::add(const Vector2& vec) const -{ - return Vector2(m_fX + vec.m_fX, m_fY + vec.m_fY); -} -Vector2 Vector2::subtract(const Vector2& vec) const -{ - return Vector2(m_fX - vec.m_fX, m_fY - vec.m_fY); -} -Vector2 Vector2::multiply(float f) const -{ - return Vector2(m_fX * f, m_fY * f); -} -Vector2 Vector2::divide(float f) const -{ - return Vector2(m_fX / f, m_fY / f); -} - -/// ***** Public Methods ***** - -Vector2 operator+(const Vector2& vec1, const Vector2& vec2) -{ - return vec1.add(vec2); -} -Vector2 operator-(const Vector2& vec1, const Vector2& vec2) -{ - return vec1.subtract(vec2); -} -Vector2 operator*(float f, const Vector2& vec) -{ - return vec.multiply(f); -} -Vector2 operator*(const Vector2& vec, float f) -{ - return vec.multiply(f); -} -Vector2 operator/(const Vector2& vec, float f) -{ - return vec.divide(f); -} - - -void operator+=(Vector2& vec1, const Vector2& vec2) -{ - vec1.m_fX += vec2.m_fX; - vec1.m_fY += vec2.m_fY; -} -void operator-=(Vector2& vec1, const Vector2& vec2) -{ - vec1.m_fX -= vec2.m_fX; - vec1.m_fY -= vec2.m_fY; -} -void operator*=(Vector2& vec, float f) -{ - vec.m_fX *= f; - vec.m_fY *= f; -} -void operator/=(Vector2& vec, float f) -{ - vec.m_fX /= f; - vec.m_fY /= f; -} diff --git a/src/Vector2.h b/src/Vector2.h deleted file mode 100644 index 57a5541..0000000 --- a/src/Vector2.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef VECTOR2_H -#define VECTOR2_H - -#include - -using std::string; - -/// ***** Header Class ***** -class Vector2 -{ - public: - float m_fX; - float m_fY; - - Vector2(); - Vector2(float, float); - - void zero(); - void unit(); - - float angle() const; - float length() const; - float sqrLength() const; - - float dot(const Vector2&) const; - - Vector2 add(const Vector2&) const; - Vector2 subtract(const Vector2&) const; - Vector2 divide(float) const; - Vector2 multiply(float) const; - - string toString() const; - void print() const; -}; - -/// ***** Header Methods ***** - -// definitions of the operators are external because (float, Vector2) would -// fail inside the class - -Vector2 operator+(const Vector2&, const Vector2&); -Vector2 operator-(const Vector2&, const Vector2&); -Vector2 operator*(float, const Vector2&); -Vector2 operator*(const Vector2&, float); -Vector2 operator/(const Vector2&, float); - -void operator+=(Vector2&, const Vector2&); -void operator-=(Vector2&, const Vector2&); -void operator*=(Vector2&, float); -void operator/=(Vector2&, float); - -#endif // VECTOR2_H diff --git a/src/collisionManager.cpp b/src/collisionManager.cpp index dc5a785..1076ccc 100644 --- a/src/collisionManager.cpp +++ b/src/collisionManager.cpp @@ -16,9 +16,10 @@ */ #include "collisionManager.h" -#include "debug.h" -#include "Vector2.h" +#include +#include +#include #include "Entities/Ball.h" #include "Entities/Polygon.h" @@ -26,8 +27,6 @@ #include "CollisionInfo.h" -#include "mathw.h" - /// ***** Private Method Headers ***** static void clearEntities(); diff --git a/src/config/config.cpp b/src/config/config.cpp index 709c5ff..88768f3 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -16,7 +16,8 @@ */ #include "config.h" -#include "debug.h" + +#include #include #include "keys.h" diff --git a/src/config/keys.cpp b/src/config/keys.cpp index 8832be5..b2e9917 100644 --- a/src/config/keys.cpp +++ b/src/config/keys.cpp @@ -16,7 +16,8 @@ */ #include "keys.h" -#include "debug.h" + +#include #include diff --git a/src/config/keys.h b/src/config/keys.h index 285ecb6..6a0d0db 100644 --- a/src/config/keys.h +++ b/src/config/keys.h @@ -19,13 +19,13 @@ #ifndef KEYS_H #define KEYS_H +#include + #include #include #include -#include "debug.h" - /// ***** Header Methods ***** namespace key { diff --git a/src/config/reader.cpp b/src/config/reader.cpp index 716ec36..3f370e3 100644 --- a/src/config/reader.cpp +++ b/src/config/reader.cpp @@ -16,7 +16,8 @@ */ #include "reader.h" -#include "debug.h" + +#include #include using std::cerr; diff --git a/src/debug.cpp b/src/debug.cpp deleted file mode 100644 index 4e659d2..0000000 --- a/src/debug.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "debug.h" - -#include -using std::cerr; -using std::cout; -using std::endl; - -#include - -#include "locks/Mutex.h" -#include "locks/Autolock.h" - -/// ***** Public Methods ***** - -Mutex muDPF; - -void DPF(int level, const char* pstr) -{ - Autolock lock(muDPF); - - cout << pstr << endl; -} - -void debug::init() -{ - muDPF.init(); -} - -void debug::clean() -{ - muDPF.clean(); -} - -void DASSERT(bool fBreak) -{ - assert(fBreak); -} - -/// ***** Private Methods ***** diff --git a/src/debug.h b/src/debug.h deleted file mode 100644 index 6085003..0000000 --- a/src/debug.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef DEBUG_H -#define DEBUG_H - -#include -using std::cout; -using std::cerr; -using std::endl; - -void DPF(int level, const char* pstr); - -namespace debug -{ - void init(); - void clean(); -} - -void DASSERT(bool fBreak); - -// comment out when not debugging -#define DEBUGGING - - -#endif // DEBUG_H diff --git a/src/dir.mk b/src/dir.mk index 303c805..4c30aa9 100644 --- a/src/dir.mk +++ b/src/dir.mk @@ -2,9 +2,7 @@ NEWSRCS := # insure blank NEWSRCS += game.cpp NEWSRCS += main.cpp -NEWSRCS += mathw.cpp NEWSRCS += ticks.cpp -NEWSRCS += Vector2.cpp NEWSRCS += handleSignal.cpp NEWSRCS += entityCreator.cpp @@ -13,8 +11,6 @@ NEWSRCS += effectManager.cpp NEWSRCS += collisionManager.cpp NEWSRCS += CollisionInfo.cpp -NEWSRCS += debug.cpp - NEWDIRS := # insure blank @@ -24,7 +20,6 @@ NEWDIRS += Effects/ NEWDIRS += config/ NEWDIRS += input/ NEWDIRS += graphics/ -NEWDIRS += locks/ # Post dir setup diff --git a/src/effectManager.cpp b/src/effectManager.cpp index c11ffc3..bcd597e 100644 --- a/src/effectManager.cpp +++ b/src/effectManager.cpp @@ -17,6 +17,8 @@ #include "effectManager.h" +#include + #include #include "Effects/Effect.h" @@ -24,7 +26,6 @@ #include "Effects/GravityWell.h" #include "Effects/Screen.h" -#include "Vector2.h" #include "input/inputManager.h" #include "config/config.h" diff --git a/src/effectManager.h b/src/effectManager.h index f77e191..b649239 100644 --- a/src/effectManager.h +++ b/src/effectManager.h @@ -18,7 +18,8 @@ #ifndef EFFECTMANAGER_H #define EFFECTMANAGER_H -#include "Vector2.h" +#include + #include "Entities/PhysicsEntity.h" /// ***** Header Methods ***** diff --git a/src/entityCreator.h b/src/entityCreator.h index 4c1b4c1..b0b0974 100644 --- a/src/entityCreator.h +++ b/src/entityCreator.h @@ -18,7 +18,7 @@ #ifndef ENTITYCREATOR_H #define ENTITYCREATOR_H -#include "Vector2.h" +#include /// ***** Header Methods ***** namespace creator diff --git a/src/entityManager.cpp b/src/entityManager.cpp index 64d7480..62bcb2e 100644 --- a/src/entityManager.cpp +++ b/src/entityManager.cpp @@ -16,14 +16,14 @@ */ #include "entityManager.h" -#include "debug.h" + +#include +#include +#include #include #include -#include "locks/Mutex.h" -#include "locks/Autolock.h" - #include "Entities/Entity.h" #include "Entities/Particle.h" #include "Entities/PhysicsEntity.h" diff --git a/src/game.cpp b/src/game.cpp index e8c37a2..3cab823 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -16,7 +16,8 @@ */ #include "game.h" -#include "debug.h" + +#include #include using std::vector; diff --git a/src/graphics/graphics.cpp b/src/graphics/graphics.cpp index 6939824..55e2337 100644 --- a/src/graphics/graphics.cpp +++ b/src/graphics/graphics.cpp @@ -16,15 +16,15 @@ */ #include "graphics.h" -#include "debug.h" + +#include +#include #include #include #include #include -#include "mathw.h" - #include using std::cerr; using std::cout; diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index aa87e1b..94a2d5c 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -18,7 +18,8 @@ #ifndef GRAPHICS_H #define GRAPHICS_H -#include "Vector2.h" +#include + #include diff --git a/src/input/inputManager.cpp b/src/input/inputManager.cpp index 5a42b2c..3d94d30 100644 --- a/src/input/inputManager.cpp +++ b/src/input/inputManager.cpp @@ -16,7 +16,8 @@ */ #include "inputManager.h" -#include "debug.h" + +#include #include diff --git a/src/input/inputManager.h b/src/input/inputManager.h index 7d156c4..6abc39f 100644 --- a/src/input/inputManager.h +++ b/src/input/inputManager.h @@ -18,8 +18,9 @@ #ifndef INPUT_H #define INPUT_H +#include + #include -#include "Vector2.h" /// ***** Header Methods ***** diff --git a/src/locks/Autolock.cpp b/src/locks/Autolock.cpp deleted file mode 100644 index 3601bdf..0000000 --- a/src/locks/Autolock.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "Autolock.h" - -#include "Mutex.h" - -/// ***** Constructors/Destructors ***** -Autolock::Autolock(Mutex& mu) - : m_mu(mu) -{ - Lock(); -} - -Autolock::~Autolock() -{ - Unlock(); -} - -void Autolock::Lock() -{ - m_mu.Lock(); -} - -void Autolock::Unlock() -{ - m_mu.Unlock(); -} diff --git a/src/locks/Autolock.h b/src/locks/Autolock.h deleted file mode 100644 index de0107c..0000000 --- a/src/locks/Autolock.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#ifndef AUTOLOCK_H -#define AUTOLOCK_H - -class Mutex; - -/// ***** Header Class ***** -class Autolock -{ -public: - Autolock(Mutex& mu); - ~Autolock(); - - void Lock(); - void Unlock(); - -// hide copying methods! -private: - Autolock(const Autolock&); - const Autolock& operator ==(const Autolock&); - -private: - Mutex& m_mu; -}; - -/// ***** Header Methods ***** - -#endif // AUTOLOCK_H diff --git a/src/locks/Mutex.cpp b/src/locks/Mutex.cpp deleted file mode 100644 index e4004c6..0000000 --- a/src/locks/Mutex.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "Mutex.h" -#include "debug.h" - -#include - -Mutex::Mutex() - : m_pSDL_mutex(NULL) -{ - -} -Mutex::~Mutex() -{ - -} - -void Mutex::init() -{ - m_pSDL_mutex = SDL_CreateMutex(); -} -void Mutex::clean() -{ - SDL_DestroyMutex(m_pSDL_mutex); - m_pSDL_mutex = NULL; -} - -bool Mutex::IsValid() -{ - return NULL != m_pSDL_mutex; -} - -void Mutex::Lock() -{ - DASSERT(IsValid()); - - SDL_mutexP(m_pSDL_mutex); - m_uiThreadID = SDL_ThreadID(); -} -void Mutex::Unlock() -{ - DASSERT(IsValid()); - - DASSERT(m_uiThreadID == SDL_ThreadID()); - SDL_mutexV(m_pSDL_mutex); -} diff --git a/src/locks/Mutex.h b/src/locks/Mutex.h deleted file mode 100644 index cac4d94..0000000 --- a/src/locks/Mutex.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#ifndef MUTEX_H -#define MUTEX_H - -/// ***** Header Class ***** - -class SDL_mutex; - -class Mutex -{ -public: - Mutex(); - ~Mutex(); - - void init(); - void clean(); - - bool IsValid(); - - void Lock(); - void Unlock(); - -// hide copying methods! -private: - Mutex(const Mutex&); - const Mutex& operator ==(const Mutex&); - -private: - SDL_mutex* m_pSDL_mutex; - unsigned int m_uiThreadID; -}; - -#endif // MUTEX_H diff --git a/src/locks/dir.mk b/src/locks/dir.mk deleted file mode 100644 index f7e8b9e..0000000 --- a/src/locks/dir.mk +++ /dev/null @@ -1,19 +0,0 @@ -NEWSRCS := # insure blank - -NEWSRCS += Autolock.cpp -NEWSRCS += Mutex.cpp - - -# Post dir setup - -CURDIR := locks/ - -NEWSRCS := $(addprefix ${CURDIR},${NEWSRCS}) -NEWOBJS := ${NEWSRCS:.cpp=.o} -NEWDEPS := ${NEWSRCS:.cpp=.d} - -# Append to lists - -SRCS += ${NEWSRCS} -OBJS += $(addprefix ${OBJSDIR},${NEWOBJS}) -DEPS += $(addprefix ${DEPSDIR},${NEWDEPS}) diff --git a/src/main.cpp b/src/main.cpp index c9e8808..34aa2ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,11 +15,12 @@ * along with this program. If not, see . */ +#include + #include #include #include -#include "debug.h" #include "handleSignal.h" #include "game.h" diff --git a/src/mathw.cpp b/src/mathw.cpp deleted file mode 100644 index 2b71dec..0000000 --- a/src/mathw.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "mathw.h" - - -/// ***** Public Methods ***** - -int mod(int x, int y) -{ - return x % y + (x < 0 ? y : 0); -} - -// Vector2 Math - -Vector2 vectorToLine -( - const Vector2& vec, - float x1, - float y1, - float x2, - float y2 -) -{ - float lineSize = (float) sqrt((x1 - x2) * (x1 - x2) - + (y1 - y2) * (y1 - y2)); - if (lineSize == 0) - return Vector2(x1 - vec.m_fX, y1 - vec.m_fY); - - float u = ((vec.m_fX - x1) * (x2 - x1) - + (vec.m_fY - y1) * (y2 - y1)) / (lineSize * lineSize); - - if (u < 0) - return Vector2(x1 - vec.m_fX, y1 - vec.m_fY); - else if (u > 1) - return Vector2(x2 - vec.m_fX, y2 - vec.m_fY); - else - { - float ix = x1 + u * (x2 - x1); - float iy = y1 + u * (y2 - y1); - return Vector2(ix - vec.m_fX, iy - vec.m_fY); - } -} - -Vector2 perp(const Vector2& vec) -{ - return Vector2(-vec.m_fY, vec.m_fX); -} - -float dot(const Vector2& vec1, const Vector2& vec2) -{ - return vec1.m_fX * vec2.m_fX + vec1.m_fY * vec2.m_fY; -} - -//TODO float Vector2::projectionCoeff(const Vector2* vec) const; -//TODO Vector2* Vector2::projection(const Vector2* vec) const; - diff --git a/src/mathw.h b/src/mathw.h deleted file mode 100644 index 26a92d8..0000000 --- a/src/mathw.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MATHW_H -#define MATHW_H - -#include -#include "Vector2.h" - - -/// ***** Public Variables ***** - -static const float PI = 3.1415926535897; - -/// ***** Header Methods ***** - -int mod(int, int); - -/// Vector2 Math - -Vector2 vectorToLine -( - const Vector2& vec, - float x1, - float y1, - float x2, - float y2 -); - -//Vector2 lineIntersection(Vector2&, Vector2&, Vector2&, Vector2&) const; - -//void Rotate(float rads); - -float dot(const Vector2&, const Vector2&); -Vector2 perp(const Vector2&); - -//TODO float projectionCoeff(const Vector2&, const Vector2&) const; -//TODO void projection(const Vector2&, const Vector2&); - -#endif // MATHW_H