Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dogotrigger/main #56

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ Resources/*
Content*
!Content/Custom

CMakeCache.txt
CMakeCache.txt

# clion
cmake-build-*
.idea
Empty file added .gitmodules
Empty file.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/OpenGD.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ if (NOT _AX_USE_PREBUILT)
add_subdirectory(${_AX_ROOT}/core ${ENGINE_BINARY_PATH}/axmol/core)
endif()


# The common cross-platforms source files and header files
file(GLOB_RECURSE GAME_HEADER
Source/*.h Source/*.hpp
Expand Down Expand Up @@ -152,6 +153,7 @@ elseif(WINDOWS)
ax_setup_winrt_sources()
endif()
list(APPEND GAME_SOURCE ${common_content_files})
add_compile_options(/arch:AVX2 /d2archSSE42 /d2archAVX)
elseif(APPLE)
if(IOS)
list(APPEND GAME_HEADER
Expand Down
32 changes: 0 additions & 32 deletions CMakePresets.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Required:

Clone axmol, run setup.ps1 and restart cmd for command line variables to update
```
git clone --branch release https://github.com/axmolengine/axmol
git clone https://github.com/axmolengine/axmol
cd axmol
./setup.ps1
```
Expand Down
10 changes: 10 additions & 0 deletions Source/BaseGameLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ void BaseGameLayer::initBatchNodes()
_main2BatchNodeTexture = _main2BatchNode->getTexture()->getPath();
}

bool BaseGameLayer::isObjectBlending(GameObject* obj)
{
return _colorChannels.contains(obj->_mainColorChannel) && _colorChannels[obj->_mainColorChannel]._blending &&
_colorChannels.contains(obj->_secColorChannel) && _colorChannels[obj->_secColorChannel]._blending ||
!_colorChannels.contains(obj->_mainColorChannel) && _colorChannels.contains(obj->_secColorChannel) &&
_colorChannels[obj->_secColorChannel]._blending ||
!_colorChannels.contains(obj->_secColorChannel) && _colorChannels.contains(obj->_mainColorChannel) &&
_colorChannels[obj->_mainColorChannel]._blending;
}

void BaseGameLayer::createObjectsFromSetup(std::string_view uncompressedLevelString)
{
//TODO: this function should only recieve vector of game object strings
Expand Down
34 changes: 19 additions & 15 deletions Source/BaseGameLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,33 @@ class BaseGameLayer : public ax::Layer {

public:

GJGameLevel* _level;
std::vector<GameObject*> _allObjects;
std::vector<GameObject*> _allObjects;
std::vector<std::vector<GameObject*>> _sectionObjects;
std::unordered_map<int, SpriteColor, my_string_hash> _colorChannels, _originalColors;
std::unordered_map<int, GroupProperties, my_string_hash> _groups;

PlayerObject* _player1, _player2;
PlayerObject* _player1, *_player2;

protected:
void loadLevel();
void initBatchNodes();
void createObjectsFromSetup(std::string_view uncompressedLevelString);
void setupLevel(std::string_view uncompressedLevelString);
void addObject(GameObject* obj);
void loadLevelData(std::string_view data);
void fillColorChannel(std::span<std::string_view> colorString, int id);
void processMoveActionsStep(float dt);
void processMoveActions(float dt);
ax::Color3B getLightBG(ax::Color3B bg, ax::Color3B p1);
virtual void loadLevel();
virtual void initBatchNodes();
virtual void createObjectsFromSetup(std::string_view uncompressedLevelString);
virtual void setupLevel(std::string_view uncompressedLevelString);
virtual void addObject(GameObject* obj);
virtual void loadLevelData(std::string_view data);
virtual void fillColorChannel(std::span<std::string_view> colorString, int id);
public:
static BaseGameLayer* create(GJGameLevel*);
bool init(GJGameLevel*);
AX_SYNTHESIZE(GJGameLevel*, _level, Level);

static BaseGameLayer* create(GJGameLevel*);
virtual bool init(GJGameLevel*);
static int sectionForPos(float x);
static BaseGameLayer* getInstance() {return _instance;}
virtual bool isObjectBlending(GameObject* obj);

void processMoveActions(float dt);
void runMoveCommand(float duration, ax::Point offsetPos, int easeType, float easeAmt, int groupID);
void processMoveActionsStep(float dt);

ax::Color3B getLightBG(ax::Color3B bg, ax::Color3B p1);
};
4 changes: 2 additions & 2 deletions Source/CircleWave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool CircleWave::init(float duration, Color4B color, float radiusMin, float radi
auto radAction = ActionTween::create(duration, "radius", radiusMin, radiusMax);
auto opacityAction = ActionTween::create(duration / 2, "opacity", 0.0, 1.0);
auto opacityAction2 = ActionTween::create(duration / 2, "opacity", 1.0, 0.0);
auto seq = Sequence::create(opacityAction, opacityAction2, CallFunc::create([=]() {
auto seq = Sequence::create(opacityAction, opacityAction2, CallFunc::create([&]() {
this->removeFromParent();
}), nullptr);
auto action = Spawn::create(radAction, seq, nullptr);
Expand All @@ -77,7 +77,7 @@ bool CircleWave::init(float duration, Color4B color, float radiusMin, float radi
auto radAction = EaseOut::create(ActionTween::create(duration, "radius", radiusMin, radiusMax), 2.0f);
auto opacityAction = EaseOut::create(ActionTween::create(duration / 2, "opacity", this->_color.a, 0.0), 2.0f);
auto spawn = Spawn::create(radAction, opacityAction, nullptr);
auto action = Sequence::create(spawn, CallFunc::create([=](){ this->removeFromParent();}), nullptr);
auto action = Sequence::create(spawn, CallFunc::create([&](){ this->removeFromParent();}), nullptr);
Director::getInstance()->getActionManager()->addAction(action, this, false);
}

Expand Down
18 changes: 12 additions & 6 deletions Source/CocosExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ void highlight(ax::Node* node, bool selected)
{
auto camera = Camera::getDefaultCamera();

const ax::Mat4& viewMatrix = camera->getViewMatrix();
const ax::Point offset(viewMatrix.m[3], viewMatrix.m[7]);
bb_min -= offset;
bb_max -= offset;
if (camera) {
const ax::Mat4& viewMatrix = camera->getViewMatrix();
const ax::Point offset(viewMatrix.m[3], viewMatrix.m[7]);
bb_min -= offset;
bb_max -= offset;
}

camera_parent = camera_parent->getParent();
}
Expand Down Expand Up @@ -255,8 +257,12 @@ void drawProperties()
groupText += fmt::format("{} ", i);
opacityMultiplier *= BaseGameLayer::getInstance()->_groups[i]._alpha;
}
ImGui::Text(fmt::format("Groups: {}", groupText).c_str());
ImGui::Text(fmt::format("Opacity Multiplier (groups): {}", opacityMultiplier).c_str());

std::string groups_string = fmt::format("Groups: {}", groupText);
std::string opacitymul_string = fmt::format("Opacity Multiplier (groups): {}", opacityMultiplier);

ImGui::Text("%s", groups_string.c_str());
ImGui::Text("%s", opacitymul_string.c_str());

float hsv1[3], hsv2[3];
bool check1, check2, check3, check4;
Expand Down
15 changes: 13 additions & 2 deletions Source/CreatorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,19 @@ bool CreatorLayer::init()
{
GameToolbox::log("tag: {}", btn->getTag());
switch (btn->getTag())
{
case 0:
{
case 0: {
auto level = GJGameLevel::createWithMinimumData("Unnamed 0", "You", 33);

auto editor = LevelEditorLayer::scene(level);

// addChild(editor, 1000);

Director::getInstance()->replaceScene(ax::TransitionFade::create(0.5f, editor));

return;
}
case 1:
{
#ifdef _WIN32
auto fu = ax::FileUtils::getInstance();
Expand Down
2 changes: 1 addition & 1 deletion Source/EffectGameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void EffectGameObject::triggerActivated(float)

auto pl = PlayLayer::getInstance();

this->_wasTriggerActivated = true;
// this->_wasTriggerActivated = true;

auto id = getID();

Expand Down
6 changes: 3 additions & 3 deletions Source/EffectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
class EffectManager : public ax::Node
{
public:
std::vector<GroupCommandObject*> _groupActions;
std::vector<GroupCommandObject*> _completedMoveActions;
std::deque<GroupCommandObject*> _tempCompletedActions;
std::vector<GroupCommandObject*> _groupActions = {};
std::vector<GroupCommandObject*> _completedMoveActions = {};
std::deque<GroupCommandObject*> _tempCompletedActions = {};
std::unordered_map<int, CCMoveNode*, my_string_hash> _activeMoveActions;

float _xAccel, _yAccel;
Expand Down
26 changes: 24 additions & 2 deletions Source/EndLevelLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ EndLevelLayer *EndLevelLayer::create(PlayLayer *pl)
pRet->_createdWithoutPlaylayer = false;
pRet->_everyplay_included = pl->_everyplay_recorded;
pRet->_stars = level->_stars;
pRet->_testmode = pl->_testMode;
} else {
pRet->_createdWithoutPlaylayer = true;
}
Expand Down Expand Up @@ -121,7 +122,7 @@ bool EndLevelLayer::init(PlayLayer *pl)
pl->m_pHudLayer->addChild(_statsLayer);
const auto& wsize = ax::Director::getInstance()->getWinSize();

// image
// level complete image

auto sprite = ax::Sprite::createWithSpriteFrameName("GJ_levelComplete_001.png");
sprite->setScale(0.8f);
Expand All @@ -148,7 +149,7 @@ bool EndLevelLayer::init(PlayLayer *pl)

// time
std::chrono::seconds duration{_time};
std::string timeText = fmt::format("Time: {:%H:%M:%S}", duration);
std::string timeText = fmt::format("Time: {:%M:%S}", duration);
auto time = ax::Label::createWithBMFont(goldFontStr, timeText);
time->setPositionY(wsize.height / 5 - 75 - 10);
time->setScale(0.8f);
Expand All @@ -157,6 +158,11 @@ bool EndLevelLayer::init(PlayLayer *pl)
// random string

std::string_view randomText = EndLevelLayer::getRandomEndingString();

if (_testmode) {
randomText = "Level Verified!";
}

auto randomt = ax::Label::createWithBMFont(bigFontStr, randomText);
randomt->setPositionY(wsize.height / 5 - 120 - 10);
if (randomText.length() > 13)
Expand Down Expand Up @@ -211,6 +217,8 @@ bool EndLevelLayer::init(PlayLayer *pl)
// stars

scheduleOnce([&](float delta) {
if (_stars < 1) return;

auto starNode = ax::Node::create();
auto bigstar = ax::Sprite::createWithSpriteFrameName("GJ_bigStar_001.png");
std::string bigFontStr = GameToolbox::getTextureString("bigFont.fnt");
Expand Down Expand Up @@ -247,6 +255,20 @@ bool EndLevelLayer::init(PlayLayer *pl)
ax::AudioEngine::play2d("highscoreGet02.ogg");
}, 1.2f, "starSound");

if (!_createdWithoutPlaylayer)
{
auto level = _playlayer->getLevel();
auto stars = level->_stars;
if (stars > 0) {
auto star_sprite = ax::Sprite::createWithSpriteFrameName("GJ_bigStar_001.png");
std::string stars_got = "+" + std::to_string(stars);

auto menu_layer = ax::Layer::create();
menu_layer->addChild(star_sprite);

}
}

// everyplay if possible

if (_everyplay_included)
Expand Down
1 change: 1 addition & 0 deletions Source/EndLevelLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class EndLevelLayer : public ax::Layer {
int _time;
int _stars;
bool _everyplay_included;
bool _testmode;
public:
static EndLevelLayer* create(PlayLayer *pl);
static EndLevelLayer* create(int attempts, int jumps, int time, bool everyplayIncluded, int stars);
Expand Down
10 changes: 9 additions & 1 deletion Source/GJGameLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <ZipUtils.h>


//the only thing we actually want as normal string is the class members
static inline std::string _toString(std::string_view s) {
return {s.begin(), s.end()};
Expand Down Expand Up @@ -132,6 +131,15 @@ std::string GJGameLevel::decompressLvlStr(std::string compressedLvlStr)
return levelString;
}

std::string GJGameLevel::compressLvlStr(std::string decompressedLvlStr, int gdLevelID) {
// ax::ZipUtils::
// std::string compressed_data = gzip::compress(decompressedLvlStr.c_str(), decompressedLvlStr.size());

// return compressed_data;

return decompressedLvlStr;
}

std::string GJGameLevel::getDifficultySprite(GJGameLevel* level, DifficultyType type)
{
if (level->_auto)
Expand Down
1 change: 1 addition & 0 deletions Source/GJGameLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class GJGameLevel {

static std::string getLevelStrFromID(int gdLevelID);
static std::string decompressLvlStr(std::string compressedLvlStr);
static std::string compressLvlStr(std::string decompressedLvlStr, int gdLevelID);

static std::string getDifficultySprite(GJGameLevel* level, DifficultyType type = kLevelCell);
};
Loading