Skip to content

Commit 5a8646b

Browse files
Start base
1 parent d31e4d6 commit 5a8646b

File tree

515 files changed

+168270
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

515 files changed

+168270
-0
lines changed

Makefile

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
####### Platform specifics
2+
3+
PLATFORM_OS := $(shell uname)
4+
PLATFORM_ARCH := $(shell getconf LONG_BIT)
5+
6+
####### Compiler, tools and options
7+
8+
DEL_FILE = rm -f
9+
CHKDIR = test -d
10+
MKDIR = mkdir -p
11+
COPY = cp -f
12+
COPY_DIR = cp -f -R
13+
DEL_DIR = rmdir
14+
MOVE = mv -f
15+
STRIP = strip
16+
17+
####### Flags
18+
19+
CC = gcc-4.8
20+
GXX = g++-4.8
21+
CFLAGS = -pipe -Wall -Wextra -pedantic -fmessage-length=0 -std=c99 $(DEFINES) -fstack-protector-all
22+
CXXFLAGS = -pipe -Wall -Wextra -pedantic -fmessage-length=0 -std=c++11 $(DEFINES) -fstack-protector-all
23+
DEFINES = -D_BSD_SOURCE -D_GNU_SOURCE
24+
25+
####### Files, Folders and Paths to app
26+
27+
DIR_OBJ = build
28+
DIR_SRC = src
29+
30+
APP_NAME = Duck Tales
31+
APP_FILE = app
32+
APP_EXEC = ducktales
33+
34+
DIR_APP = src/App
35+
36+
SRC_APP = $(wildcard $(DIR_SRC)/*/*.cpp)
37+
INC_APP = $(wildcard $(DIR_SRC)/*/*.h)
38+
OBJ_APP = $(addsuffix .o, $(basename $(subst $(DIR_APP)/, $(DIR_OBJ)/$(DIR_APP)/, $(SRC_APP))))
39+
40+
####### Files, Folders and Paths to keygen
41+
42+
KGN_NAME = Key Gen
43+
KGN_FILE = keygen
44+
KGN_EXEC = keygen
45+
46+
DIR_KGN = src/Keygen
47+
48+
SRC_KGN = $(wildcard $(DIR_SRC)/*/*.cpp)
49+
INC_KGN = $(wildcard $(DIR_SRC)/*/*.h)
50+
OBJ_KGN = $(addsuffix .o, $(basename $(subst $(DIR_KGN)/, $(DIR_OBJ)/$(DIR_KGN)/, $(SRC_KGN))))
51+
52+
####### Includes and Libraries
53+
54+
ifeq ($(PLATFORM_ARCH), 32)
55+
INCS = -Ilib/TinyEngine/include -Isrc -Isrc/FrameWork -I./src/SceneGame -I/usr/include/freetype2 -I/usr/include/GL -I/usr/include/SDL -fabi-version=2 -fno-omit-frame-pointer -I/usr/include/mysql
56+
LIBS = -L/usr/lib -L/usr/lib/i386-linux-gnu -lcrypto -lssl -lblkid -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_net -lSDL_ttf -lX11 -lXrandr -lmysqlclient -lsqlite3 -lpthread -lz -m32
57+
else ifeq ($(PLATFORM_ARCH), 64)
58+
INCS = -Ilib/TinyEngine/include -Isrc -Isrc/FrameWork -I./src/SceneGame -I/usr/include/freetype2 -I/usr/include/GL -I/usr/include/SDL -fabi-version=2 -fno-omit-frame-pointer -I/usr/include/mysql
59+
LIBS = -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -lcrypto -lssl -lblkid -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_net -lSDL_ttf -lX11 -lXrandr -lmysqlclient -lsqlite3 -lpthread -lz -m64
60+
endif
61+
62+
####### Build rules
63+
64+
.PHONY: all light hard app gdb upload download
65+
.SECONDARY: build-pre build-post build-debug build-app build-game build-key build-keygen all exec-pre exec-post exec-gdb exec-run run gdb git-pre git-post git-upload git-download upload download
66+
67+
####### Compiling all
68+
69+
all: build-debug
70+
light: build-light
71+
hard: build-hard
72+
73+
print:
74+
@echo $(OBJ_APP)
75+
76+
####### Compiling objects
77+
78+
build-game: build-pre $(DIR_OBJ)/$(APP_FILE)
79+
build-keygen: build-pre $(DIR_OBJ)/$(KGN_FILE)
80+
81+
$(DIR_OBJ)/$(APP_FILE): $(OBJ_APP)
82+
@$(GXX) $(CXXFLAGS) $(DIR_APP).cpp -o $(DIR_OBJ)/$(APP_EXEC) $(DEFINES) $(OBJ_APP) $(INCS) $(LIBS)
83+
84+
$(DIR_OBJ)/$(KGN_FILE): $(OBJ_KGN)
85+
@$(GXX) $(CXXFLAGS) $(DIR_KGN).cpp -o $(DIR_OBJ)/$(KGN_EXEC) $(DEFINES) $(OBJ_KGN) $(INCS) $(LIBS)
86+
87+
####### Compiling apps
88+
89+
build-app: build-pre $(OBJ_APP)
90+
build-key: build-pre $(OBJ_KGN)
91+
92+
$(DIR_OBJ)/$(DIR_APP)/%.o: $(DIR_APP)/%.cpp $(DIR_APP)/%.h
93+
@$(CHKDIR) $(DIR_OBJ) | $(MKDIR) $(DIR_OBJ)
94+
@$(CHKDIR) $(dir $@) | $(MKDIR) $(dir $@)
95+
@$(GXX) $(CXXFLAGS) -c $< -o $@ $(DEFINES) $(INCS) $(LIBS)
96+
@echo Done $< in $@
97+
98+
$(DIR_OBJ)/$(DIR_KGN)/%.o: $(DIR_KGN)/%.cpp $(DIR_KGN)/%.h
99+
@$(CHKDIR) $(DIR_OBJ) | $(MKDIR) $(DIR_OBJ)
100+
@$(CHKDIR) $(dir $@) | $(MKDIR) $(dir $@)
101+
@$(GXX) $(CXXFLAGS) -c $< -o $@ $(DEFINES) $(INCS) $(LIBS)
102+
@echo Done $< in $@
103+
104+
####### Build
105+
106+
build-pre:
107+
@echo Building ...
108+
109+
build-post:
110+
@echo Done.
111+
112+
build-light: CFLAGS += -g0
113+
build-light: DEFINES += -DLIGHT
114+
build-light: build-app build-key build-game build-keygen
115+
@$(MAKE) --no-print-directory build-post
116+
117+
build-hard: CFLAGS += -g0
118+
build-hard: DEFINES += -DHARD
119+
build-hard: build-app build-key build-game build-keygen
120+
@$(MAKE) --no-print-directory build-post
121+
122+
build-debug: DEFINES += -DDEBUG -DLIGHT
123+
build-debug: CFLAGS += -O0 -g3 -g -ggdb -O0 -Wall -W
124+
build-debug: CXXFLAGS += -O0 -g3 -g -ggdb -O0 -Wall -W
125+
build-debug: build-app build-key build-game build-keygen
126+
@$(MAKE) --no-print-directory build-post
127+
128+
####### Clearing
129+
130+
clean-pre:
131+
@echo Cleaning ...
132+
133+
clean-post:
134+
@echo Cleaned.
135+
136+
clean-key:
137+
@$(DEL_FILE) $(DIR_OBJ)/$(DIR_KGN)/*/*
138+
139+
clean-app:
140+
@$(DEL_FILE) $(DIR_OBJ)/$(APP_FILE)/*/*
141+
@$(DEL_FILE) $(DIR_OBJ)/$(APP_EXEC)
142+
143+
clean: clean-pre clean-key clean-app clean-post
144+
145+
####### Execute
146+
147+
exec-pre:
148+
@echo Running ...
149+
150+
exec-post:
151+
@echo Done.
152+
153+
exec-dbg:
154+
@gdb ./$(DIR_OBJ)/$(APP_EXEC)
155+
156+
exec-run:
157+
./$(DIR_OBJ)/$(APP_EXEC)
158+
159+
run: exec-pre exec-run exec-post
160+
dbg: exec-pre exec-dbg exec-post
161+
162+
####### Update and Download
163+
164+
git-pre:
165+
@echo GitHub ...
166+
167+
git-post:
168+
@echo Done.
169+
170+
git-upload:
171+
@git add conf src resources Makefile INFO INSTALL; git commit -m "Compile and update autmatic"; git push origin master;
172+
173+
git-download:
174+
@git pull --recurse-submodules
175+
@git submodule update --remote --recursive
176+
@git submodule foreach git pull origin master
177+
178+
upload: git-pre git-upload git-post
179+
download: git-pre git-download git-post
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef TINYENGINE_LTE_COMMON_H_
2+
#define TINYENGINE_LTE_COMMON_H_
3+
4+
#pragma once
5+
6+
#include <SDL/SDL.h>
7+
#include <SDL/SDL_image.h>
8+
9+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef TINYENGINE_LTE_IFONT_H_
2+
#define TINYENGINE_LTE_IFONT_H_
3+
4+
#pragma once
5+
6+
#include <string>
7+
8+
#include "../LTE_Types.h"
9+
#include "../LTE_Utils.h"
10+
11+
template <class T>
12+
class LTE_IFont {
13+
public:
14+
LTE_IFont() {}
15+
LTE_IFont(const LTE_IFont&) = delete;
16+
LTE_IFont(const std::string& path, int ptsize) { LTE_Unused(path, ptsize); }
17+
virtual ~LTE_IFont() {}
18+
virtual void Load(const std::string& path, int ptsize) = 0;
19+
virtual void Draw(const char *text, int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) const = 0;
20+
virtual void SetStyle(const LTE_FontStyle& style) = 0;
21+
virtual T GetNative() const = 0;
22+
};
23+
24+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef TINYENGINE_LTE_ITEXTURE_H_
2+
#define TINYENGINE_LTE_ITEXTURE_H_
3+
4+
#pragma once
5+
6+
#include <string>
7+
#include <SDL/SDL.h>
8+
#include "../LTE_Types.h"
9+
#include "../LTE_Utils.h"
10+
11+
template <class T>
12+
class LTE_ITexture {
13+
public:
14+
LTE_ITexture() {}
15+
LTE_ITexture(const LTE_ITexture&) = delete;
16+
LTE_ITexture(const std::string& path) { LTE_Unused(path); }
17+
virtual ~LTE_ITexture() {}
18+
virtual void Load(const std::string& path) = 0;
19+
virtual void Draw(int x, int y, uint32_t w, uint32_t h, int row, int col) const = 0;
20+
virtual void Draw(int x, int y) const = 0;
21+
virtual T GetNative() const = 0;
22+
const LTE_Size& GetSize() const { return this->_size; }
23+
protected:
24+
LTE_Size _size {0,0};
25+
};
26+
27+
#endif

include/TinyEngine/LTE_Clock.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#ifndef TINYENGINE_LTE_CLOCK_H_
2+
#define TINYENGINE_LTE_CLOCK_H_
3+
4+
#pragma once
5+
6+
#include <cassert>
7+
#include <iostream>
8+
#include <string>
9+
#include <SDL/SDL_timer.h>
10+
11+
12+
class LTE_Clock
13+
{
14+
public:
15+
LTE_Clock()
16+
: _startTicks(0)
17+
, _pausedTicks(0)
18+
, _paused(true)
19+
, _started(false)
20+
{
21+
}
22+
void Start()
23+
{
24+
this->_started = true;
25+
this->_paused = false;
26+
this->_startTicks = SDL_GetTicks();
27+
this->_pausedTicks = 0;
28+
}
29+
void Stop()
30+
{
31+
this->_started = false;
32+
this->_paused = false;
33+
this->_startTicks = 0;
34+
this->_pausedTicks = 0;
35+
}
36+
void Pause()
37+
{
38+
if (this->_started && !this->_paused)
39+
{
40+
this->_paused = true;
41+
this->_pausedTicks = SDL_GetTicks() - this->_startTicks;
42+
this->_startTicks = 0;
43+
}
44+
}
45+
void Unpause()
46+
{
47+
if (this->_started && this->_paused)
48+
{
49+
this->_paused = false;
50+
this->_startTicks = SDL_GetTicks() - this->_pausedTicks;
51+
this->_pausedTicks = 0;
52+
}
53+
}
54+
uint32_t GetMSeconds() const
55+
{
56+
uint32_t time = 0;
57+
if (this->_started)
58+
{
59+
if (this->_paused)
60+
{
61+
time = this->_pausedTicks;
62+
}
63+
else
64+
{
65+
time = SDL_GetTicks() - this->_startTicks;
66+
}
67+
}
68+
return time;
69+
}
70+
float GetSeconds() const
71+
{
72+
return static_cast<float>(this->GetMSeconds()) / 1000.f;
73+
}
74+
bool IsStarted() const
75+
{
76+
return this->_started;
77+
}
78+
bool IsPaused() const
79+
{
80+
return this->_paused && this->_started;
81+
}
82+
private:
83+
uint32_t _startTicks { 0 };
84+
uint32_t _pausedTicks { 0 };
85+
bool _paused { false };
86+
bool _started { false };
87+
};
88+
89+
#endif /* TINYENGINE_LTE_CLOCK_H_ */

include/TinyEngine/LTE_Common.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef TINYENGINE_LTE_COMMON_H_
2+
#define TINYENGINE_LTE_COMMON_H_
3+
4+
#pragma once
5+
6+
#ifdef USE_OPENGL
7+
# include "OpenGL/LTE_Common.h"
8+
#else
9+
# include "SDL/LTE_Common.h"
10+
#endif
11+
12+
#endif

0 commit comments

Comments
 (0)