Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/aw/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>

#include "general\settings.hpp"
#include "states\stateMachine.hpp"
#include "general/settings.hpp"
#include "states/stateMachine.hpp"


namespace aw
Expand Down Expand Up @@ -34,4 +34,4 @@ namespace aw
};
}

#endif
#endif
63 changes: 38 additions & 25 deletions include/aw/general/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,39 @@ namespace aw
if (line == "[window]")
{
//Next row = size, format: "width height"
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.size.x >> windowSettings.size.y;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.size.x >> windowSettings.size.y;
}
//Next row = title
std::getline(file, windowSettings.title);
//Next row = style
std::getline(file, line);
sstr = std::stringstream(line);
sstr >> windowSettings.style;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.style;
}
//Next row = contextSettings format: "depth stencil antialiasing major minor"
std::getline(file, line);
sstr = std::stringstream(line);
sstr >> windowSettings.settings.depthBits >> windowSettings.settings.stencilBits >>
windowSettings.settings.antialiasingLevel >> windowSettings.settings.majorVersion >>
windowSettings.settings.minorVersion;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.settings.depthBits >> windowSettings.settings.stencilBits >>
windowSettings.settings.antialiasingLevel >> windowSettings.settings.majorVersion >>
windowSettings.settings.minorVersion;
}
//Next row = vsync
std::getline(file, line);
sstr = std::stringstream(line);
sstr >> windowSettings.vsync;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.vsync;
}
//Next row = shaders
std::getline(file, line);
sstr = std::stringstream(line);
sstr >> windowSettings.shaders;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> windowSettings.shaders;
}
//Read everything
file.close();
return true;
Expand All @@ -89,14 +99,17 @@ namespace aw
if (line == "[sound]")
{
//Next row = enabled
std::getline(file, line);
std::stringstream sstr(line);
sstr >> soundSettings.enabled;
{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> soundSettings.enabled;
}
//Next row = volumes format: "menu game"
std::getline(file, line);
sstr = std::stringstream(line);
sstr >> soundSettings.volumeMusic >> soundSettings.volumeVFX;

{
std::getline(file, line);
std::stringstream sstr(line);
sstr >> soundSettings.volumeMusic >> soundSettings.volumeVFX;
}
//Read everything
file.close();
return true;
Expand Down Expand Up @@ -129,4 +142,4 @@ namespace aw

file << "\n";
}
}
}
4 changes: 2 additions & 2 deletions include/aw/states/stateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace aw

private:
std::stack<State_ptr> mStateStack;
std::atomic<int> mShouldPopState = 0; //Loading screen is working due to multithreading = protect this var
std::atomic<int> mShouldPopState{0}; //Loading screen is working due to multithreading = protect this var
};
}

#endif
#endif
5 changes: 3 additions & 2 deletions include/game/states/menuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ namespace aw
if (callback.id > 100 && callback.id < 200)
{
std::string path = "data/levels/Level" + std::to_string(callback.id - 100) + ".txt";
pushState(StateMachine::State_ptr(new GameState(getStateMachine(), mWindow, mSettings, path)));
auto state = StateMachine::State_ptr(new GameState(getStateMachine(), mWindow, mSettings, path));
pushState(state);
}
}
}
Expand All @@ -65,4 +66,4 @@ namespace aw
{
mGui.draw(true);
}
}
}
4 changes: 2 additions & 2 deletions include/game/states/menuState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "../../aw/states/state.hpp"

#include <TGUI\TGUI.hpp>
#include <TGUI/TGUI.hpp>

namespace sf
{
Expand Down Expand Up @@ -33,4 +33,4 @@ namespace aw
};
}

#endif
#endif
54 changes: 54 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#-------------------------------------------------------------------------------
# General makefile for C/C++ projects using SFML on linux
#-------------------------------------------------------------------------------

TARGET := $(shell basename $(CURDIR))
SOURCES := include include/game/camera include/game/map include/game/misc include/game/player include/game/spawner include/game/states include/aw/ include/aw/colSystem include/aw/general include/aw/states include/aw/utilities
INCLUDES := include include/aw include/game
BUILD := build

#-------------------------------------------------------------------------------
SYSTEM := $(shell uname -s)
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cpp))
OFILES := $(addprefix $(BUILD)/,$(CFILES:%.c=%.o)\
$(CPPFILES:%.cpp=%.o))
DEPENDFILES := $(OFILES:%.o=%.d)
CC := gcc
CXX := g++
INCLUDEFILES := $(foreach dir,$(INCLUDES),$(wildcard $(dir)/*.h))
INCLUDE := $(addprefix -I,$(INCLUDES))
DEPENDFLAGS := -MMD -MP
CFLAGS := $(INCLUDE) -Wall -O2
CXXFLAGS := $(CFLAGS) -std=c++11
# Set LIBSUFFIX to -s for static build (for some reason not working :/ )
LIBSUFFIX :=
LIBS := tgui$(LIBSUFFIX) sfml-audio$(LIBSUFFIX) sfml-graphics$(LIBSUFFIX) sfml-window$(LIBSUFFIX) sfml-system$(LIBSUFFIX) GL GLU X11 Xrandr freetype GLEW jpeg sndfile openal
LDFLAGS := $(addprefix -l,$(LIBS))

all: setup $(TARGET)

$(TARGET): $(OFILES)
$(CXX) $(CFLAGS) -o $(TARGET) $^ $(LDFLAGS)

.PHONY: setup clean

setup:
$(foreach source,$(SOURCES),$(shell echo \
$(shell [ -d $(BUILD)/$(source) ] || ( mkdir -p $(BUILD)/$(source)) )))

clean:
-rm -fr $(TARGET) $(BUILD)

-include $(DEPENDFILES)

#-------------------------------------------------------------------------------
$(BUILD)/%.o: %.c
@echo $(notdir $<)
$(CC) $(DEPENDFLAGS) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
@echo

$(BUILD)/%.o: %.cpp
@echo $(notdir $<)
$(CXX) $(DEPENDFLAGS) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
@echo