diff options
| -rw-r--r-- | Makefile | 25 | ||||
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | src/Game.cpp | 12 | ||||
| -rw-r--r-- | src/Makefile | 15 |
4 files changed, 33 insertions, 24 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f829a19 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +CXX = g++ +CXXFLAGS = --std=c++14 -g -O2 -Wall +LDLIBS = -lsfml-graphics -lsfml-window -lsfml-system + +SOURCE_DIR = src/ +OBJECTS_DIR= obj/ +OBJS = main.o State.o Game.o Global.o Enemy1.o Enemy2.o Enemy3.o Powerup.o Entity.o Player.o +OBJECTS = $(addprefix $(OBJECTS_DIR),$(OBJS)) + +TARGET = sfml-rpg + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $(TARGET) $(LDLIBS) + +$(OBJECTS_DIR)%.o: $(SOURCE_DIR)%.cpp + $(MKDIR_P) $(dir $@) + $(CXX) $(CXXFLAGS) -c $< -o $@ + +clean: + $(RM) $(OBJECTS) sfml-rpg + +RM = rm -f +MKDIR_P = mkdir -p @@ -6,7 +6,7 @@ Simple C++ SFML school project. - [**libsfml-dev**](https://packages.debian.org/buster/libsfml-dev) for Debian based distributions - [**sfml**](https://archlinux.org/packages/community/x86_64/sfml/) for Arch based distributions ``` -g++ -std=c++14 -O2 -o sfml-rpg main.cpp -lsmfl-graphics -lsfml-window -lsfml-system +make ``` ### Windows @@ -14,8 +14,9 @@ g++ -std=c++14 -O2 -o sfml-rpg main.cpp -lsmfl-graphics -lsfml-window -lsfml-sys - Install [mingw-w64](http://mingw-w64.org/doku.php/download/mingw-builds) - Add mingw64\bin to $PATH ``` -g++ -std=c++14 -O2 -o sfml-rpg main.cpp -I SFML-2.5.1\include -L SFML-2.5.1\lib -lsfml-graphics -lsfml-window -lsfml-system +g++ -std=c++14 -g -O2 -Wall -o sfml-rpg *.cpp -I SFML-2.5.1\include -L SFML-2.5.1\lib -lsfml-graphics -lsfml-window -lsfml-system ``` +Or just use Linux > If you use Visual Studio or Code::Blocks you can follow [official tutorial](https://www.sfml-dev.org/tutorials) for setting up SFML. ## Requirements - SFML 2.5+ version diff --git a/src/Game.cpp b/src/Game.cpp index fdb5f54..a0c28af 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -24,7 +24,7 @@ void Game::initshapes() } void Game::initui() { - if(!font.loadFromFile("../assets/fonts/LiberationMono-Regular.ttf")) + if(!font.loadFromFile("assets/fonts/LiberationMono-Regular.ttf")) { std::cerr<<"Font not found\n"; } @@ -49,11 +49,11 @@ void Game::initui() } void Game::inittex() { - if(!healthtex.loadFromFile("../assets/images/healing.png")) + if(!healthtex.loadFromFile("assets/images/healing.png")) { std::cerr<<"Texture not found\n"; } - if(!neprijateljtex.loadFromFile("../assets/images/nep.png")) + if(!neprijateljtex.loadFromFile("assets/images/nep.png")) { std::cerr<<"Texture not found\n"; } @@ -83,10 +83,10 @@ void Game::updatewin() Game::Game(sf::RenderWindow *glprozor) { prozor=glprozor; - initui(); updatewin(); - initent(); + initui(); initshapes(); + initent(); inittex(); } bool Game::gameover() @@ -261,10 +261,8 @@ void Game::respawn() void Game::run() { if(gameover()) return; - updateui(); igrac.updatest(dt); - respawn(); position(); checkcollision(); diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index b4ed4bd..0000000 --- a/src/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CXX = g++ -CXXFLAGS = --std=c++14 -g -O2 -Wall -SRC_DIR = src/ -OBJECTS = main.o State.o Game.o Global.o Enemy1.o Enemy2.o Enemy3.o Powerup.o Entity.o Player.o - -all: sfml-rpg - -sfml-rpg: $(OBJECTS) - $(CXX) $(CXXFLAGS) $(OBJECTS) -o sfml-rpg -lsfml-graphics -lsfml-window -lsfml-system - -%.o : %.cpp - $(CXX) $(CXXFLAGS) -c $< - -clean: - rm -f $(OBJECTS) sfml-rpg |
