Skip to content

Commit

Permalink
v0.5.0 Release (#12)
Browse files Browse the repository at this point in the history
* F/interaction box (#11)

* create interaction box for player

* what

* get interactions talking together

* show interaction panel

* create multiple textboxes..

* find bug with offset making text blurry on loading.

* try fix

* add victory music, and proper text display

* type properly

* typing sound

* add in rectangle constructors and comparisons

* fix issue with fade

* get bgm secondary working

* console working

* remove warning

* fix things

* try fix memory issue

* F/standards (#13)

* use weak_ptr?

* add in memcheck

* hopefully fix surface loading

* try yes

* yes try stop

* try fix this stuff

* try and do yes do

* add in wrapper for file loading

* fix issue with offset with 2 static set, remove comments, make console widget always scroll

* add in gif

* able to mute secondary music

* remove multiple loads on text

* load text once on loading screen

* try things, not work

* fix warnings

* reorder

* try adding in ctor to bjgame

* try adding in ctor to bjgame

* try shared

* memcheck

* fix leaks / valgrind, push

* tryfix windows

* remove windows until bugfix

* remove windows release until bugfix
  • Loading branch information
kjblanchard authored Nov 26, 2024
1 parent 697edd7 commit 7270fa4
Show file tree
Hide file tree
Showing 67 changed files with 918 additions and 400 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
strategy:
matrix:
include:
- os: windows
make_cmd: wrebuild
suffix: zip
zlib: wzlib
name: win
# - os: windows
# make_cmd: wrebuild
# suffix: zip
# zlib: wzlib
# name: win
- os: macos
make_cmd: xrebuild
suffix: tgz
Expand Down Expand Up @@ -88,9 +88,9 @@ jobs:
strategy:
matrix:
include:
- os: win
artifact_name: EscapeTheFate.zip
asset_name: supergoon_win.zip
# - os: win
# artifact_name: EscapeTheFate.zip
# asset_name: supergoon_win.zip
- os: mac
artifact_name: EscapeTheFate.tgz
asset_name: supergoon_mac.tgz
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
- Play the game here, or likely watch its "progress" [Play!](https://escapethefate.supergoon.com)
- Project board [Board](https://github.com/users/kjblanchard/projects/11)
- ![Build All Platforms]( https://github.com/kjblanchard/sgEngine/actions/workflows/build.yml/badge.svg)
- ![Status Picture](https://github.com/kjblanchard/sgEngine/blob/master/img/debug.gif?raw=true)

- Current Status picture
- ![Status Picture](https://github.com/kjblanchard/sgEngine/blob/master/img/state.gif?raw=true)
- Uses imgui for development debugging.
- ![Status Picture](https://github.com/kjblanchard/sgEngine/blob/master/img/state.gif?raw=true)


## Installation
- Run any of the make commands for your platform, or run cmake directly, currently this bundles the demo game and engine together
Expand Down
File renamed without changes.
Binary file added assets/bgm/victory.ogg
Binary file not shown.
4 changes: 2 additions & 2 deletions assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"x": 512,
"y": 288
},
"skipLogos": false,
"mute": false
"skipLogos": true,
"mute": true
}

Binary file added assets/img/interaction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions assets/tiled/goonRpg.tiled-session
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"activeFile": "debugSouth.tmj",
"activeFile": "debugTown.tmj",
"expandedProjectPaths": [
"."
],
Expand All @@ -15,8 +15,8 @@
"scale": 2,
"selectedLayer": 1,
"viewCenter": {
"x": 396.5,
"y": 246.5
"x": 393,
"y": 243
}
},
"debugTown.tmj": {
Expand All @@ -25,25 +25,25 @@
3
],
"scale": 2,
"selectedLayer": 4,
"selectedLayer": 5,
"viewCenter": {
"x": 300.25,
"y": 140.25
"x": 300.5,
"y": 140.5
}
},
"debugTownHome.tmj": {
"expandedGroupLayers": [
4
],
"expandedObjectLayers": [
5,
6
6,
5
],
"scale": 3,
"selectedLayer": 4,
"viewCenter": {
"x": 125.5,
"y": 85.5
"x": 125.66666666666669,
"y": 85.66666666666664
}
},
"house.tsj": {
Expand Down Expand Up @@ -75,12 +75,12 @@
],
"project": "goonRpg.tiled-project",
"recentFiles": [
"debugTown.tmj",
"debugTownHome.tmj",
"house.tsj",
"inside.tsj",
"terrain.tsj",
"debugSouth.tmj",
"outside.tsj",
"debugSouth.tmj"
"terrain.tsj",
"inside.tsj",
"house.tsj",
"debugTownHome.tmj",
"debugTown.tmj"
]
}
Binary file modified img/debug.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/state.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(SRC_FILES
src/Tween/Tween.cpp
src/Tween/Sequence.cpp
src/Events.cpp
src/Filesystem.cpp
src/Aseprite/AsepriteAnimation.cpp
src/Content/AsepriteDocument.cpp
src/Content/Font.cpp
Expand Down Expand Up @@ -42,6 +43,7 @@ if(imgui)
src/Widgets/UIWidget.cpp
src/Widgets/Global.cpp
src/Widgets/LevelWidget.cpp
src/Widgets/ConsoleWidget.cpp
)
endif()

Expand Down
6 changes: 2 additions & 4 deletions src/engine/external/include/SupergoonEngine/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
*
*/

/**
* @brief Wraps a function, or a line (so that you can return and define a variable) and measure it and display the time it took, identifier is a descriptive name for it
*
*/
/**
* @brief The level that we should show debug events at.
*
Expand Down Expand Up @@ -73,6 +69,8 @@ void sgLogError(const char *format, ...);
*/
void sgLogCritical(const char *fmt, ...);

void sgSetDebugFunction(void (*)(const char *, const char *, int));

void sgSetLogLevel(int newLevel);

#ifdef __cplusplus
Expand Down
8 changes: 8 additions & 0 deletions src/engine/external/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#define MAX_LOG_SIZE 400

static void (*logFunc)(const char *, const char *, int) = NULL;

/**
* @brief The file that will be written to when logs are put.
*
Expand Down Expand Up @@ -60,6 +62,9 @@ int sgInitializeDebugLogFile(void) {
sgLogError("Could not open file for logging!");
return 0;
}
void sgSetDebugFunction(void (*func)(const char *, const char *, int)) {
logFunc = func;
}

int sgCloseDebugLogFile(void) {
if (!openDebugFile)
Expand All @@ -77,6 +82,9 @@ static void Log(sgLogLevel level, const char *thing_to_write) {
strftime(buf, sizeof(buf), "%m-%d-%H:%M-%S", gm_time);
FILE *outStream = level == Log_LError ? stderr : stdout;
fprintf(outStream, "%s: %s end\n", buf, thing_to_write);
if (logFunc) {
logFunc(buf, thing_to_write, level);
}
if (level == Log_LError && openDebugFile) {
fprintf(openDebugFile, "%s: %s\n", buf, thing_to_write);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class AsepriteDocument;
class AsepriteAnimation {
public:
AsepriteAnimation(std::string n);
~AsepriteAnimation();
std::string Filename();
void Load();
void UpdateAnimation(double d);
Expand Down
29 changes: 20 additions & 9 deletions src/engine/include/Supergoon/Content/ContentRegistry.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <Supergoon/Content/Content.hpp>
#include <Supergoon/Log.hpp>
#include <memory>
#include <unordered_map>

Expand All @@ -13,7 +14,7 @@ class ContentRegistry {
// Loads all content that isn't loaded
static void LoadAllContent();
// Clear any content that isn't being used, useful to run between loading levels, if forced it will force destroy(usually only actually cleans when above 20 stale)
static void ClearStaleContent(bool force = false);
static void ClearStaleContent();
// Unloads all content and clears the loaded content list, even if shared ptrs still have references
static void DestroyAllContent();
/**
Expand All @@ -27,9 +28,12 @@ class ContentRegistry {
static std::shared_ptr<T> CreateContent(const std::string& key, Args&&... args) {
auto it = _loadedContent.find(key);
if (it != _loadedContent.end()) {
std::shared_ptr<T> specificContent = std::dynamic_pointer_cast<T>(it->second);
if (specificContent) {
return specificContent;
auto shared = it->second.lock();
if (shared) {
auto sharedCast = std::dynamic_pointer_cast<T>(shared);
if (sharedCast) {
return sharedCast;
}
}
}
// If content doesn't exist or is expired, load it and store it in the map
Expand All @@ -39,7 +43,7 @@ class ContentRegistry {
}
static bool ContentExists(const std::string& key) {
auto it = _loadedContent.find(key);
if (it != _loadedContent.end()) {
if (it != _loadedContent.end() && !it->second.expired()) {
return true;
}
return false;
Expand All @@ -48,16 +52,23 @@ class ContentRegistry {
static std::shared_ptr<T> GetContent(const std::string& key) {
auto it = _loadedContent.find(key);
if (it != _loadedContent.end()) {
std::shared_ptr<T> specificContent = std::dynamic_pointer_cast<T>(it->second);
if (specificContent) {
return specificContent;
auto thing = it->second.lock();
if (it->second.lock()) {
auto shared = std::dynamic_pointer_cast<T>(it->second.lock());
if (shared) {
return shared;
}
}
// std::shared_ptr<T> specificContent = std::dynamic_pointer_cast<T>(it->second);
// if (specificContent) {
// return specificContent;
// }
}
return nullptr;
}

private:
static std::unordered_map<std::string, std::shared_ptr<Content>> _loadedContent;
static std::unordered_map<std::string, std::weak_ptr<Content>> _loadedContent;
friend class ContentWidget;
};

Expand Down
6 changes: 3 additions & 3 deletions src/engine/include/Supergoon/Content/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class Image : public Content {
void SetAlpha(int alpha);

private:
SDL_Texture* _image;
SDL_Texture* _image = nullptr;
ImageType _imageType;
float _width;
float _height;
float _width = 0;
float _height = 0;
SDL_Surface* _surface = nullptr;
Color _imageColor = {255, 255, 255, 255};

Expand Down
4 changes: 3 additions & 1 deletion src/engine/include/Supergoon/Content/Text.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once
#include <Supergoon/Content/Content.hpp>
#include <Supergoon/Content/Font.hpp>
#include <Supergoon/Content/Image.hpp>
#include <Supergoon/Primitives/Color.hpp>
#include <Supergoon/Primitives/Point.hpp>
#include <Supergoon/Primitives/Rectangle.hpp>
#include <memory>
#include <vector>
namespace Supergoon {
class Image;
class Text : public Content {
public:
Text(std::string text, std::string fontName, int size);
Expand Down Expand Up @@ -37,6 +38,7 @@ class Text : public Content {
int _lettersToDraw;
int _paddingL = 0, _paddingR = 0, _paddingT = 0; //,_paddingB = 0;
int _alpha = 255;
std::vector<std::shared_ptr<Image>> _letterImages;
std::shared_ptr<Font> _font;
std::shared_ptr<Image> _image;
// We will keep the text within this space
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct GameState {
bool Loading;
bool CameraFollowTarget;
bool EnteringBattle;
bool Interacting;
// Level* CurrentLevel;
};
} // namespace Supergoon
1 change: 1 addition & 0 deletions src/engine/include/Supergoon/Events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct BuiltinEventTypes {
uint32_t LevelChangeEvent;
uint32_t ResetGameEvent;
uint32_t PlayBgmEvent;
uint32_t StopBgmEvent;
uint32_t UiFadeInStart;
uint32_t UiFadeInEnd;
uint32_t UiFadeOutStart;
Expand Down
9 changes: 9 additions & 0 deletions src/engine/include/Supergoon/Filesystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include <fstream>
#include <iostream>
#include <istream>
namespace Supergoon {
// Loads a file that is needed for the game to run, if the file doesn't exist throws an error and exits.
std::ifstream SafeLoadFile(std::string& name);

} // namespace Supergoon
27 changes: 10 additions & 17 deletions src/engine/include/Supergoon/Game.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_video.h>
#include <SupergoonEngine/clock.h>

#include <Supergoon/Events.hpp>
#include <Supergoon/Graphics/Graphics.hpp>
#include <Supergoon/Sound.hpp>
#include <memory>

typedef union SDL_Event SDL_Event;

namespace Supergoon {
class Sound;
class Graphics;
class Events;
class Game;
}
} // namespace Supergoon

#define REGISTER_GAME(DERIVED_GAME_CLASS) \
extern "C" Game* sgRegisterGame() { \
Expand All @@ -26,12 +26,8 @@ Supergoon::Game* sgRegisterGame();
#endif

namespace Supergoon {
class Sound;
class Graphics;
class Events;
class Game {
public:
Game();
virtual ~Game();
// Happens once before game start
void Initialize();
Expand All @@ -48,19 +44,16 @@ class Game {
// Happens after update
virtual void Draw() = 0;
virtual void Reset() = 0;
// inline Sound& GetSound() { return *_sound; }
// static inline Game* Instance() { return _game; }
static double DeltaTime();
static double DeltaTimeMS();
// static inline void SetGameInstance(Game* game) { _game = game; };

protected:
private:
void InitializeImGui();
bool _initialized = false;
geClock _clock;
std::unique_ptr<Sound> _sound = nullptr;
std::unique_ptr<Graphics> _graphics = nullptr;
std::unique_ptr<Events> _events = nullptr;
// static Game* _game;
std::shared_ptr<Sound> _sound = nullptr;
std::shared_ptr<Graphics> _graphics = nullptr;
std::shared_ptr<Events> _events = nullptr;
};
} // namespace Supergoon
1 change: 1 addition & 0 deletions src/engine/include/Supergoon/Graphics/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Graphics {
~Graphics();
void CreateWindow(int width, int height, std::string name);
void InitializeImGui();
void CloseImGui();
void DrawStart();
void DrawEnd();
void DrawImGui();
Expand Down
Loading

0 comments on commit 7270fa4

Please sign in to comment.