Skip to content

Commit

Permalink
Alpha 1.1 (#13)
Browse files Browse the repository at this point in the history
Alpha 1.1
  • Loading branch information
justin-ys authored Dec 29, 2023
2 parents ac5eede + e9fcb4f commit 26f328c
Show file tree
Hide file tree
Showing 37 changed files with 746 additions and 213 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ log.txt
test_log.txt
Spylike-v*
lib/bin
lib/include
lib/include
build/*
40 changes: 34 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
CXX=g++
CPPFLAGS=-std=c++2a -Iinclude -Igame/include -Ilib/include -DMA_NO_PULSEAUDIO
LDLIBS=
OBJS=graphics/*.cpp logging/*.cpp models/*.cpp level/*.cpp audio/*.cpp game/*.cpp game/entities/*.cpp game/UI/*.cpp util/*.cpp main.cpp
LDLIBS=-Llib/bin
SOURCES=$(wildcard graphics/*.cpp logging/*.cpp models/*.cpp level/*.cpp audio/*.cpp game/*.cpp game/entities/*.cpp game/UI/*.cpp util/*.cpp main.cpp)
OBJS=$(patsubst %.cpp, build/%.o, $(SOURCES))
VER=vA1
USE_DISCORD=1

ifndef PDCURSES_BACKEND
ifeq ($(OS),Windows_NT)
Expand All @@ -12,6 +14,7 @@ ifndef PDCURSES_BACKEND
ifeq ($(UNAME_S),Linux)
ifndef USE_NCURSES
USE_NCURSES=1
CPPFLAGS+= -DUSE_NCURSESW
endif
PDCURSES_BACKEND=x11
LDLIBS+= -lpthread -lm -ldl
Expand All @@ -22,21 +25,46 @@ endif
ifeq ($(USE_NCURSES), 1)
LDLIBS+= -lncursesw
else
LDLIBS+= -Llib/bin -lpdcurses
LDLIBS+= -lpdcurses
endif

ifndef PDCURSES_BACKEND
$(error "OS not detected or supported - please specify PDCurses backend (wincon, x11, sdl2))
endif

ifeq ($(USE_DISCORD), 1)
$(shell mkdir -p lib/bin)
$(shell mkdir -p lib/include)
ifeq ($(UNAME_S),Linux)
$(shell cp -u lib/discord-rpc-linux/linux-dynamic/include/*.h lib/include)
$(shell cp -u lib/discord-rpc-linux/linux-dynamic/lib/libdiscord-rpc.so lib/bin)
LDLIBS+= -ldiscord-rpc
CPPFLAGS+= -DUSE_DISCORD
else
USE_DISCORD=0
endif
endif

$(shell mkdir -p lib/include)
$(shell cp lib/miniaudio/miniaudio.h lib/include/miniaudio.h)

build: build-pdcurses
build: $(OBJS)
cp lib/miniaudio/miniaudio.h lib/include/miniaudio.h
$(CXX) $(CPPFLAGS) -o Spylike-$(VER) $(OBJS) $(LDLIBS)
$(CXX) $(CPPFLAGS) -o Spylike-$(VER) $(OBJS) $(LDLIBS) -Wl,-rpath=lib/bin

build/%.o: %.cpp
mkdir -p $(@D)
$(CXX) $(CPPFLAGS) -c -o $@ $(LDLIBS) $^

debug: CPPFLAGS+= -g -O0
debug: CPPFLAGS+= -g -O0 -v
debug: build

clean:
rm -rf lib/bin/*
rm -rf lib/include/*
rm -rf build/*
rm -rf lib/src/*

build-pdcurses:
cd lib && mkdir -p bin
cd lib && mkdir -p include
Expand Down
Binary file removed Spylike-TestSuite-vA1.exe
Binary file not shown.
8 changes: 6 additions & 2 deletions events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ CAMERA_MoveUp: Moves the camera up by one unit. (CameraEvent)
CAMERA_MoveDown: Moves the camera down by one unit. (CameraEvent)
CAMERA_MoveRight: Moves the camera right by one unit. (CameraEvent)
CAMERA_MoveLeft: Moves the camera left by one unit. (CameraEvent)
CAMERA_Move: Moves the camera to pos specified in CameraEvent.pos.
CAMERA_Move: Moves the camera origin to pos specified in CameraEvent.pos.
CAMERA_MoveCenter: Centers the camera at pos specified in CameraEvent.pos.
CAMERA_MoveCenterH: Centers the camera horizontally at pos specified in CameraEvent.pos, ignoring y
CAMERA_MoveCenterX: Centers the camera vertically at pos specified in CameraEvent.pos, ignoring x


Audio:
AUDIO_PlayMusic: Plays the music with filepath [rootPath]/AudioPlayEvent.sound and volume AudioPlayEvent.volume
Expand All @@ -24,4 +28,4 @@ MENU_ButtonClick: Calls when any button is clicked, ID given in MenuButtonEvent.
LEVEL_change: Changes the level to LevelChangeEvent.levelPath
GAME_KeyCollect: The key for the final boss door was collected.
GAME_DoorRequest: Event for the door to check whether it can be opened.
GAME_DoorResponse: Response from the game manager about GAME_DoorRequest, result in bool DoorResponse.result.
GAME_DoorResponse: Response from the game manager about GAME_DoorRequest, result in bool DoorResponse.result.
10 changes: 5 additions & 5 deletions game/UI/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void MenuButton::click() {
eventManager->emit(ev);
}

void MenuButton::draw(GeometryRenderer& painter) {
void MenuButton::draw(TextRenderManager& painter) {
std::string drawnText = text;
// note that subtracting 2 from width may cause integer overflow(???) so we have to do it this way
if (((text.length() + 2) > width) || (height < 3)) {
Expand All @@ -43,7 +43,7 @@ void MenuButton::on_event(Event& e) {}

void MenuButton::on_update() {}

void Menu::draw(GeometryRenderer& painter) {
void Menu::draw(TextRenderManager& painter) {
Coordinate selectionPos = buttons.find(currentSelection)->second.pos;
Coordinate arrowPos = Coordinate(selectionPos.x + buttons.find(currentSelection)->second.width/2, selectionPos.y - 1);
painter.draw(arrowPos, 'v', "UI");
Expand All @@ -53,7 +53,7 @@ void Menu::draw(GeometryRenderer& painter) {
}
}

void PauseMenu::draw(GeometryRenderer& painter) {
void PauseMenu::draw(TextRenderManager& painter) {
/*
painter.drawString(Coordinate(1, 1), ""
"|||\n"
Expand All @@ -68,12 +68,12 @@ void PauseMenu::draw(GeometryRenderer& painter) {
Menu::draw(painter);
}

void GameOverMenu::draw(GeometryRenderer& painter) {
void GameOverMenu::draw(TextRenderManager& painter) {
painter.drawString(Coordinate(painter.getScreenWidth()/2-8, 1), "GAME OVER!", "UI");
Menu::draw(painter);
}

void StartMenu::draw(GeometryRenderer& painter) {
void StartMenu::draw(TextRenderManager& painter) {
painter.drawString(Coordinate(painter.getScreenWidth()/2-12, 1), "WELCOME TO SPYLIKE!", "UI");
painter.drawString(Coordinate(painter.getScreenWidth()/2-7, 2), "CONTROLS:", "UI");
painter.drawString(Coordinate(painter.getScreenWidth()/2-10, 3), "W,A,S,D MOVEMENT", "UI");
Expand Down
Loading

0 comments on commit 26f328c

Please sign in to comment.