[Clean] Cleaning up LibD to resurect the project.

This commit is contained in:
Rtch90 2012-09-02 04:52:53 +01:00
parent 4ba792cc18
commit f84f9c2982
27 changed files with 162 additions and 234 deletions

3
.gitignore vendored
View File

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

View File

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

View File

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

BIN
Data/Img/HUD/SpellHud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -70,5 +70,10 @@
<property name="y" value="13"/>
</properties>
</object>
<object name="NPC!!!" type="NPC" x="644" y="319" width="32" height="32">
<properties>
<property name="image" value="Player"/>
</properties>
</object>
</objectgroup>
</map>

View File

@ -58,7 +58,7 @@ void Actor::Update(float dt) {
float oldX = x;
float oldY = y;
Move(dt);
ProcessEvents(dt);
float collisionYOffset = GetMaxHeight() / 2.0f;

View File

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

View File

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

View File

@ -14,5 +14,5 @@ void NPC::Render(void) {
Actor::Render();
}
void NPC::Move(float dt) {
void NPC::ProcessEvents(float dt) {
}

View File

@ -11,5 +11,5 @@ public:
void Render(void);
private:
void Move(float dt);
void ProcessEvents(float dt);
};

View File

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

View File

@ -16,5 +16,5 @@ public:
void Render(void);
private:
void Move(float dt);
void ProcessEvents(float dt);
};

53
src/BattleSys/Slot.cpp Normal file
View File

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

43
src/BattleSys/Slot.h Normal file
View File

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

View File

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

View File

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

View File

@ -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,
"<Misteress of Magic>");
glLoadIdentity();
@ -232,6 +239,7 @@ void Game::RenderHUD(void) {
if(_inGameMenuShown) {
_inGameMenu->Render();
}
_slot->Render(windowWidth/600, windowHeight/1.10f);
}
void Game::NewGame(void) {

View File

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

View File

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

View File

@ -114,6 +114,7 @@ int main(int argc, char** argv) {
}
UpdateInput();
game.Prepare(dt);
game.ProcessEvents(dt);
game.Render();
SDL_GL_SwapBuffers();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ void Menu::AddButton(Button* button) {
void Menu::AlignButtons(int how) {
int x = 0;
int y = 0;
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
Button* button = (*i);
button->SetXY(x, y);
@ -42,7 +42,7 @@ void Menu::AlignButtons(int how) {
void Menu::SelectButton(int index) {
int buttonsIndex = 0;
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
(*i)->SetSelected(buttonsIndex == index);
buttonsIndex++;
}
@ -55,7 +55,7 @@ void Menu::Update(void) {
int index = 0;
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
Button* button = (*i);
int oldX = button->GetX();
int oldY = button->GetY();
button->SetXY(oldX + x, oldY + y);
@ -92,11 +92,10 @@ void Menu::Update(void) {
void Menu::Render(void) {
for(std::list<Button*>::iterator i = _buttons.begin(); i != _buttons.end(); ++i) {
Button* button = (*i);
int oldX = button->GetX();
int oldY = button->GetY();
button->SetXY(oldX + x, oldY + y);
button->Render();
button->Render(oldX + x, oldY + y);
button->SetXY(oldX, oldY);
}
}