diff --git a/.gitignore b/.gitignore
index 966e7b3..5cdca01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
-LibDQt/LibDQt
-LibDQt/Makefile
LibD
*.pro.user
moc_*
@@ -12,6 +10,7 @@ moc_*
*.sdf
*.opensdf
*.user
+Bin/Makefile
Bin/VC10/Debug
Bin/VC10/Release
Bin/VC10/ipch
diff --git a/LibDQt/LibDQt.pro b/Bin/LibD.pro
similarity index 95%
rename from LibDQt/LibDQt.pro
rename to Bin/LibD.pro
index e5329ff..1343b4e 100644
--- a/LibDQt/LibDQt.pro
+++ b/Bin/LibD.pro
@@ -8,7 +8,7 @@ LIBS += -lGL \
-ltinyxml \
-lSDL_mixer \
-lSDL_ttf
-win32: {
+win32: {
LIBS -= -lGL \
-lGLU
LIBS += -lkernel32 \
@@ -67,7 +67,9 @@ HEADERS += ../src/Actor/Player.h \
../src/UI/Button.h \
../src/Main/TitleScreen.h \
../src/Level/Warp.h \
- ../src/Math/Rect.h
+ ../src/Math/Rect.h \
+ ../src/BattleSys/Slot.h
+
SOURCES += ../src/Actor/Player.cpp \
../src/Collision/AABB.cpp \
../src/Global/Globals.cpp \
@@ -108,4 +110,7 @@ SOURCES += ../src/Actor/Player.cpp \
../src/UI/Menu.cpp \
../src/UI/Button.cpp \
../src/Main/TitleScreen.cpp \
- ../src/Level/Warp.cpp
+ ../src/Level/Warp.cpp \
+ ../src/BattleSys/Slot.cpp
+
+QMAKE_CLEAN += LibD Debug.log
diff --git a/Bin/Makefile b/Bin/Makefile
deleted file mode 100644
index 1236a2d..0000000
--- a/Bin/Makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lglut -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -ltinyxml
-LDADDSTATIC = -Wl,-Bstatic -lSDL -lSDL_image -lopenal -lalut -L/usr/X11 -Wl,-Bdynamic -lasound -lartsc -lesd -lpulse -lpulse-simple -ldirectfb -lvga -laa -lcaca -ljpeg -ltiff -
-
-.PHONY: default static all clean
-
-default: all
-
-all:
- $(MAKE) -C ../src/Main
- $(MAKE) -C ../src/Texture
- $(MAKE) -C ../src/Actor
- $(MAKE) -C ../src/Math
- $(MAKE) -C ../src/System
- $(MAKE) -C ../src/Sprite
- $(MAKE) -C ../src/IO
- $(MAKE) -C ../src/Global
-
- $(CC) $(CFLAGS) -o LibD ../src/Main/main.cpp ../src/Main/*.o ../src/Texture/*.o \
- ../src/Actor/*.o ../src/Math/*.o ../src/System/*.o ../src/Sprite/*.o \
- ../src/IO/*.o ../src/Global/*.o $(LDADD)
-
-static:
- @echo -e "\033[1;31mThis is an experimental build, if it does not work, don't complain...\033[0m"
- @sleep 1
- $(MAKE) -C ../src/Main/ ../src/Main/*.o ../src/Texture/*.o \
- ../src/Actor/*.o ../src/Math/*.o ../src/System/*.o ../src/Sprite/*.o \
- ../src/IO/*.o ../src/Global/*.o
-
- $(CC) $(CFLAGS) -o build/LibD-static ../src/Main/main.cpp ../src/Main/*.o \
- ../src/Texture/*.o ../src/Actor/*.o ../src/Math/*.o \
- ../src/System/*.o ../src/Sprite/*.o ../src/IO/*.o
- ../src/Global/*.o \
- $(LDADDSTATIC)
-
-clean:
- $(MAKE) -C ../src/Main/ clean
- $(MAKE) -C ../src/Texture/ clean
- $(MAKE) -C ../src/Actor/ clean
- $(MAKE) -C ../src/Math/ clean
- $(MAKE) -C ../src/System/ clean
- $(MAKE) -C ../src/Sprite/ clean
- $(MAKE) -C ../src/IO/ clean
- $(MAKE) -C ../src/Global/ clean
- rm -f *.log
- rm -f LibD
diff --git a/Data/Img/HUD/SpellHud.png b/Data/Img/HUD/SpellHud.png
new file mode 100644
index 0000000..4df9dc4
Binary files /dev/null and b/Data/Img/HUD/SpellHud.png differ
diff --git a/Data/Map/Ugly.tmx b/Data/Map/Ugly.tmx
index c7240e3..8ff7e84 100644
--- a/Data/Map/Ugly.tmx
+++ b/Data/Map/Ugly.tmx
@@ -70,5 +70,10 @@
+
diff --git a/src/Actor/Actor.cpp b/src/Actor/Actor.cpp
index ea1bd76..ef01eeb 100644
--- a/src/Actor/Actor.cpp
+++ b/src/Actor/Actor.cpp
@@ -58,7 +58,7 @@ void Actor::Update(float dt) {
float oldX = x;
float oldY = y;
- Move(dt);
+ ProcessEvents(dt);
float collisionYOffset = GetMaxHeight() / 2.0f;
diff --git a/src/Actor/Actor.h b/src/Actor/Actor.h
index 831caf4..0c3cd2f 100644
--- a/src/Actor/Actor.h
+++ b/src/Actor/Actor.h
@@ -25,7 +25,7 @@ public:
};
Actor(Level* level);
- ~Actor(void);
+ virtual ~Actor(void);
void SetLevel(Level* level) { _level = level; }
@@ -48,7 +48,7 @@ public:
void SetDirection(Facing direction) { _direction = direction; }
protected:
- virtual void Move(float dt) = 0;
+ virtual void ProcessEvents(float dt) = 0;
AnimatingSprite* GetAnimation(void);
diff --git a/src/Actor/Makefile b/src/Actor/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/Actor/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/Actor/NPC.cpp b/src/Actor/NPC.cpp
index cc76dac..c6c38a9 100644
--- a/src/Actor/NPC.cpp
+++ b/src/Actor/NPC.cpp
@@ -14,5 +14,5 @@ void NPC::Render(void) {
Actor::Render();
}
-void NPC::Move(float dt) {
+void NPC::ProcessEvents(float dt) {
}
diff --git a/src/Actor/NPC.h b/src/Actor/NPC.h
index 222dc57..a3fd20a 100644
--- a/src/Actor/NPC.h
+++ b/src/Actor/NPC.h
@@ -11,5 +11,5 @@ public:
void Render(void);
private:
- void Move(float dt);
+ void ProcessEvents(float dt);
};
diff --git a/src/Actor/Player.cpp b/src/Actor/Player.cpp
index c420d04..078d8b3 100644
--- a/src/Actor/Player.cpp
+++ b/src/Actor/Player.cpp
@@ -27,7 +27,7 @@ void Player::Render(void) {
Actor::Render();
}
-void Player::Move(float dt) {
+void Player::ProcessEvents(float dt) {
if(KeyStillDown(SDLK_a) || KeyStillDown(SDLK_LEFT)) {
x -= _velocity * 60 * dt;
_direction = Actor::LEFT;
diff --git a/src/Actor/Player.h b/src/Actor/Player.h
index 0f4c599..39af2ba 100644
--- a/src/Actor/Player.h
+++ b/src/Actor/Player.h
@@ -16,5 +16,5 @@ public:
void Render(void);
private:
- void Move(float dt);
+ void ProcessEvents(float dt);
};
diff --git a/src/BattleSys/Slot.cpp b/src/BattleSys/Slot.cpp
new file mode 100644
index 0000000..da56a44
--- /dev/null
+++ b/src/BattleSys/Slot.cpp
@@ -0,0 +1,53 @@
+#include "Slot.h"
+
+Slot::Slot(void) {
+ _triggered = false;
+ _selected = false;
+ x = 0;
+ y = 0;
+ w = 0;
+ h = 0;
+
+ //Sprite* _slot = new Sprite();
+ //_slot->LoadSprite("../Data/Img/HUD/SpellHud.png");
+}
+
+Slot::~Slot(void) {
+ //delete _slot;
+ delete _slotArray[_index];
+}
+
+void Slot::PrepareSlot(void) {
+ for(int i = 0; i < MAX_SLOTS; i++) {
+ _slotArray[i] = new Button();
+ _slotArray[i]->LoadSprite("../Data/Img/HUD/SpellHud.png");
+ _index = i;
+ }
+}
+
+void Slot::Render(void) {
+ //_slot->Draw();
+}
+
+void Slot::Render(float x, float y) {
+ for(int i = 0; i < _index; i++) {
+ int offset = 52;
+
+ if(i != _index) {
+ x += offset;
+ _slotArray[_index]->Render(x, y);
+ }
+ }
+}
+
+void Slot::ProcessEvents(void) {
+ _slotArray[0]->Update();
+ if(_slotArray[0]->IsSelected()) {
+ if(MouseUp(SDL_BUTTON(1))) {
+ _slotArray[0]->SetSelected(true);
+ Debug::logger->message("Slot has been triggered.");
+ }
+ } else {
+ //Debug::logger->message("Not triggered");
+ }
+}
diff --git a/src/BattleSys/Slot.h b/src/BattleSys/Slot.h
new file mode 100644
index 0000000..198af8d
--- /dev/null
+++ b/src/BattleSys/Slot.h
@@ -0,0 +1,43 @@
+#pragma once
+#include "../Math/Vec2.h"
+#include "../System/Debug.h"
+#include "../Global/Globals.h"
+#include "../UI/Button.h"
+#include "../IO/Input.h"
+#define MAX_SLOTS 15
+
+class Slot {
+public:
+ Slot(void);
+ ~Slot(void);
+
+ void PrepareSlot(void);
+ void Render(void);
+ void Render(float x, float y);
+
+ void ProcessEvents(void);
+
+ bool IsSelected(void) const { return _selected; }
+ void SetSelected(bool selected) { _selected = selected; }
+ bool Triggered(void) const { return _triggered; }
+
+ int GetX(void) { return x; }
+ int GetY(void) { return y; }
+ void SetX(int x) { this->x = x; }
+ void SetY(int y) { this->y = y; }
+ void SetXY(int x, int y) { SetX(x); SetY(y); }
+
+ int GetWidth(void) { return w; }
+ int GetHeight(void) { return h; }
+
+
+private:
+ //Button* _slot;
+ Button* _slotArray[MAX_SLOTS];
+ int _index;
+
+ bool _selected;
+ bool _triggered;
+
+ int x,y,w,h;
+};
diff --git a/src/Global/Makefile b/src/Global/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/Global/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/IO/Makefile b/src/IO/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/IO/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/Main/Game.cpp b/src/Main/Game.cpp
index 06c92fc..53ed449 100644
--- a/src/Main/Game.cpp
+++ b/src/Main/Game.cpp
@@ -25,6 +25,11 @@ Game::Game(void) {
_level = new Level(this);
_player = new Player(_level);
+ //_NPC = new NPC(_level);
+ _slot = new Slot();
+
+ //_NPC->SetXY(30.0f, 30.0f);
+
_testFont = new Font();
_titleScreen = new TitleScreen();
@@ -54,7 +59,7 @@ bool Game::Init(void) {
}
void Game::Prepare(float dt) {
-
+ _slot->PrepareSlot();
}
void Game::Render(void) {
@@ -71,6 +76,7 @@ void Game::Shutdown(void) {
delete _testFont;
delete _player;
delete _level;
+ delete _slot;
if(_inGameMenu) {
delete _inGameMenu;
_inGameMenu = NULL;
@@ -83,6 +89,7 @@ void Game::ProcessEvents(float dt) {
} else {
UpdateGame(dt);
}
+ _slot->ProcessEvents();
}
void Game::OnResize(int width, int height) {
@@ -214,11 +221,11 @@ void Game::RenderGame(void) {
_testFont->SetColor(0.0f, 1.0f, 1.0f, 1.0f);
_testFont->RenderText(
_player->GetX() - 5,
- _player->GetY() - _testFont->GetLineSkip() - 2,
+ _player->GetY() - _testFont->GetLineSkip() - 20,
"Miss D");
_testFont->RenderText(
_player->GetX() - 50,
- _player->GetY() - _testFont->GetLineSkip() - 20,
+ _player->GetY() - _testFont->GetLineSkip() - 2,
"");
glLoadIdentity();
@@ -232,6 +239,7 @@ void Game::RenderHUD(void) {
if(_inGameMenuShown) {
_inGameMenu->Render();
}
+ _slot->Render(windowWidth/600, windowHeight/1.10f);
}
void Game::NewGame(void) {
diff --git a/src/Main/Game.h b/src/Main/Game.h
index 995efc1..6b00d9b 100644
--- a/src/Main/Game.h
+++ b/src/Main/Game.h
@@ -2,6 +2,7 @@
#include "../IO/Input.h"
#include "../Actor/Player.h"
#include "../Font/Font.h"
+#include "../BattleSys/Slot.h"
class Sprite;
class Level;
@@ -29,6 +30,9 @@ public:
void SetRunning(bool running) { _running = running; }
private:
+ // Battle system crap.
+ Slot* _slot;
+
void UpdateTitle(float dt);
void UpdateGame(float dt);
void RenderTitle(void);
diff --git a/src/Main/Makefile b/src/Main/Makefile
deleted file mode 100644
index 0484894..0000000
--- a/src/Main/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = LGLXWindow.o Game.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/Main/main.cpp b/src/Main/main.cpp
index 3a01324..bf58093 100644
--- a/src/Main/main.cpp
+++ b/src/Main/main.cpp
@@ -114,6 +114,7 @@ int main(int argc, char** argv) {
}
UpdateInput();
+ game.Prepare(dt);
game.ProcessEvents(dt);
game.Render();
SDL_GL_SwapBuffers();
diff --git a/src/Math/Makefile b/src/Math/Makefile
deleted file mode 100644
index 1a3c264..0000000
--- a/src/Math/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = FPS.o Timer.o Vec2.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/Sprite/Makefile b/src/Sprite/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/Sprite/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/System/Makefile b/src/System/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/System/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/Texture/Makefile b/src/Texture/Makefile
deleted file mode 100644
index d9f50be..0000000
--- a/src/Texture/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC = g++
-CFLAGS = -ansi -Wall -g
-LDADD = -lGL -lGLU -lSDL -lSDL_image
-
-objects = *.o \
-
-
-.PHONY: default all clean
-
-default: all
-
-%.cpp: %.h
-
-%.o: %.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-all: $(objects)
-
-clean:
- rm -f $(objects)
diff --git a/src/UI/Button.cpp b/src/UI/Button.cpp
index c1aedfa..9330f5d 100644
--- a/src/UI/Button.cpp
+++ b/src/UI/Button.cpp
@@ -8,15 +8,20 @@ Button::Button(void) {
_highlighted = false;
_selected = false;
_triggered = false;
+ _sprite = NULL;
x = 0;
y = 0;
w = 0;
h = 0;
}
+Button::~Button(void) {
+ delete _sprite;
+}
+
void Button::Update(void) {
_triggered = false;
-
+
int mouseX = ::GetX();
int mouseY = ::GetY();
@@ -32,7 +37,7 @@ void Button::Update(void) {
}
}
-void Button::Render(void) {
+void Button::Render(float x, float y) {
if(_font) {
if(_highlighted || _selected) {
_font->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
@@ -42,6 +47,9 @@ void Button::Render(void) {
_font->RenderText(x, y, _text.GetPointer());
_font->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
}
+ if(_sprite != NULL) {
+ _sprite->Draw(x, y);
+ }
}
void Button::SetFont(Font* font) {
@@ -57,3 +65,8 @@ void Button::SetText(const String& text) {
_font->TextSize(text.GetPointer(), w, h);
}
}
+
+void Button::LoadSprite(const char* filename) {
+ _sprite = new Sprite();
+ _sprite->LoadSprite(filename);
+}
diff --git a/src/UI/Button.h b/src/UI/Button.h
index 6400559..fbf3152 100644
--- a/src/UI/Button.h
+++ b/src/UI/Button.h
@@ -1,21 +1,25 @@
#pragma once
+#include "../Sprite/Sprite.h"
#include "../System/String.h"
#include "../Font/Font.h"
class Button {
public:
Button(void);
+ ~Button(void);
void Update(void);
- void Render(void);
+ void Render(float x, float y);
Font* GetFont(void) { return _font; }
void SetFont(Font* font);
-
+ void LoadSprite(const char* filename);
+
+
const String& GetText(void) const { return _text;}
void SetText(const String& text);
-
+
bool IsHighlighted(void) const { return _highlighted; }
void SetHighlighted(bool highlighted) { _highlighted = highlighted; }
@@ -36,7 +40,8 @@ public:
private:
Font* _font;
String _text;
-
+ Sprite* _sprite;
+
bool _highlighted;
bool _selected;
bool _triggered;
diff --git a/src/UI/Menu.cpp b/src/UI/Menu.cpp
index a12a9ae..5ff1780 100644
--- a/src/UI/Menu.cpp
+++ b/src/UI/Menu.cpp
@@ -28,7 +28,7 @@ void Menu::AddButton(Button* button) {
void Menu::AlignButtons(int how) {
int x = 0;
int y = 0;
- for(std::list