Hang on to your entities.

Every visible element will be classed as an entity and it is a subclass of an Entity
parent class. I am not quite finished with this, the game entities will all be stored
in a list and the gameworld class will be assigned to manage the list.

Also, I'll be adding to the way the game and window communicate with each other.
this should solve some problems I had with my 'Quick input handling hack'

-- Add : Entity types.
-- Add : UnukWindow
-- Add : Geometry - I have placed some vector stuff in here, to replace Vec2.*
This commit is contained in:
Rtch90 2011-10-14 17:07:02 +01:00
parent d6d139d7c4
commit 7bc05f1707
9 changed files with 225 additions and 25 deletions

View File

@ -1,4 +1,4 @@
Log Started: Fri Oct 14 14:32:48 2011 Log Started: Fri Oct 14 17:05:07 2011
-----Debug Initialized----- -----Debug Initialized-----
@ -10,25 +10,11 @@ OpenGL 3.0 is not supported, falling back to 2.1.
-----Logic----- -----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
Warning: Can not translate this key
-----Cleaning Up----- -----Cleaning Up-----
Player Deleted. Player Deleted.
Log Closed: Fri Oct 14 14:32:53 2011 Log Closed: Fri Oct 14 17:05:09 2011

View File

@ -1,6 +1,6 @@
############################################################################# #############################################################################
# Makefile for building: Unuk-QT # 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 # Project: Unuk-QT.pro
# Template: app # Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro # 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. 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++ LINK = g++
LFLAGS = LFLAGS =
LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread -lSDL -lGL
AR = ar cqs AR = ar cqs
RANLIB = RANLIB =
QMAKE = /usr/bin/qmake-qt4 QMAKE = /usr/bin/qmake-qt4
@ -50,7 +50,8 @@ SOURCES = ../src/libUnuk/Vec2.cpp \
../src/libUnuk/Debug.cpp \ ../src/libUnuk/Debug.cpp \
../src/Unuk/Player.cpp \ ../src/Unuk/Player.cpp \
../src/Unuk/main.cpp \ ../src/Unuk/main.cpp \
../src/Unuk/Game.cpp ../src/Unuk/Game.cpp \
../src/libUnuk/Entity.cpp
OBJECTS = Vec2.o \ OBJECTS = Vec2.o \
Sprite.o \ Sprite.o \
ImageLoader.o \ ImageLoader.o \
@ -58,7 +59,8 @@ OBJECTS = Vec2.o \
Debug.o \ Debug.o \
Player.o \ Player.o \
main.o \ main.o \
Game.o Game.o \
Entity.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \ DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \ /usr/share/qt4/mkspecs/common/linux.conf \
@ -158,7 +160,7 @@ qmake: FORCE
dist: dist:
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0 @$(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 clean:compiler_clean
@ -249,6 +251,12 @@ Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \
../src/libUnuk/Debug.h ../src/libUnuk/Debug.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Game.o ../src/Unuk/Game.cpp $(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
install: FORCE install: FORCE

View File

@ -15,7 +15,11 @@ HEADERS += ../src/libUnuk/Vec2.h \
../src/Unuk/Player.h \ ../src/Unuk/Player.h \
../src/libUnuk/KeyboardInterface.h \ ../src/libUnuk/KeyboardInterface.h \
../src/libUnuk/XKeyboardInterface.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 \ SOURCES += ../src/libUnuk/Vec2.cpp \
../src/libUnuk/Sprite.cpp \ ../src/libUnuk/Sprite.cpp \
../src/libUnuk/ImageLoader.cpp \ ../src/libUnuk/ImageLoader.cpp \
@ -23,4 +27,5 @@ SOURCES += ../src/libUnuk/Vec2.cpp \
../src/libUnuk/Debug.cpp \ ../src/libUnuk/Debug.cpp \
../src/Unuk/Player.cpp \ ../src/Unuk/Player.cpp \
../src/Unuk/main.cpp \ ../src/Unuk/main.cpp \
../src/Unuk/Game.cpp ../src/Unuk/Game.cpp \
../src/libUnuk/Entity.cpp

View File

@ -80,7 +80,6 @@
<value type="QString">DISPLAY=:0</value> <value type="QString">DISPLAY=:0</value>
<value type="QString">HOME=/home/allanis</value> <value type="QString">HOME=/home/allanis</value>
<value type="QString">HUSHLOGIN=FALSE</value> <value type="QString">HUSHLOGIN=FALSE</value>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=allanis</value> <value type="QString">LOGNAME=allanis</value>
<value type="QString">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:</value> <value type="QString">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:</value>
@ -120,7 +119,6 @@
<value type="QString">DISPLAY=:0</value> <value type="QString">DISPLAY=:0</value>
<value type="QString">HOME=/home/allanis</value> <value type="QString">HOME=/home/allanis</value>
<value type="QString">HUSHLOGIN=FALSE</value> <value type="QString">HUSHLOGIN=FALSE</value>
<value type="QString">LANGUAGE=</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=allanis</value> <value type="QString">LOGNAME=allanis</value>
<value type="QString">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:</value> <value type="QString">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:</value>

View File

@ -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();
}

View File

@ -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

View File

@ -0,0 +1,8 @@
#ifndef _ENTITYTYPES_H_
#define _ENTITYTYPES_H_
enum EntityType {
PLAYER
};
#endif

View File

@ -0,0 +1,92 @@
#ifndef _GEOMETRY_H_
#define _GEOMETRY_H_
#include <cmath>
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

View File

@ -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