Compare commits

9 Commits

36 changed files with 207 additions and 76 deletions

BIN
.DS_Store vendored

Binary file not shown.

3
.gitignore vendored
View File

@ -110,3 +110,6 @@ CMakeCache.txt
# macOS finder files # macOS finder files
.DS_Store .DS_Store
# VS Code project stuff
.vscode*

View File

@ -12,7 +12,7 @@ PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer>=2.0.0) PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer>=2.0.0)
#PKG_SEARCH_MODULE(BOOSTFILESYSTEM boost_filesystem >=) #PKG_SEARCH_MODULE(BOOSTFILESYSTEM boost_filesystem >=)
find_package(Boost COMPONENTS system filesystem REQUIRED) #find_package(Boost COMPONENTS system filesystem REQUIRED)
# Point to our own cmake modules # Point to our own cmake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
@ -27,4 +27,4 @@ file(GLOB_RECURSE CPPSOURCES src/*.cpp)
add_executable(${PROJECT_NAME} ${CSOURCES} ${CPPSOURCES}) add_executable(${PROJECT_NAME} ${CSOURCES} ${CPPSOURCES})
install(TARGETS ${PROJECT_NAME} DESTINATION bin) install(TARGETS ${PROJECT_NAME} DESTINATION bin)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::system Boost::filesystem PRIVATE /usr/local/lib/libSDL2.dylib /usr/local/lib/libSDL2_image.dylib /usr/local/lib/libSDL2_mixer.dylib) target_link_libraries(${PROJECT_NAME} PRIVATE /usr/local/lib/libSDL2.dylib /usr/local/lib/libSDL2_image.dylib /usr/local/lib/libSDL2_mixer.dylib)

View File

@ -1,9 +1,37 @@
=======
# Kaiju Save Earth # Kaiju Saves Earth
---
Low Rez Jam 2023 Low Rez Jam 2023
A game where you play as a giant monster (Kaiju) who must save all the humans from destroying themselves and the world by catching them and safely stowing them on your back. ![Kaiju Saves Earth Title Screen](assets/textures/ui/titlescreenbig.png "Kaiju Saves Earth")
In the distant future humans are panicked and pose a great risk to each other and themselves. Fortunately there is a giant monster "Kaiju" that come in to scoop up these people before they hurt anyone, storing them safely on its protected shell on its back. You play as the Kaiju trying to save as many people as possible before they hurt themselves.
Controls: w,a,s,d for movement and u,i,j,k for other actions, escape to quit.
Currently on builds on linux and macOS; uses CMake and should be easy enough to port to other systems.
By: By:
Alan Youngblood Alan Youngblood
## INSTALL
### Linux
1. Download and unzip the project files
2. Install KDevelop with your package manager
3. Install dependencies (listed as apt packages with debian/ubuntu and derivative distros): `sudo apt install libboost-dev cmake build-essential libsdl2-2.0-0 libsdl2-dev libsdl2-image-2.0.-0 libsdl2-image-dev libsdl2-mixer-2.0-0 libsdl2-mixer-dev`
4. Open the .kdev4 project file in KDevelop, configure launch to be the executable which should be KaijuSaveEarth/build/KaijuSaveEarth; build should be configured already.
5. Build in KDevelop.
6. Launch/Run from KDevelop.
7. Enjoy playing!
### macOS
1. Download and unzip the project files
2. Install Apple Mac Developer tools in terminal.app: xcode-select --install
3. Install dependencies, we recommend using brew: brew install boost cmake sdl2 sdl2_image sdl2_mixer<br>
4. In terminal: `cd KaijuSaveEarth/build`
5. `cmake ..`
6. `make`
7. `open ..`
8. Double Click the executable KaijuSaveEarth
9. Enjoy playing!

BIN
assets/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@
"height": 4300, "height": 4300,
"width": 2 "width": 2
}, },
"activeFile": "", "activeFile": "kaiju-city-map2.json",
"expandedProjectPaths": [ "expandedProjectPaths": [
"." "."
], ],
@ -20,11 +20,14 @@
"scaleInEditor": 4 "scaleInEditor": 4
}, },
"kaiju-city-map.json": { "kaiju-city-map.json": {
"scale": 3, "expandedObjectLayers": [
"selectedLayer": 1, 3
],
"scale": 4,
"selectedLayer": 0,
"viewCenter": { "viewCenter": {
"x": 86.16666666666666, "x": 132.75,
"y": 10.666666666666671 "y": 137.875
} }
}, },
"kaiju-city-map.json#kaiju-city": { "kaiju-city-map.json#kaiju-city": {
@ -34,10 +37,13 @@
"scale": 1.4114285714285715, "scale": 1.4114285714285715,
"selectedLayer": 0, "selectedLayer": 0,
"viewCenter": { "viewCenter": {
"x": 232.38866396761134, "x": 232.3886639676113,
"y": 218.21862348178138 "y": 218.57287449392717
} }
}, },
"kaiju-city-map.tmj#kaiju-city": {
"scaleInDock": 1
},
"kaiju-city-map.tmx": { "kaiju-city-map.tmx": {
"scale": 1.4114285714285715, "scale": 1.4114285714285715,
"selectedLayer": 0, "selectedLayer": 0,
@ -46,6 +52,18 @@
"y": 116.19433198380568 "y": 116.19433198380568
} }
}, },
"kaiju-city-map2.json": {
"scale": 2,
"selectedLayer": 1,
"viewCenter": {
"x": 169.5,
"y": 148.25
}
},
"kaiju-city-ts.tsj": {
"scaleInDock": 3,
"scaleInEditor": 1
},
"kaiju-city.tsj": { "kaiju-city.tsj": {
"dynamicWrapping": false, "dynamicWrapping": false,
"scaleInDock": 1, "scaleInDock": 1,
@ -70,27 +88,30 @@
}, },
"last.exportedFilePath": "/home/ayoungblood/projects/KaijuSaveEarth/assets/maps", "last.exportedFilePath": "/home/ayoungblood/projects/KaijuSaveEarth/assets/maps",
"last.externalTilesetPath": "/home/ayoungblood/projects/KaijuSaveEarth/assets/maps", "last.externalTilesetPath": "/home/ayoungblood/projects/KaijuSaveEarth/assets/maps",
"last.imagePath": "/home/ayoungblood/projects/KaijuSaveEarth/assets/maps", "last.imagePath": "/Users/ayoungblood/Projects/KaijuSaveEarth/assets/maps",
"lastUsedTilesetExportFilter": "JSON tileset files (*.tsj *.json)", "lastUsedTilesetExportFilter": "JSON tileset files (*.tsj *.json)",
"map.height": 32, "map.height": 40,
"map.lastUsedExportFilter": "All Files (*)", "map.lastUsedExportFilter": "All Files (*)",
"map.lastUsedFormat": "json", "map.lastUsedFormat": "json",
"map.layerDataFormat": null, "map.layerDataFormat": null,
"map.tileHeight": 8, "map.tileHeight": 8,
"map.tileWidth": 8, "map.tileWidth": 8,
"map.width": 32, "map.width": 40,
"openFiles": [ "openFiles": [
"kaiju-city-map2.json"
], ],
"project": "kaiju-city-map.tiled-project", "project": "kaiju-city-map.tiled-project",
"recentFiles": [ "recentFiles": [
"kaiju-city-map2.json",
"kaiju-city-ts.tsj",
"kaiju-city-map.json",
"kaiju-city-map.tmj",
"kaiju-city.tsj",
"testmap.json", "testmap.json",
"kaiju-tokyo.tsj", "kaiju-tokyo.tsj",
"kaiju-city-map.json",
"kaiju-city.tsx", "kaiju-city.tsx",
"br-tiles.tsj", "br-tiles.tsj",
"kaiju-city-map.tmx", "kaiju-city-map.tmx"
"kaiju-city-map.tmj",
"kaiju-city.tsj"
], ],
"tileset.lastUsedFilter": "JSON tileset files (*.tsj *.json)", "tileset.lastUsedFilter": "JSON tileset files (*.tsj *.json)",
"tileset.lastUsedFormat": "json", "tileset.lastUsedFormat": "json",

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,14 @@
{ "columns":16,
"image":"kaiju-city-ts.png",
"imageheight":128,
"imagewidth":128,
"margin":0,
"name":"kaiju-city-ts",
"spacing":0,
"tilecount":256,
"tiledversion":"1.10.1",
"tileheight":8,
"tilewidth":8,
"type":"tileset",
"version":"1.10"
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
src/.DS_Store vendored

Binary file not shown.

7
src/config/intro.json Normal file
View File

@ -0,0 +1,7 @@
{
"intro": {
"1": "IN THE YEAR\n23YY ...\nHUMAN\nPARANOIA\nRUNS WILD\nCONSUMED\nBY FEAR\nAND GREED",
"2": "THEY DESTROY\nEACH OTHER\nAND EARTH\nWHO CAN\nSAVE THEM?\n",
"3": "SURELY NOT\nANOTHER\nHUMAN?!?\nPERHAPS\nONLY A\nGREATER\nMONSTER..."
}
}

View File

@ -52,9 +52,11 @@ public:
collider.x = xpos; collider.x = xpos;
collider.y = ypos; collider.y = ypos;
collider.w = collider.h = size*scale; collider.w = collider.h = size*scale;
setTex(texture); if(texture != ""){
center.x = collider.x+collider.w/2; setTex(texture);
center.y = collider.y+collider.h/2; }
center.x = collider.x+collider.w/2;
center.y = collider.y+collider.h/2;
} }
ColliderComponent(std::string t, int width, int height, bool hasOffset, int oX, int oY, std::string texture) ColliderComponent(std::string t, int width, int height, bool hasOffset, int oX, int oY, std::string texture)
@ -62,11 +64,13 @@ public:
tag = t; tag = t;
collider.w = width; collider.w = width;
collider.h = height; collider.h = height;
offsetX = oX; offsetX = oX;
offsetY = oY; offsetY = oY;
setTex(texture); if(texture != ""){
center.x = collider.x+collider.w/2; setTex(texture);
center.y = collider.y+collider.h/2; }
center.x = collider.x+collider.w/2;
center.y = collider.y+collider.h/2;
} }
void init() override void init() override

View File

@ -66,28 +66,48 @@ public:
spriteType = sType; spriteType = sType;
if(sType == spriteAnimation) if(sType == spriteAnimation)
{ {
/*boost::filesystem::path p{argv[0]}; //std::string fullPath = Game::projPath + json;
p = absolute(p).parent_path(); std::ifstream fin(json);
std::string configPath = "src/config/config.json";
std::string bps = p.string();
size_t charPos = bps.find("build");
bps.erase(charPos,bps.length());
std::string configurationPath = bps + json;*/
std::cout << "Project Path: " << Game::projPath << std::endl;
std::string fullPath = Game::projPath + json;
std::ifstream fin(fullPath);
if(fin.fail()){ if(fin.fail()){
std::cerr<<"ERROR opening json file: " << json << std::endl; std::cerr<<"ERROR opening json file: " << json << std::endl;
} else if (fin.is_open()){ } else if (fin.is_open()){
//printf("Opened a json file\n");
std::ifstream jsonText(json); std::ifstream jsonText(json);
std::ostringstream tmp; std::ostringstream tmp;
tmp << jsonText.rdbuf(); tmp << jsonText.rdbuf();
std::string aJson = tmp.str(); std::string aJson = tmp.str();
cJSON * animJson = cJSON_Parse(aJson.c_str()); cJSON * animJson = cJSON_Parse(aJson.c_str());
std::cout << "animJson: " << std::endl;
std::cout << animJson << std::endl;
char * printOut = cJSON_Print(animJson);
//std::cout << animJson << std::endl;
cJSON * meta = cJSON_GetObjectItem(animJson, "meta"); cJSON * meta = cJSON_GetObjectItem(animJson, "meta");
cJSON * version = cJSON_GetObjectItem(animJson, "version");
cJSON * frameTags = cJSON_GetObjectItem(meta,"frameTags"); cJSON * frameTags = cJSON_GetObjectItem(meta,"frameTags");
cJSON * frames = cJSON_GetObjectItem(animJson, "frames");
int tagsCount = cJSON_GetArraySize(frameTags); int tagsCount = cJSON_GetArraySize(frameTags);
int framesCount = cJSON_GetArraySize(frames);
//std::cout << "tagsCount: " << tagsCount << std::endl;
//std::cout << "version: " << version << std::endl;
const cJSON * aFrame = NULL;
const cJSON * aFrames = NULL;
aFrames =cJSON_GetObjectItemCaseSensitive(animJson, "frames");
cJSON_ArrayForEach(aFrame, aFrames){
cJSON *filename = cJSON_GetObjectItemCaseSensitive(aFrame, "filename");
if (!cJSON_IsNumber(aFrame)){
//printf("Not a number\n");
//printf("Json filename: %s\n",filename);
} else {
//std::cout << "animation frame number: " << aFrame->valueint<< std::endl;
}
}
for (int f = 0; f<framesCount; f++){
cJSON * crrntFrame = cJSON_GetArrayItem(frames, f);
std::string fileName = cJSON_GetObjectItem(crrntFrame, "filename")->valuestring;
std::cout << "Filename for frame is: " << fileName << std::endl;
}
for (int t = 0; t < tagsCount; t++) for (int t = 0; t < tagsCount; t++)
{ {
@ -98,6 +118,7 @@ public:
int toFrame = cJSON_GetObjectItem(animItem, "to")->valueint; int toFrame = cJSON_GetObjectItem(animItem, "to")->valueint;
Animation anim = Animation(fromFrame,toFrame,100); Animation anim = Animation(fromFrame,toFrame,100);
animations.emplace(name, anim); animations.emplace(name, anim);
std::cout << "Animation Name: " << name << "from: " << fromFrame << "to: " << toFrame << std::endl;
Play(name); Play(name);
} }
} }

View File

@ -46,8 +46,8 @@ public:
{ {
// TILESON ~~~~~~~~~~~ // TILESON ~~~~~~~~~~~
//const std::filesystem::path jsonPath = std::filesystem::u8path(mapPath); const std::filesystem::path jsonPath = std::filesystem::u8path(mapPath);
const std::filesystem::path jsonPath = std::filesystem::u8path("/Users/ayoungblood/Projects/KaijuSaveEarth/assets/maps/kaiju-city-map.json"); //const std::filesystem::path jsonPath = std::filesystem::u8path("/Users/ayoungblood/Projects/KaijuSaveEarth/assets/maps/kaiju-city-map.json");
map = t.parse(jsonPath); map = t.parse(jsonPath);
//std::cout << "Trying to load json tile map from: " << jsonPath << std::endl; //std::cout << "Trying to load json tile map from: " << jsonPath << std::endl;
if(map->getStatus() == tson::ParseStatus::OK) if(map->getStatus() == tson::ParseStatus::OK)

View File

@ -145,16 +145,18 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
} }
std::string kaijuTex = Game::projPath + "assets/textures/actors/kaijuturtle.png"; std::string kaijuTex = Game::projPath + "assets/textures/actors/kaijuturtle.png";
std::string fontTex = Game::projPath + "assets/textures/ui/ui-font-lorez5.png";
std::string textBoxTex = Game::projPath + "assets/textures/ui/ui-element-bubble.png";
std::string musicFile = Game::projPath + "assets/audio/music/neuwave.ogg";
std::string sfxFile = Game::projPath + "assets/audio/sfx/bwoop.wav";
assets->AddTexture("player", kaijuTex.c_str()); assets->AddTexture("player", kaijuTex.c_str());
assets->AddTexture("font", "assets/textures/ui/ui-font-lorez5.png"); assets->AddTexture("font", fontTex.c_str());
assets->AddTexture("textBox", "assets/textures/ui/ui-element-bubble.png"); assets->AddTexture("textBox", textBoxTex.c_str());
assets->AddTexture("collider","assets/textures/ColTex.png");
assets->AddMusicTrack("simonZ","assets/audio/music/sillypuppy.ogg"); assets->AddMusicTrack("neuwave",musicFile.c_str());
assets->AddMusicTrack("simonZ","assets/audio/music/victory.ogg");
assets->AddSoundClip("bwoop","assets/audio/sfx/bwoop.wav"); assets->AddSoundClip("bwoop",sfxFile.c_str());
std::string myText = "U to Start"; std::string myText = "U to Start";
@ -177,11 +179,12 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
//ecs implementation //ecs implementation
player.addComponent<TransformComponent>(150*gScale,100*gScale,32,32,globalScale,3); // 180,120 player.addComponent<TransformComponent>(150*gScale,100*gScale,32,32,globalScale,2); // 180,120
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, "assets/textures/actors/kaijuturtle.json"); std::string playerJson = Game::projPath + "assets/textures/actors/kaijuturtle.json";
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, playerJson);
// player.addComponent<PlayerController>(0.0,0.0,false,false,Vector2D().Zero()); // player.addComponent<PlayerController>(0.0,0.0,false,false,Vector2D().Zero());
player.addComponent<ColliderComponent>("player",16*globalScale,32*globalScale, true, 2*globalScale,10*globalScale, "collider"); player.addComponent<ColliderComponent>("player",20*globalScale,20*globalScale, true, 0*globalScale,0*globalScale, "");
player.addComponent<KeyboardController>(); player.addComponent<KeyboardController>();
player.addGroup(groupPlayers); player.addGroup(groupPlayers);
@ -189,7 +192,8 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
levelMap.y = 0; levelMap.y = 0;
// printf("Trying to load Tilemap\n"); // printf("Trying to load Tilemap\n");
gameScene.addComponent<TileMapComponent>("assets/maps/kaiju-city-map.json","kaiju-city","Tile Layer 1","Collision",gScale,player.getComponent<TransformComponent>().position.x+player.getComponent<TransformComponent>().width/2,player.getComponent<TransformComponent>().position.y+player.getComponent<TransformComponent>().height/2); //150,100 std::string mapPath = Game::projPath + "assets/maps/kaiju-city-map2.json";
gameScene.addComponent<TileMapComponent>(mapPath,"kaiju-city-ts","Tile Layer 1","Collision",gScale,player.getComponent<TransformComponent>().position.x+player.getComponent<TransformComponent>().width/2,player.getComponent<TransformComponent>().position.y+player.getComponent<TransformComponent>().height/2); //150,100
gameScene.addGroup(groupMap); gameScene.addGroup(groupMap);
// printf("Completed loading Tilemap\n"); // printf("Completed loading Tilemap\n");
@ -245,7 +249,7 @@ void Game::update()
if (Mix_PlayingMusic() == 0 && gsm->currentState == GameStateManager::ST_COREGAME) if (Mix_PlayingMusic() == 0 && gsm->currentState == GameStateManager::ST_COREGAME)
{ {
// std::cout << "Play Music Now" << std::endl; // std::cout << "Play Music Now" << std::endl;
// Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1); Mix_PlayMusic(assets->GetMusicTrack("neuwave"), -1);
} }
if (Mix_PlayingMusic() != 0 && gsm->currentState != GameStateManager::ST_COREGAME) if (Mix_PlayingMusic() != 0 && gsm->currentState != GameStateManager::ST_COREGAME)
{ {

View File

@ -11,44 +11,30 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <boost/filesystem.hpp>
Game *game = nullptr; Game *game = nullptr;
int main(int argc, const char * argv[]) int main(int argc, const char * argv[])
{ {
// printf("Program has started, but not initialized yet.\n");
const int FPS = 60; const int FPS = 60;
const int frameDelay = 1000 / FPS; const int frameDelay = 1000 / FPS;
Uint64 frameStart; Uint64 frameStart;
int frameTime; int frameTime;
boost::filesystem::path p{argv[0]};
p = absolute(p).parent_path();
// std::cout << "boost path: " << p << std::endl;
// ============================= // =============================
// Load cJSON config.json file // Load cJSON config.json file
// ============================= // =============================
// Starting with Error Checking
std::string configPath = "src/config/config.json"; std::string configPath = "src/config/config.json";
std::string bps = p.string(); std::string sdlBasePath = SDL_GetBasePath();
size_t charPos = bps.find("build"); size_t charPosSdl = sdlBasePath.find("build");
bps.erase(charPos,bps.length()); sdlBasePath.erase(charPosSdl,sdlBasePath.length());
// std::cout << "Trimmed Boost Path: " << bps << std::endl; std::string configurationPath = sdlBasePath + configPath;
std::string configurationPath = bps + configPath;
//std::string configPath = "/Users/ayoungblood/Projects/KaijuSaveEarth/src/config/config.json";
// /Users/ayoungblood/Projects/KaijuSaveEarth
// std::string fullPath = p.c_str() + "/" + configPath;
std::ifstream fin(configurationPath); std::ifstream fin(configurationPath);
// std::cout << "Attempting to load: " << configPath << std::endl;
// std::cout << "Current working Dir: " << std::filesystem::current_path() << std::endl;
if(!fin.is_open()){ if(!fin.is_open()){
std::cerr<<"ERROR: config.json not found or opened"<<std::endl; std::cerr<<"ERROR: config.json not found or opened"<<std::endl;
} else { } else {
printf("config.json loaded successfully.\n");
std::ifstream jsonText(configurationPath); std::ifstream jsonText(configurationPath);
std::ostringstream tmp; std::ostringstream tmp;
tmp << jsonText.rdbuf(); tmp << jsonText.rdbuf();
@ -60,12 +46,7 @@ int main(int argc, const char * argv[])
int windowHeight = cJSON_GetObjectItem(windowSize, "h")->valueint; int windowHeight = cJSON_GetObjectItem(windowSize, "h")->valueint;
int windowFS = cJSON_GetObjectItem(myJSON, "WindowFullScreen")->valueint; int windowFS = cJSON_GetObjectItem(myJSON, "WindowFullScreen")->valueint;
int globalScale = cJSON_GetObjectItem(myJSON, "GlobalScale")->valueint; int globalScale = cJSON_GetObjectItem(myJSON, "GlobalScale")->valueint;
/* int windowWidth = 64;
int windowHeight = 64;
int windowFS = 0;
int globalScale = 10;*/
bool isWindowFS; bool isWindowFS;
//std::string windowName = "KaijuSaveEarth";
if (windowFS==0) if (windowFS==0)
{ {
isWindowFS = false; isWindowFS = false;
@ -75,9 +56,9 @@ int main(int argc, const char * argv[])
} }
windowWidth = windowWidth*globalScale; windowWidth = windowWidth*globalScale;
windowHeight = windowHeight*globalScale; windowHeight = windowHeight*globalScale;
game = new Game(bps); game = new Game(sdlBasePath);
game->init(windowName->valuestring, windowWidth, windowHeight, isWindowFS, globalScale); game->init(windowName->valuestring, windowWidth, windowHeight, isWindowFS, globalScale);
// game->init(windowName.c_str(), windowWidth, windowHeight, isWindowFS, globalScale);
// cJSON memory management // cJSON memory management
cJSON_Delete(myJSON); cJSON_Delete(myJSON);