-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* building with emscripten and interfacing like python * more wrapper code * more wrapper code * more progress on observers * converting into react project so its easier to use with components etc * the pain of trying to make this a react module * all working asynchronously with react * fixing some refactor bits * adding phaser for rendering * more work on renderer, using phaser * renderers working for sprite and block2D * correct tiling for sprite2D tilsets * more work on level-builder * more progress on editor tool, can now edit and save in window and hot-swap gdy * actions now automatically mapped * calculating action mappings to keyboard mapping * more mechanics and fixings for making crafter work * fixing some issues with behaviours/probabilities overriding others * working on tests for improved behaviours * fixing python tests for updatd behaviours * very close to having working crafter envs * much more updates for GriddlyJS and fixes for grafter envs * some more fixes to allow arrows to be launched in the right directions with the right images, also bug fix for collision detections
- Loading branch information
Showing
79 changed files
with
32,166 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "Jiddly.hpp" | ||
|
||
#include <spdlog/spdlog.h> | ||
|
||
#include <iostream> | ||
|
||
#include "../../src/Griddly/Core/GDY/GDYFactory.hpp" | ||
#include "../../src/Griddly/Core/GDY/Objects/ObjectGenerator.hpp" | ||
#include "../../src/Griddly/Core/GDY/TerminationGenerator.hpp" | ||
|
||
Jiddly::Jiddly() { | ||
#ifndef NDEBUG | ||
spdlog::set_level(spdlog::level::debug); | ||
#else | ||
spdlog::set_level(spdlog::level::info); | ||
#endif | ||
|
||
spdlog::debug("Jiddly module loaded!"); | ||
} | ||
|
||
std::shared_ptr<JiddlyGDYWrapper> Jiddly::loadString(std::string levelString) { | ||
auto objectGenerator = std::make_shared<griddly::ObjectGenerator>(griddly::ObjectGenerator()); | ||
auto terminationGenerator = std::make_shared<griddly::TerminationGenerator>(griddly::TerminationGenerator()); | ||
auto gdyFactory = std::make_shared<griddly::GDYFactory>(griddly::GDYFactory(objectGenerator, terminationGenerator)); | ||
std::istringstream s(levelString); | ||
gdyFactory->parseFromStream(s); | ||
return std::make_shared<JiddlyGDYWrapper>(JiddlyGDYWrapper(gdyFactory)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include <emscripten/bind.h> | ||
#include <emscripten/html5.h> | ||
|
||
#include "../../src/Griddly/Core/Grid.hpp" | ||
#include "JiddlyGDYWrapper.hpp" | ||
|
||
namespace e = emscripten; | ||
|
||
class Jiddly { | ||
public: | ||
Jiddly(); | ||
std::shared_ptr<JiddlyGDYWrapper> loadString(std::string levelString); | ||
}; | ||
|
||
template <typename K, typename V> | ||
e::class_<std::unordered_map<K, V>> register_unordered_map(const char* name) { | ||
typedef std::unordered_map<K, V> MapType; | ||
|
||
size_t (MapType::*size)() const = &MapType::size; | ||
return e::class_<MapType>(name) | ||
.template constructor<>() | ||
.function("size", size) | ||
.function("get", e::internal::MapAccess<MapType>::get) | ||
.function("set", e::internal::MapAccess<MapType>::set) | ||
.function("keys", e::internal::MapAccess<MapType>::keys); | ||
} | ||
|
||
EMSCRIPTEN_BINDINGS(Jiddly) { | ||
// Classes | ||
e::class_<Jiddly>("Jiddly") | ||
.constructor() | ||
.function("loadString", &Jiddly::loadString); | ||
|
||
e::class_<JiddlyGDYWrapper>("JiddlyGDYWrapper") | ||
.smart_ptr<std::shared_ptr<JiddlyGDYWrapper>>("JiddlyGDYWrapper") | ||
.function("setMaxSteps", &JiddlyGDYWrapper::setMaxSteps) | ||
.function("getPlayerCount", &JiddlyGDYWrapper::getPlayerCount) | ||
.function("getAvatarObject", &JiddlyGDYWrapper::getAvatarObject) | ||
.function("getExternalActionNames", &JiddlyGDYWrapper::getExternalActionNames) | ||
.function("getLevelCount", &JiddlyGDYWrapper::getLevelCount) | ||
.function("getObserverType", &JiddlyGDYWrapper::getObserverType) | ||
.function("getActionInputMappings", &JiddlyGDYWrapper::getActionInputMappings) | ||
.function("createGame", &JiddlyGDYWrapper::createGame); | ||
|
||
e::class_<JiddlyGameWrapper>("JiddlyGameWrapper") | ||
.smart_ptr<std::shared_ptr<JiddlyGameWrapper>>("JiddlyGameWrapper") | ||
.function("getActionTypeId", &JiddlyGameWrapper::getActionTypeId) | ||
.function("init", &JiddlyGameWrapper::init) | ||
.function("release", &JiddlyGameWrapper::release) | ||
.function("registerPlayer", &JiddlyGameWrapper::registerPlayer) | ||
.function("loadLevel", &JiddlyGameWrapper::loadLevel) | ||
.function("loadLevelString", &JiddlyGameWrapper::loadLevelString) | ||
.function("reset", &JiddlyGameWrapper::reset) | ||
.function("getGlobalObservationDescription", &JiddlyGameWrapper::getGlobalObservationDescription) | ||
.function("observe", &JiddlyGameWrapper::observe) | ||
.function("stepParallel", &JiddlyGameWrapper::stepParallel) | ||
.function("getWidth", &JiddlyGameWrapper::getWidth) | ||
.function("getHeight", &JiddlyGameWrapper::getHeight) | ||
.function("getState", &JiddlyGameWrapper::getState) | ||
.function("getGlobalVariableNames", &JiddlyGameWrapper::getGlobalVariableNames) | ||
.function("getObjectVariableMap", &JiddlyGameWrapper::getObjectVariableMap) | ||
.function("getGlobalVariables", &JiddlyGameWrapper::getGlobalVariables) | ||
.function("getObjectNames", &JiddlyGameWrapper::getObjectNames) | ||
.function("getObjectVariableNames", &JiddlyGameWrapper::getObjectVariableNames) | ||
.function("seedRandomGenerator", &JiddlyGameWrapper::seedRandomGenerator); | ||
|
||
e::class_<JiddlyPlayerWrapper>("JiddlyPlayerWrapper") | ||
.smart_ptr<std::shared_ptr<JiddlyPlayerWrapper>>("JiddlyPlayerWrapper"); | ||
|
||
// Types | ||
e::value_object<glm::ivec2>("glm::ivec2") | ||
.field("x", &glm::ivec2::x) | ||
.field("y", &glm::ivec2::y); | ||
|
||
e::value_object<glm::vec2>("glm::vec2") | ||
.field("x", &glm::vec2::x) | ||
.field("y", &glm::vec2::y); | ||
|
||
e::register_vector<int32_t>("IntVector"); | ||
e::register_vector<uint32_t>("UInt32Vector"); | ||
e::register_vector<uint8_t>("UInt8Vector"); | ||
e::register_vector<std::string>("StringVector"); | ||
|
||
e::enum_<griddly::ObserverType>("ObserverType") | ||
.value("VECTOR", griddly::ObserverType::VECTOR) | ||
.value("ASCII", griddly::ObserverType::ASCII) | ||
.value("ENTITY", griddly::ObserverType::ENTITY) | ||
.value("NONE", griddly::ObserverType::NONE); | ||
} |
Oops, something went wrong.