diff --git a/trunk/Bin/Debug.log b/trunk/Bin/Debug.log index 5c2b459..a9439e2 100644 --- a/trunk/Bin/Debug.log +++ b/trunk/Bin/Debug.log @@ -1,4 +1,4 @@ -Log Started: Fri Oct 14 14:32:48 2011 +Log Started: Fri Oct 14 17:05:07 2011 -----Debug Initialized----- @@ -10,25 +10,11 @@ OpenGL 3.0 is not supported, falling back to 2.1. -----Logic----- Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -Warning: Can not translate this key -----Cleaning Up----- Player Deleted. -Log Closed: Fri Oct 14 14:32:53 2011 +Log Closed: Fri Oct 14 17:05:09 2011 diff --git a/trunk/Unuk-QT/Makefile b/trunk/Unuk-QT/Makefile index b6f3eed..79d2087 100644 --- a/trunk/Unuk-QT/Makefile +++ b/trunk/Unuk-QT/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: Unuk-QT -# Generated by qmake (2.01a) (Qt 4.7.3) on: Fri Oct 14 14:55:11 2011 +# Generated by qmake (2.01a) (Qt 4.7.3) on: Fri Oct 14 17:01:42 2011 # Project: Unuk-QT.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro @@ -16,7 +16,7 @@ CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. LINK = g++ LFLAGS = -LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread +LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread -lSDL -lGL AR = ar cqs RANLIB = QMAKE = /usr/bin/qmake-qt4 @@ -50,7 +50,8 @@ SOURCES = ../src/libUnuk/Vec2.cpp \ ../src/libUnuk/Debug.cpp \ ../src/Unuk/Player.cpp \ ../src/Unuk/main.cpp \ - ../src/Unuk/Game.cpp + ../src/Unuk/Game.cpp \ + ../src/libUnuk/Entity.cpp OBJECTS = Vec2.o \ Sprite.o \ ImageLoader.o \ @@ -58,7 +59,8 @@ OBJECTS = Vec2.o \ Debug.o \ Player.o \ main.o \ - Game.o + Game.o \ + Entity.o DIST = /usr/share/qt4/mkspecs/common/g++.conf \ /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ @@ -158,7 +160,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Vec2.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/GlxWindow.h ../src/libUnuk/Sprite.h ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/Unuk/Game.h ../src/Unuk/Player.h ../src/libUnuk/KeyboardInterface.h ../src/libUnuk/XKeyboardInterface.h ../src/libUnuk/Static.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Vec2.cpp ../src/libUnuk/Sprite.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/GlxWindow.cpp ../src/libUnuk/Debug.cpp ../src/Unuk/Player.cpp ../src/Unuk/main.cpp ../src/Unuk/Game.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Vec2.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/GlxWindow.h ../src/libUnuk/Sprite.h ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/Unuk/Game.h ../src/Unuk/Player.h ../src/libUnuk/KeyboardInterface.h ../src/libUnuk/XKeyboardInterface.h ../src/libUnuk/Static.h ../src/libUnuk/UnukWindow.h ../src/libUnuk/Geometry.h ../src/libUnuk/Entity.h ../src/libUnuk/EntityType.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Vec2.cpp ../src/libUnuk/Sprite.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/GlxWindow.cpp ../src/libUnuk/Debug.cpp ../src/Unuk/Player.cpp ../src/Unuk/main.cpp ../src/Unuk/Game.cpp ../src/libUnuk/Entity.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0 clean:compiler_clean @@ -249,6 +251,12 @@ Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \ ../src/libUnuk/Debug.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Game.o ../src/Unuk/Game.cpp +Entity.o: ../src/libUnuk/Entity.cpp ../src/libUnuk/Entity.h \ + ../src/libUnuk/Geometry.h \ + ../src/libUnuk/EntityType.h \ + ../src/libUnuk/Static.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Entity.o ../src/libUnuk/Entity.cpp + ####### Install install: FORCE diff --git a/trunk/Unuk-QT/Unuk-QT.pro b/trunk/Unuk-QT/Unuk-QT.pro index 9c4c0b7..25b5f1a 100644 --- a/trunk/Unuk-QT/Unuk-QT.pro +++ b/trunk/Unuk-QT/Unuk-QT.pro @@ -15,7 +15,11 @@ HEADERS += ../src/libUnuk/Vec2.h \ ../src/Unuk/Player.h \ ../src/libUnuk/KeyboardInterface.h \ ../src/libUnuk/XKeyboardInterface.h \ - ../src/libUnuk/Static.h + ../src/libUnuk/Static.h \ + ../src/libUnuk/UnukWindow.h \ + ../src/libUnuk/Geometry.h \ + ../src/libUnuk/Entity.h \ + ../src/libUnuk/EntityType.h SOURCES += ../src/libUnuk/Vec2.cpp \ ../src/libUnuk/Sprite.cpp \ ../src/libUnuk/ImageLoader.cpp \ @@ -23,4 +27,5 @@ SOURCES += ../src/libUnuk/Vec2.cpp \ ../src/libUnuk/Debug.cpp \ ../src/Unuk/Player.cpp \ ../src/Unuk/main.cpp \ - ../src/Unuk/Game.cpp + ../src/Unuk/Game.cpp \ + ../src/libUnuk/Entity.cpp diff --git a/trunk/Unuk-QT/Unuk-QT.pro.user b/trunk/Unuk-QT/Unuk-QT.pro.user index 9cca2a7..5e94399 100644 --- a/trunk/Unuk-QT/Unuk-QT.pro.user +++ b/trunk/Unuk-QT/Unuk-QT.pro.user @@ -80,7 +80,6 @@ DISPLAY=:0 HOME=/home/allanis HUSHLOGIN=FALSE - LANGUAGE= LD_LIBRARY_PATH=/usr/lib/qtcreator LOGNAME=allanis LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: @@ -120,7 +119,6 @@ DISPLAY=:0 HOME=/home/allanis HUSHLOGIN=FALSE - LANGUAGE= LD_LIBRARY_PATH=/usr/lib/qtcreator LOGNAME=allanis LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: diff --git a/trunk/src/libUnuk/Entity.cpp b/trunk/src/libUnuk/Entity.cpp new file mode 100644 index 0000000..e0998d4 --- /dev/null +++ b/trunk/src/libUnuk/Entity.cpp @@ -0,0 +1,35 @@ +#include "Entity.h" + +Entity::Entity(GameWorld* const gameWorld) : + m_canBeRemoved(false), + m_world(gameWorld) {} + +Entity::~Entity(void) {} + +bool Entity::CanBeRemoved(void) const { + return m_canBeRemoved; +} + +void Entity::Destroy(void) { + m_canBeRemoved = true; +} + +void Entity::Prepare(float dt) { + OnPrepare(dt); +} + +void Entity::Render(void) const { + OnRender(); +} + +void Entity::OnPostRender(void) { + OnPostRender(); +} + +bool Entity::Initialize(void) { + return OnInitiaize(); +} + +void Entity::Shutdown(void) { + OnShutdown(); +} diff --git a/trunk/src/libUnuk/Entity.h b/trunk/src/libUnuk/Entity.h new file mode 100644 index 0000000..945221a --- /dev/null +++ b/trunk/src/libUnuk/Entity.h @@ -0,0 +1,46 @@ +#ifndef _ENTITY_H_ +#define _ENTITY_H_ +#include "Geometry.h" +#include "EntityType.h" +#include "Static.h" + +class GameWorld; + +/* + * Entity is static because we will mainly be handling + * pointers (that can be copied around) but we want + * all entities to be initiaized by the gameworld. + */ + +class Entity : private Static { +public: + Entity(GameWorld* const gameWorld); + virtual ~Entity(void); + + void Prepare(float dt); + void Render(void) const; + void PostRender(void); + bool Initialize(void); + void Shutdown(void); + bool CanBeRemoved(void) const; + void Destroy(void); + + virtual Vector2 GetPosition(void) const = 0; + //virtual Vector2 GetVelocity() const = 0; + virtual void SetPosition(const Vector2& position) = 0; + + virtual EntityType GetType(void) const = 0; + +private: + virtual void OnPrepare(float dt) = 0; + virtual void OnRender(void) const = 0; + virtual void OnPostRender(void) = 0; + virtual bool OnInitiaize(void) = 0; + virtual void OnShutdown(void) = 0; + + bool m_canBeRemoved; + + GameWorld* m_world; +}; + +#endif diff --git a/trunk/src/libUnuk/EntityType.h b/trunk/src/libUnuk/EntityType.h new file mode 100644 index 0000000..0b46c76 --- /dev/null +++ b/trunk/src/libUnuk/EntityType.h @@ -0,0 +1,8 @@ +#ifndef _ENTITYTYPES_H_ +#define _ENTITYTYPES_H_ + +enum EntityType { + PLAYER +}; + +#endif diff --git a/trunk/src/libUnuk/Geometry.h b/trunk/src/libUnuk/Geometry.h new file mode 100644 index 0000000..b7cda8f --- /dev/null +++ b/trunk/src/libUnuk/Geometry.h @@ -0,0 +1,92 @@ +#ifndef _GEOMETRY_H_ +#define _GEOMETRY_H_ +#include + +struct TexCoord { + float s, t; + TexCoord(void): + s(0.0f), + t(0.0f) {} + + TexCoord(float s, float t): + s(s), + t(t) {} +}; + +struct Colour { + float r, g, b, a; + Colour(float R, float G, float B, float A): + r(R), + g(G), + b(B), + a(A) {} + + Colour(void): + r(0.0f), + g(0.0f), + b(0.0f), + a(0.0f) {} +}; + +struct Vector2 { + float x, y; + Vector2(float X, float Y): + x(X), + y(y) {} + + Vector2(void): + x(0.0f), + y(0.0f) {} + + Vector2(const Vector2& v): + x(v.x), + y(v.y) {} + + Vector2 operator*(const float s) const { + return Vector2(x*s, y*s); + } + + Vector2& operator=(const Vector2& v) { + if(this == &v) { + return *this; + } + x = v.x; + y = v.y; + + return *this; + } + + Vector2& operator+=(const Vector2& v) { + this->x += v.x; + this->y += v.y; + + return *this; + } + + const Vector2 operator-(const Vector2& v) const { + Vector2 result; + result.x = x - v.x; + result.y = y - v.y; + + return result; + } + + float length(void) const { + return sqrtf(x*x+y*y); + } + + void normalize(void) { + float l = 1.0f / length(); + x *= l; + y *= l; + } +}; + +typedef Vector2 Vertex; + +inline float degreesToRadians(const float degrees) { + const float PIOver180 = 3.14159f / 180.0f; + return degrees * PIOver180; +} + +#endif diff --git a/trunk/src/libUnuk/UnukWindow.h b/trunk/src/libUnuk/UnukWindow.h new file mode 100644 index 0000000..b8c7c70 --- /dev/null +++ b/trunk/src/libUnuk/UnukWindow.h @@ -0,0 +1,22 @@ +#ifndef _UNUKWINDOW_H_ +#define _UNUKWINDOW_H_ +#include "Static.h" + +class KeyboardInterface; +class Game; + +class Static : private Static { +public: + virtual ~UnukWindow(void) {} + + virtual bool Create(int width, int height, int bpp, bool fullscreen) = 0; + virtual void Destroy(void) = 0; + virtual void processEvents(void) = 0; + virtual void AttachGame(Game* game) = 0; + virtual bool IsRunning(void) = 0; + virtual void SwapBuffers(void) = 0; + virtual float GetElapsedSeconds(void) = 0; + virtual KeyboardInterface* GetKeyboard(void) const = 0; +}; + +#endif