From bce58db1dfcb08a20d575bface64ea526829eb83 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Thu, 19 Nov 2020 08:51:20 -0500 Subject: [PATCH 01/17] Added baseline skeleton for character loading and move hitboxes --- include/core/move_model.h | 13 +++++++++++-- include/core/player_model.h | 26 ++++++++++++++++++++++++++ include/core/world_model.h | 2 -- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/include/core/move_model.h b/include/core/move_model.h index dffac4c..98bebbe 100644 --- a/include/core/move_model.h +++ b/include/core/move_model.h @@ -6,12 +6,17 @@ #include #include +#include namespace antares { namespace models { -struct HitBox { +struct AttackHitBoxes { + + std::string name; + + std::vector hit_boxes; }; @@ -19,9 +24,13 @@ class Move { public: + //add an interval between attacks think linguini dash attack + std::string move_image_; - HitBox hit_box_; + std::vector attack_intervals_; + + std::vector hit_boxes_; private: diff --git a/include/core/player_model.h b/include/core/player_model.h index 1859a48..bbb8a98 100644 --- a/include/core/player_model.h +++ b/include/core/player_model.h @@ -7,12 +7,38 @@ #include +#include "move_model.h" + namespace antares { namespace models { struct MoveSet { +}; + +struct CharacterData { + + std::string character_name; + + int fall_speed; + int fast_fall_speed; + int run_speed; + int weight; + +}; + +class Player { + +public: + + void InitiateMove(Move& move); + +private: + + int current_lag_; + + CharacterData character_data_; }; diff --git a/include/core/world_model.h b/include/core/world_model.h index 21dcd75..54e2d26 100644 --- a/include/core/world_model.h +++ b/include/core/world_model.h @@ -4,8 +4,6 @@ #pragma once - - #include #include From 59335019289902fbbb90686187ec8d7e19a89ad9 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Sun, 22 Nov 2020 15:54:42 -0500 Subject: [PATCH 02/17] Altered the window length and added some event handlers --- include/visualizer/antares_app.h | 6 ++++-- src/visualizer/antares_app.cc | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/visualizer/antares_app.h b/include/visualizer/antares_app.h index 8309c9d..0d23908 100644 --- a/include/visualizer/antares_app.h +++ b/include/visualizer/antares_app.h @@ -8,6 +8,7 @@ #include #include "core/world_model.h" +#include "world_visualizer.h" namespace antares { @@ -27,12 +28,13 @@ namespace visualizer { void setup() override; void keyDown(ci::app::KeyEvent event) override; - const double kWindowSize = 650; + const double kWindowLength = 600; + const double kWindowHeight = 400; const double kMargin = 100; private: - antares::models::Map map_; + antares::visualizer::CinderMap cinder_map_; static const std::string kMapPath; diff --git a/src/visualizer/antares_app.cc b/src/visualizer/antares_app.cc index 45ec9d2..3fb833d 100644 --- a/src/visualizer/antares_app.cc +++ b/src/visualizer/antares_app.cc @@ -14,26 +14,44 @@ const ci::Color AntaresApp::kTextColor = ci::Color::black(); const ci::Color8u AntaresApp::kBackgroundColor(255, 246, 148); antares::visualizer::AntaresApp::AntaresApp() { - + ci::app::setWindowSize((int) kWindowLength, (int) kWindowHeight); } void antares::visualizer::AntaresApp::draw() { - AppBase::draw(); + cinder_map_.Render(); } void antares::visualizer::AntaresApp::update() { - AppBase::update(); + cinder_map_.UpdateState(); } void antares::visualizer::AntaresApp::setup() { - AppBase::setup(); + cinder_map_.map_model_.GenerateWorld(); } void antares::visualizer::AntaresApp::keyDown(ci::app::KeyEvent event) { AppBase::keyDown(event); switch (event.getCode()) { - case ci::app::KeyEvent::KEY_r: + case ci::app::KeyEvent::KEY_w: + break; + case ci::app::KeyEvent::KEY_a: + break; + case ci::app::KeyEvent::KEY_s: + break; + case ci::app::KeyEvent::KEY_d: + break; + case ci::app::KeyEvent::KEY_SPACE: + break; + case ci::app::KeyEvent::KEY_j: + break; + case ci::app::KeyEvent::KEY_k: + break; + case ci::app::KeyEvent::KEY_l: + break; + case ci::app::KeyEvent::KEY_ESCAPE: + break; + case ci::app::KeyEvent::KEY_RETURN: break; } } From 48e1eaa077bf1a9070d9edbee473efc7a60e0647 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Sun, 22 Nov 2020 15:55:25 -0500 Subject: [PATCH 03/17] Added more skeletons for move model and player model --- include/core/move_model.h | 11 ++++++----- include/core/player_model.h | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/core/move_model.h b/include/core/move_model.h index 98bebbe..3ab4e3c 100644 --- a/include/core/move_model.h +++ b/include/core/move_model.h @@ -24,13 +24,13 @@ class Move { public: - //add an interval between attacks think linguini dash attack - std::string move_image_; - std::vector attack_intervals_; + std::vector move_part_intervals_; - std::vector hit_boxes_; + int start_up_frames_; + int active_frames_; + int end_lag_; private: @@ -41,10 +41,11 @@ class Attack : public Move { public: + std::vector hit_boxes_; + bool is_hurt_box_; float damage_; - float knock_back_; private: diff --git a/include/core/player_model.h b/include/core/player_model.h index bbb8a98..0c273c7 100644 --- a/include/core/player_model.h +++ b/include/core/player_model.h @@ -15,6 +15,19 @@ namespace models { struct MoveSet { + + +}; + +struct SpriteSet { + + std::string idle; + std::string hit; + std::string out; + + std::string jump; + std::string run; + std::string turn; }; struct CharacterData { @@ -26,6 +39,14 @@ struct CharacterData { int run_speed; int weight; + MoveSet move_set; + + SpriteSet character_set; + + std::vector hurt_boxes; + + //add class template to allow for unique interactions for kits, think cloud limit and resource characters + }; class Player { @@ -38,6 +59,10 @@ class Player { int current_lag_; + float current_damage_; + + float damage_dealt_; + CharacterData character_data_; }; From 57b0800dc7a7c167398370c2569b2d04765b9928 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Wed, 25 Nov 2020 01:50:53 -0500 Subject: [PATCH 04/17] Created world visualizer to visualize the world model --- include/visualizer/world_visualizer.h | 43 ++++++++++++++++++++++++++- src/visualizer/world_visualizer.cc | 36 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/include/visualizer/world_visualizer.h b/include/visualizer/world_visualizer.h index 2603c8c..f2cc517 100644 --- a/include/visualizer/world_visualizer.h +++ b/include/visualizer/world_visualizer.h @@ -1,5 +1,46 @@ // // Created by Nathaniel Smith on 11/16/20. // +#pragma once -#pragma once \ No newline at end of file +#include "core/world_model.h" +#include "visualizer_helpers.h" + +namespace antares { + +namespace visualizer { + +class CinderMap { + + +public: + + CinderMap(); + + CinderMap(const models::World &world); + + /** + * Updates the state for of the container model + */ + void UpdateState(); + + /** + * Renders the current state of the model + */ + void Render() const; + + /** + * Resets the state of the model + * Not implemented :( + */ + void Reset(); + + /** container model for the particles */ + + models::World world_model_; + +}; + +} //namespace visualizer + +} //namespace antares \ No newline at end of file diff --git a/src/visualizer/world_visualizer.cc b/src/visualizer/world_visualizer.cc index 8d9e530..a35218d 100644 --- a/src/visualizer/world_visualizer.cc +++ b/src/visualizer/world_visualizer.cc @@ -4,3 +4,39 @@ #include "visualizer/world_visualizer.h" +namespace antares { + +namespace visualizer { + + + + + visualizer::CinderMap::CinderMap() { + + } + + visualizer::CinderMap::CinderMap(const models::World &world) { + + } + + void visualizer::CinderMap::UpdateState() { + world_model_.UpdateState(); + } + + void visualizer::CinderMap::Render() const { + + int color_differentiator = 0; + for (const b2Body* body = world_model_.world_.GetBodyList(); body; body = body->GetNext()) { + DrawPolygon(body, world_model_.kPixelsPerMeterFactor, + ci::Color8u(255 - color_differentiator , color_differentiator, 150)); + color_differentiator = 150; + } + } + + void visualizer::CinderMap::Reset() { + + } + +} //namespace visualizer + +} //namespace antares \ No newline at end of file From ea893acb0c2ad7ffa98f4cc7df19142a37c7ef07 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Wed, 25 Nov 2020 01:51:33 -0500 Subject: [PATCH 05/17] Created a world class to encompass all of the physics body as well as created generate map method --- include/core/world_model.h | 42 +++++++++++++++++++++++---- src/core/world_model.cc | 59 ++++++++++++++++++++++++++++++++------ 2 files changed, 88 insertions(+), 13 deletions(-) diff --git a/include/core/world_model.h b/include/core/world_model.h index 54e2d26..6499251 100644 --- a/include/core/world_model.h +++ b/include/core/world_model.h @@ -9,6 +9,8 @@ #include #include +#include "player_model.h" + namespace antares { namespace models { @@ -25,20 +27,50 @@ namespace models { void DeserializeJson(); + void GenerateMap(b2World &world, float pixel_per_meter_factor); + + private: + + const double kWindowLength = 600; + const double kWindowHeight = 400; + + }; + + + class World { + + + public: + + World(); + + World(Map *map, Player *player); + void GenerateWorld(); - void CreateMap(); + void UpdateState(); + + b2World world_ = b2World(kGravity); + + const float kPixelsPerMeterFactor = 50.0f; - b2Body* ground_body_; + Map *map_; - b2PolygonShape ground_box_; + Player *player_; private: - const b2Vec2 kGravity = b2Vec2(0.0f, -10.0f); + const float kTimeStep = 1.0f / 60.0f; + + const int32 kVelocityIterations = 6; + const int32 kPositionIterations = 2; + + const b2Vec2 kGravity = b2Vec2(0.0f, 30.0f); + + const double kWindowLength = 600; + const double kWindowHeight = 400; - b2World world_ = b2World(kGravity); }; diff --git a/src/core/world_model.cc b/src/core/world_model.cc index 53a35ec..067b11d 100644 --- a/src/core/world_model.cc +++ b/src/core/world_model.cc @@ -21,20 +21,63 @@ void Map::DeserializeJson() { } -void Map::GenerateWorld() { - CreateMap(); -} +void Map::GenerateMap(b2World &world, float pixel_per_meter_factor) { + + float meter_per_pixel_factor = (1.0f / pixel_per_meter_factor); + + //multiply values shown by pixels per meter factor to shrink down + + b2BodyDef bodyDef; + bodyDef.type = b2_dynamicBody; + bodyDef.position.Set(kWindowLength / 2.0f * meter_per_pixel_factor, + kWindowHeight / 2.0f * meter_per_pixel_factor); + b2Body* body = world.CreateBody(&bodyDef); + + b2PolygonShape dynamicBox; + dynamicBox.SetAsBox(10.0f * meter_per_pixel_factor, 10.0f * meter_per_pixel_factor); -void Map::CreateMap() { + b2FixtureDef fixtureDef; + fixtureDef.shape = &dynamicBox; + fixtureDef.density = 1.0f; + fixtureDef.friction = 0.3f; + body->CreateFixture(&fixtureDef); b2BodyDef ground_body_def; - ground_body_def.position.Set(0.0f, -10.0f); - ground_box_.SetAsBox(50.0f, 10.0f); - ground_body_ = world_.CreateBody(&ground_body_def); - ground_body_->CreateFixture(&ground_box_, 0.0f); + ground_body_def.position.Set(kWindowLength / 2.0f * meter_per_pixel_factor, + (kWindowHeight - 10) * meter_per_pixel_factor); + b2PolygonShape ground_box; + ground_box.SetAsBox(50.0f * meter_per_pixel_factor, 10.0f * meter_per_pixel_factor); + b2Body* ground_body = world.CreateBody(&ground_body_def); + ground_body->CreateFixture(&ground_box, 0.0f); + + + +} +World::World() { + + Map *empty_map = new Map(); + Player *empty_player = new Player(); + + map_ = empty_map; + player_ = empty_player; } +World::World(Map *map, Player *player) { + map_ = map; + player_ = player; +} + +void World::UpdateState() { + world_.Step(kTimeStep, kVelocityIterations, kPositionIterations); +} + +void World::GenerateWorld() { + world_.SetGravity(kGravity); + map_->GenerateMap(world_, kPixelsPerMeterFactor); +} + + } //namespace models } //namespace antares From c21763f578bd645e91620d1eb68e59b3f3963d87 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Wed, 25 Nov 2020 01:51:42 -0500 Subject: [PATCH 06/17] Added new cc files --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fc457a..a3659e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,10 @@ include("${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake") list(APPEND CORE_SOURCE_FILES src/core/player_model.cc) list(APPEND CORE_SOURCE_FILES src/core/world_model.cc) -list(APPEND CORE_SOURCE_FILES src/visualizer/antares_app.cc) list(APPEND CORE_SOURCE_FILES src/core/move_model.cc) +list(APPEND CORE_SOURCE_FILES src/visualizer/antares_app.cc) +list(APPEND CORE_SOURCE_FILES src/visualizer/visualizer_helpers.cc) +list(APPEND CORE_SOURCE_FILES src/visualizer/world_visualizer.cc) list(APPEND TEST_FILES tests/antares_tests.cc) From 6abf5824051690cd7ec4e2e6ea0ed856072b9a92 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Wed, 25 Nov 2020 01:52:18 -0500 Subject: [PATCH 07/17] Created method DrawPolygon to draw the bodies of physics --- include/visualizer/visualizer_helpers.h | 19 ++++++++ src/visualizer/visualizer_helpers.cc | 59 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 include/visualizer/visualizer_helpers.h create mode 100644 src/visualizer/visualizer_helpers.cc diff --git a/include/visualizer/visualizer_helpers.h b/include/visualizer/visualizer_helpers.h new file mode 100644 index 0000000..03af7b7 --- /dev/null +++ b/include/visualizer/visualizer_helpers.h @@ -0,0 +1,19 @@ +// +// Created by Nathaniel Smith on 11/21/20. +// + +#pragma once + +#include +#include + +namespace antares { + +namespace visualizer { + + void DrawPolygon(const b2Body *body, float pixels_per_meter_factor, const ci::Color8u& color); + + +} //namespace visualizer + +} //namespace antares \ No newline at end of file diff --git a/src/visualizer/visualizer_helpers.cc b/src/visualizer/visualizer_helpers.cc new file mode 100644 index 0000000..877fa77 --- /dev/null +++ b/src/visualizer/visualizer_helpers.cc @@ -0,0 +1,59 @@ +// +// Created by Nathaniel Smith on 11/21/20. +// + +#include "visualizer/visualizer_helpers.h" +#include +#include +#include +#include "cinder/gl/gl.h" + +//make method that draws a polygon when given a body by iterating through the fixtures and getting the vertices +// of the shapes that the fixture binds to the body and drawing them. + +namespace antares { + +namespace visualizer { + + + //add color value to customize + void DrawPolygon(const b2Body *body, float pixels_per_meter_factor, const ci::Color8u& color) { + + b2Vec2 pos = body->GetPosition(); + std::cout << pos.x << " " << pos.y << std::endl; + for (const b2Fixture* fixture = body->GetFixtureList(); fixture; fixture = fixture->GetNext()) { + + b2Shape::Type shape_type = fixture->GetType(); + + if (shape_type == b2Shape::e_polygon ) { + + b2PolygonShape* polygon = (b2PolygonShape*)fixture->GetShape(); + + ci::PolyLine2f poly_line; + + for (int vertex_index = 0; vertex_index < polygon->GetVertexCount(); vertex_index++) { + + b2Vec2 b2_vertex = polygon->GetVertex(vertex_index); + glm::vec2 glm_vertex; + + glm_vertex.x = (b2_vertex.x + pos.x) * pixels_per_meter_factor; + glm_vertex.y = (b2_vertex.y + pos.y) * pixels_per_meter_factor; + + poly_line.push_back(glm_vertex); + } + + ci::gl::color(color); + + ci::gl::drawSolid(poly_line); + + + } + } + + } + + + +} //namespace visualizer + +} //namespace antares From e37c67d6bf94e187cd96b1f787c04d0fbc953395 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Wed, 25 Nov 2020 01:52:57 -0500 Subject: [PATCH 08/17] Added pixels per meter factor to allow for easier physics conversions --- include/visualizer/antares_app.h | 1 + src/visualizer/antares_app.cc | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/visualizer/antares_app.h b/include/visualizer/antares_app.h index 0d23908..dc7e839 100644 --- a/include/visualizer/antares_app.h +++ b/include/visualizer/antares_app.h @@ -31,6 +31,7 @@ namespace visualizer { const double kWindowLength = 600; const double kWindowHeight = 400; const double kMargin = 100; + const float kPixelsPerMeterFactor = 50.0f; private: diff --git a/src/visualizer/antares_app.cc b/src/visualizer/antares_app.cc index 3fb833d..75f01fb 100644 --- a/src/visualizer/antares_app.cc +++ b/src/visualizer/antares_app.cc @@ -2,6 +2,7 @@ // Created by Nathaniel Smith on 11/12/20. // +#include #include "visualizer/antares_app.h" namespace antares { @@ -18,6 +19,8 @@ antares::visualizer::AntaresApp::AntaresApp() { } void antares::visualizer::AntaresApp::draw() { + ci::gl::clear(kBackgroundColor); + cinder_map_.Render(); } @@ -26,7 +29,7 @@ void antares::visualizer::AntaresApp::update() { } void antares::visualizer::AntaresApp::setup() { - cinder_map_.map_model_.GenerateWorld(); + cinder_map_.world_model_.GenerateWorld(); } void antares::visualizer::AntaresApp::keyDown(ci::app::KeyEvent event) { From 4a939e16a26c252cbaf8e4d78235dc533b60262c Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:27:41 -0500 Subject: [PATCH 09/17] Added structures for moveset decomposition as well as the json loading macros. --- include/core/player_model.h | 139 ++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/include/core/player_model.h b/include/core/player_model.h index 0c273c7..8b1d171 100644 --- a/include/core/player_model.h +++ b/include/core/player_model.h @@ -6,6 +6,7 @@ #include #include +#include #include "move_model.h" @@ -13,14 +14,142 @@ namespace antares { namespace models { +struct AirAttacks { + +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(AirAttacks, neutral_air, forward_air, + back_air, up_air, down_air); + +private: + std::vector neutral_air_input{"j"}; + std::vector forward_air_inputs{"jd", "dj", "ja", "aj"}; + std::vector back_air_inputs{"jd", "dj", "ja", "aj"}; + std::vector up_air_inputs{"jw", "wj"}; + std::vector down_air_inputs{"js", "sj"}; + + Attack neutral_air = Attack(neutral_air_input); + Attack forward_air = Attack(forward_air_inputs); + Attack back_air = Attack(back_air_inputs); + Attack up_air = Attack(up_air_inputs); + Attack down_air = Attack(down_air_inputs); + +}; + +struct Specials { + +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Specials, neutral_special, down_special, + up_special, forward_special); + +private: + std::vector neutral_special_input{"k"}; + std::vector forward_special_inputs{"kd", "dk", "ka", "ak"}; + std::vector down_special_inputs{"ks", "sk"}; + std::vector up_special_inputs{"kw", "wk"}; + + Attack neutral_special = Attack(neutral_special_input); + Attack down_special = Attack(forward_special_inputs); + Attack up_special = Attack(down_special_inputs); + Attack forward_special = Attack(up_special_inputs); + +}; + +struct GroundedNormals { + +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(GroundedNormals, jab, forward_tilt, down_tilt, up_tilt, + forward_strong, down_strong, down_strong, up_strong); + +private: + std::vector jap_input{"j"}; + std::vector forward_tilt_inputs{"jd", "dj", "ja", "aj"}; + std::vector up_tilt_inputs{"jw", "wj"}; + std::vector down_tilt_inputs{"js", "sj"}; + + std::vector forward_strong_inputs{"jd", "dj", "ja", "aj"}; + std::vector up_strong_inputs{"jw", "wj"}; + std::vector down_strong_inputs{"js", "sj"}; + + Attack jab = Attack(jap_input); + Attack forward_tilt = Attack(forward_tilt_inputs); + Attack down_tilt = Attack(up_tilt_inputs); + Attack up_tilt = Attack(down_tilt_inputs); + + Attack forward_strong = Attack(forward_strong_inputs); + Attack down_strong = Attack(up_strong_inputs); + Attack up_strong = Attack(down_strong_inputs); + +}; + +struct Throws { + +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Throws, neutral_throw, forward_throw, + back_throw, down_throw, up_throw); + +private: + std::vector neutral_throw_input{"l"}; + std::vector forward_throw_inputs{"ld", "dl", "la", "al"}; + std::vector back_throw_inputs{"ld", "dl", "la", "al"}; + std::vector up_throw_inputs{"lw", "wl"}; + std::vector down_throw_inputs{"ls", "sl"}; + + Throw neutral_throw = Throw(neutral_throw_input); + Throw forward_throw = Throw(forward_throw_inputs); + Throw back_throw = Throw(back_throw_inputs); + Throw down_throw = Throw(up_throw_inputs); + Throw up_throw = Throw(down_throw_inputs); + +}; + +struct Defense { + +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Defense, shield, roll_left, roll_right, spot_dodge, + air_dodge); + +private: + std::vector shield_input{"shift"}; + std::vector roll_left_inputs{"ashift", "shifta"}; + std::vector roll_right_inputs{"shiftd", "dshift"}; + std::vector spot_dodge_inputs{"shiftw", "wshift", "dshift", "shiftd"}; + std::vector air_dodge_input{"shift"}; + + Shield shield = Shield(shield_input); + + MobilityMove roll_left = MobilityMove(roll_left_inputs); + MobilityMove roll_right = MobilityMove(roll_right_inputs); + MobilityMove spot_dodge = MobilityMove(spot_dodge_inputs); + MobilityMove air_dodge = MobilityMove(air_dodge_input); + +}; + + struct MoveSet { +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(MoveSet, jump, defense); + // , throws, + // grounded_normals, air_attacks, specials + +private: + std::vector jump_input{"shift"}; + MobilityMove jump = MobilityMove(jump_input); + Defense defense; + Throws throws; + GroundedNormals grounded_normals; + AirAttacks air_attacks; + Specials specials; }; struct SpriteSet { +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(SpriteSet, idle, hit, out, jump, run, turn); + +private: std::string idle; std::string hit; std::string out; @@ -32,6 +161,16 @@ struct SpriteSet { struct CharacterData { +public: + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(CharacterData, character_name, fall_speed_multiplier, + fast_fall_speed_multiplier, run_speed, jump_height, + move_set, sprite_set, hurt_boxes_data); + + CharacterData(); + +private: + std::string character_name; int fall_speed; From 206257e171aea421250cce71c8c539b5e9817962 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:29:26 -0500 Subject: [PATCH 10/17] Added extra fields for character data and player modelds as well as created skeletons for generate player and parse input --- include/core/player_model.h | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/include/core/player_model.h b/include/core/player_model.h index 8b1d171..c763c26 100644 --- a/include/core/player_model.h +++ b/include/core/player_model.h @@ -4,7 +4,6 @@ #pragma once #include - #include #include @@ -173,18 +172,18 @@ struct CharacterData { std::string character_name; - int fall_speed; - int fast_fall_speed; - int run_speed; - int weight; + float fall_speed_multiplier; + float fast_fall_speed_multiplier; + float run_speed; + float jump_height; MoveSet move_set; - SpriteSet character_set; + SpriteSet sprite_set; - std::vector hurt_boxes; + std::vector hurt_boxes_data; - //add class template to allow for unique interactions for kits, think cloud limit and resource characters + std::vector hurt_boxes; }; @@ -192,18 +191,40 @@ class Player { public: + Player(); + + void GeneratePlayer(const std::string& json_path); + void InitiateMove(Move& move); + void ParseInput(); + + std::vector input_list_; + std::map input_timers_; + private: + std::string current_sprite_; + + b2Vec2 position_; + int current_lag_; + int lives_left_; + int shield_charge_; + float current_damage_; float damage_dealt_; CharacterData character_data_; + bool is_facing_right_; + bool is_in_air_; + bool is_shielding_; + + + }; } //namespace models From ed29d93a78ea4dea93fdcf7e2ccfbd44ec7782bd Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:30:12 -0500 Subject: [PATCH 11/17] created skeletons for generate player and parse input --- src/core/player_model.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/core/player_model.cc b/src/core/player_model.cc index 344c176..f91941c 100644 --- a/src/core/player_model.cc +++ b/src/core/player_model.cc @@ -2,6 +2,8 @@ // Created by Nathaniel Smith on 11/12/20. // +#include +#include #include "core/player_model.h" @@ -11,6 +13,31 @@ namespace models { //have player model store position and attributes struct moveset struct, and image reference +void Player::ParseInput() { + + +} + +void Player::GeneratePlayer(const std::string& json_path) { + std::ifstream file(json_path); + nlohmann::json json; + if (file.is_open()) { + std::cout << "good"; + } + file >> json; + this->character_data_ = json; + std::cout << "test"; +} + +Player::Player() { + +} + + +CharacterData::CharacterData() { + +} + } //namespace models } //namespace antares \ No newline at end of file From dbee1fceddcdd5280a29c627827fed662ae656df Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:32:23 -0500 Subject: [PATCH 12/17] Split non attack class into three classes, shield, mobility move and throw for more specification on moves. I also created default constructors and added json parsing macros. --- include/core/move_model.h | 88 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/include/core/move_model.h b/include/core/move_model.h index 3ab4e3c..79465c7 100644 --- a/include/core/move_model.h +++ b/include/core/move_model.h @@ -4,6 +4,8 @@ #pragma once +#include + #include #include #include @@ -12,10 +14,27 @@ namespace antares { namespace models { +//I created this to hold the data for circle shapes because I didn't want to altar +//the actual class +struct b2CircleShapeDataHolder { + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(b2CircleShapeDataHolder, m_radius, x, y); + + float m_radius; + float x; + float y; +}; + struct AttackHitBoxes { +public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(AttackHitBoxes, name, hit_boxes_data); + +private: std::string name; + std::vector hit_boxes_data; + std::vector hit_boxes; }; @@ -24,6 +43,10 @@ class Move { public: + Move(std::vector inputs); + + Move(); + std::string move_image_; std::vector move_part_intervals_; @@ -32,6 +55,8 @@ class Move { int active_frames_; int end_lag_; + std::vector possible_inputs_; + private: @@ -41,6 +66,15 @@ class Attack : public Move { public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Attack, move_image_, move_part_intervals_, start_up_frames_, + active_frames_, end_lag_, hit_boxes_, is_hurt_box_, + damage_, knock_back_); + + Attack(std::vector inputs); + + Attack(); + +private: std::vector hit_boxes_; bool is_hurt_box_; @@ -52,15 +86,63 @@ class Attack : public Move { }; - class NonAttack : public Move { +class MobilityMove : public Move { + +public: + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(MobilityMove, move_image_, move_part_intervals_, start_up_frames_, + active_frames_, end_lag_, has_invulnerability_, + x_velocity_change_, y_velocity_change_); + + MobilityMove(std::vector inputs); + + MobilityMove(); + +private: + + bool has_invulnerability_; + + float x_velocity_change_; + + float y_velocity_change_; +}; + + +class Shield : public Move { - public: +public: + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Shield, move_image_, move_part_intervals_, start_up_frames_, + active_frames_, end_lag_, shield_hit_box_data_); + + Shield(std::vector inputs); + + Shield(); + +private: - private: + b2CircleShapeDataHolder shield_hit_box_data_; + + b2CircleShape shield_hit_box_; }; +class Throw : public Move { + +public: + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Throw, move_image_, move_part_intervals_, start_up_frames_, + active_frames_, end_lag_); + + Throw(std::vector inputs); + + Throw(); + +private: + +}; + } //namespace models From 6f790b2cf37c3d8d5a949f060f42e57ca57c8a27 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:32:29 -0500 Subject: [PATCH 13/17] Split non attack class into three classes, shield, mobility move and throw for more specification on moves. I also created default constructors and added json parsing macros. --- src/core/move_model.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/core/move_model.cc b/src/core/move_model.cc index f57180a..9db5a59 100644 --- a/src/core/move_model.cc +++ b/src/core/move_model.cc @@ -4,13 +4,53 @@ #include "core/move_model.h" +#include + namespace antares { namespace models { +Move::Move(std::vector inputs) { + this->possible_inputs_ = std::move(inputs); +} + +Move::Move() { + +} + + +Attack::Attack(std::vector inputs) : Move(inputs){ + this->possible_inputs_ = std::move(inputs); +} + +Attack::Attack() { + +} + +MobilityMove::MobilityMove(std::vector inputs) : Move(inputs){ + this->possible_inputs_ = std::move(inputs); +} + +MobilityMove::MobilityMove() { + +} + +Throw::Throw(std::vector inputs) : Move(inputs) { + +} + +Throw::Throw() { + +} + +Shield::Shield(std::vector inputs) : Move(inputs) { + +} +Shield::Shield() { +} } //namespace models From 9f94e14ab1b709172f3b48872417eb26e867fe22 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 20:33:07 -0500 Subject: [PATCH 14/17] Added first part of the input handlers. --- src/visualizer/antares_app.cc | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/visualizer/antares_app.cc b/src/visualizer/antares_app.cc index 75f01fb..4f5ac83 100644 --- a/src/visualizer/antares_app.cc +++ b/src/visualizer/antares_app.cc @@ -14,6 +14,9 @@ const std::string AntaresApp::kMapPath = ""; const ci::Color AntaresApp::kTextColor = ci::Color::black(); const ci::Color8u AntaresApp::kBackgroundColor(255, 246, 148); +const std::string AntaresApp::kPlayerJsonPath = + "resources/character_json/player.json"; + antares::visualizer::AntaresApp::AntaresApp() { ci::app::setWindowSize((int) kWindowLength, (int) kWindowHeight); } @@ -25,32 +28,79 @@ void antares::visualizer::AntaresApp::draw() { } void antares::visualizer::AntaresApp::update() { + + std::vector input_remove_list_; + for (auto &input : world_model_.player_->input_timers_) { + if (input.second == 0) { + input_remove_list_.push_back(input.first); + } + input.second -= 1; + } + for (std::string input : input_remove_list_) { + world_model_.player_->input_timers_.erase(input); + } + input_remove_list_.clear(); + + + for(auto it = world_model_.player_->input_timers_.cbegin(); it != world_model_.player_->input_timers_.cend(); ++it) + { + std::cout << it->first << " " << it->second << std::endl; + } cinder_map_.UpdateState(); } void antares::visualizer::AntaresApp::setup() { cinder_map_.world_model_.GenerateWorld(); + cinder_map_.world_model_.player_->GeneratePlayer(kPlayerJsonPath); + std::cout << "ok"; } void antares::visualizer::AntaresApp::keyDown(ci::app::KeyEvent event) { AppBase::keyDown(event); + //Repeat inputs are read every 5-6 frames switch (event.getCode()) { + // WASD are directional keys case ci::app::KeyEvent::KEY_w: + world_model_.player_->input_list_.emplace_back("w"); + world_model_.player_->input_timers_["w"] = 5; break; case ci::app::KeyEvent::KEY_a: + world_model_.player_->input_list_.emplace_back("a"); + world_model_.player_->input_timers_["a"] = 5; break; case ci::app::KeyEvent::KEY_s: + world_model_.player_->input_list_.emplace_back("s"); + world_model_.player_->input_timers_["s"] = 5; break; case ci::app::KeyEvent::KEY_d: + world_model_.player_->input_list_.emplace_back("d"); + world_model_.player_->input_timers_["d"] = 5; break; + // Space is jump case ci::app::KeyEvent::KEY_SPACE: + world_model_.player_->input_list_.emplace_back("space"); + world_model_.player_->input_timers_["space"] = 5; break; + // j is normal attacks ie tilts, air attacks and strong attacks. case ci::app::KeyEvent::KEY_j: + world_model_.player_->input_list_.emplace_back("j"); + world_model_.player_->input_timers_["j"] = 5; break; + // k is for specials case ci::app::KeyEvent::KEY_k: + world_model_.player_->input_list_.emplace_back("k"); + world_model_.player_->input_timers_["k"] = 5; break; + // l is for throws case ci::app::KeyEvent::KEY_l: + world_model_.player_->input_list_.emplace_back("l"); + world_model_.player_->input_timers_["l"] = 5; + break; + // : is for shields + case ci::app::KeyEvent::KEY_LSHIFT: + world_model_.player_->input_list_.emplace_back("shift"); + world_model_.player_->input_timers_["shift"] = 5; break; case ci::app::KeyEvent::KEY_ESCAPE: break; From bcd55dc5fd8eef0fb713d1b7a600cd4d70512952 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 23:37:27 -0500 Subject: [PATCH 15/17] Created player base json --- resources/character_json/player.json | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 resources/character_json/player.json diff --git a/resources/character_json/player.json b/resources/character_json/player.json new file mode 100644 index 0000000..c6401bf --- /dev/null +++ b/resources/character_json/player.json @@ -0,0 +1,102 @@ +{ + "character_name": "Bob", + "fall_speed_multiplier": 0.6, + "fast_fall_speed_multiplier": 0.8, + "run_speed": 0.5, + "jump_height": 0.5, + + "move_set": { + "jump": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 10, + "end_lag_": 0, + "has_invulnerability_": false, + "x_velocity_change_": 0.0, + "y_velocity_change_": 0.7 + }, + "defense": { + "roll_left": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 10, + "end_lag_": 4, + "has_invulnerability_": true, + "x_velocity_change_": -0.5, + "y_velocity_change_": 0.0 + }, + "roll_right": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 10, + "end_lag_": 4, + "has_invulnerability_": true, + "x_velocity_change_": 0.5, + "y_velocity_change_": 0.0 + }, + "spot_dodge": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 10, + "end_lag_": 5, + "has_invulnerability_": true, + "x_velocity_change_": 0.0, + "y_velocity_change_": 0.7 + }, + "air_dodge": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 10, + "end_lag_": 4, + "has_invulnerability_": true, + "x_velocity_change_": 0.0, + "y_velocity_change_": 0.0 + }, + "shield": { + "move_image_": "not_here", + "move_part_intervals_": [], + "start_up_frames_": 3, + "active_frames_": 5, + "end_lag_": 3, + "has_invulnerability_": true, + "x_velocity_change_": 0.0, + "y_velocity_change_": 0.0, + "shield_hit_box_data_": { + "m_radius": 0.5, + "x": 0.0, + "y": 0.0 + } + } + } + }, + "sprite_set": { + "idle": "rip", + "hit": "rip", + "out": "rip", + "jump": "rip", + "run": "rip", + "turn": "rip" + }, + "hurt_boxes_data": [ + { + "m_radius": 0.5, + "x": 0.0, + "y": 0.0 + }, + { + "m_radius": 0.5, + "x": 0.0, + "y": 0.5 + }, + { + "m_radius": 0.5, + "x": 0.0, + "y": -0.5 + } + ] +} From 1d84736d6df5e867bce2353696bbf6b45c322c1f Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 23:38:13 -0500 Subject: [PATCH 16/17] Added a player json path and world model reference --- include/visualizer/antares_app.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/visualizer/antares_app.h b/include/visualizer/antares_app.h index dc7e839..ade2ff1 100644 --- a/include/visualizer/antares_app.h +++ b/include/visualizer/antares_app.h @@ -37,11 +37,15 @@ namespace visualizer { antares::visualizer::CinderMap cinder_map_; + antares::models::World world_model_; + static const std::string kMapPath; static const ci::Color kTextColor; static const ci::Color8u kBackgroundColor; + + static const std::string kPlayerJsonPath; }; } //namespace visualizer From e72f40491a2547a31a8e78435a28bdc2afdc845c Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Tue, 1 Dec 2020 23:38:43 -0500 Subject: [PATCH 17/17] Removed throws because I don't have time to implement --- include/core/move_model.h | 4 +++- include/core/player_model.h | 27 +++------------------------ src/core/player_model.cc | 5 +++++ src/visualizer/visualizer_helpers.cc | 1 - 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/core/move_model.h b/include/core/move_model.h index 79465c7..9bcf949 100644 --- a/include/core/move_model.h +++ b/include/core/move_model.h @@ -67,7 +67,7 @@ class Attack : public Move { public: NLOHMANN_DEFINE_TYPE_INTRUSIVE(Attack, move_image_, move_part_intervals_, start_up_frames_, - active_frames_, end_lag_, hit_boxes_, is_hurt_box_, + active_frames_, end_lag_, hit_boxes_, is_hurt_box_, is_projectile_, damage_, knock_back_); Attack(std::vector inputs); @@ -79,6 +79,8 @@ class Attack : public Move { bool is_hurt_box_; + bool is_projectile_; + float damage_; float knock_back_; diff --git a/include/core/player_model.h b/include/core/player_model.h index c763c26..a58c001 100644 --- a/include/core/player_model.h +++ b/include/core/player_model.h @@ -80,27 +80,6 @@ struct GroundedNormals { }; -struct Throws { - -public: - NLOHMANN_DEFINE_TYPE_INTRUSIVE(Throws, neutral_throw, forward_throw, - back_throw, down_throw, up_throw); - -private: - std::vector neutral_throw_input{"l"}; - std::vector forward_throw_inputs{"ld", "dl", "la", "al"}; - std::vector back_throw_inputs{"ld", "dl", "la", "al"}; - std::vector up_throw_inputs{"lw", "wl"}; - std::vector down_throw_inputs{"ls", "sl"}; - - Throw neutral_throw = Throw(neutral_throw_input); - Throw forward_throw = Throw(forward_throw_inputs); - Throw back_throw = Throw(back_throw_inputs); - Throw down_throw = Throw(up_throw_inputs); - Throw up_throw = Throw(down_throw_inputs); - -}; - struct Defense { public: @@ -128,15 +107,13 @@ struct MoveSet { public: NLOHMANN_DEFINE_TYPE_INTRUSIVE(MoveSet, jump, defense); - // , throws, // grounded_normals, air_attacks, specials private: - std::vector jump_input{"shift"}; + std::vector jump_input{"space"}; MobilityMove jump = MobilityMove(jump_input); Defense defense; - Throws throws; GroundedNormals grounded_normals; AirAttacks air_attacks; Specials specials; @@ -170,6 +147,8 @@ struct CharacterData { private: + float health_; + std::string character_name; float fall_speed_multiplier; diff --git a/src/core/player_model.cc b/src/core/player_model.cc index f91941c..2f51de2 100644 --- a/src/core/player_model.cc +++ b/src/core/player_model.cc @@ -26,6 +26,7 @@ void Player::GeneratePlayer(const std::string& json_path) { } file >> json; this->character_data_ = json; + std::cout << "test"; } @@ -33,6 +34,10 @@ Player::Player() { } +void Player::InitiateMove(Move &move) { + +} + CharacterData::CharacterData() { diff --git a/src/visualizer/visualizer_helpers.cc b/src/visualizer/visualizer_helpers.cc index 877fa77..3a54ff0 100644 --- a/src/visualizer/visualizer_helpers.cc +++ b/src/visualizer/visualizer_helpers.cc @@ -20,7 +20,6 @@ namespace visualizer { void DrawPolygon(const b2Body *body, float pixels_per_meter_factor, const ci::Color8u& color) { b2Vec2 pos = body->GetPosition(); - std::cout << pos.x << " " << pos.y << std::endl; for (const b2Fixture* fixture = body->GetFixtureList(); fixture; fixture = fixture->GetNext()) { b2Shape::Type shape_type = fixture->GetType();