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

Week2 #2

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
106 changes: 100 additions & 6 deletions include/core/move_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,58 @@

#pragma once

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes on commit messages:

  1. Don't repeat them.
  2. Don't write them in first person (don't say "I also...").
  3. If you want to mention two things you did in one commit message (which should ideally only be when the two things were somewhat minor/did not involve a lot of code), you can just separate them with a semi-colon; using "as well as" is fine, but it might cause trouble later when you're trying to keep your message under 50 characters.


#include <nlohmann/json.hpp>

#include <Box2D/Box2D.h>
#include <string>
#include <vector>

namespace antares {

namespace models {

struct HitBox {
//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<b2CircleShapeDataHolder> hit_boxes_data;

std::vector<b2CircleShape> hit_boxes;

};

class Move {

public:

Move(std::vector<std::string> inputs);

Move();

std::string move_image_;

HitBox hit_box_;
std::vector<int> move_part_intervals_;

int start_up_frames_;
int active_frames_;
int end_lag_;

std::vector<std::string> possible_inputs_;

private:

Expand All @@ -32,25 +66,85 @@ 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_, is_projectile_,
damage_, knock_back_);

Attack(std::vector<std::string> inputs);

Attack();

private:
std::vector<AttackHitBoxes> hit_boxes_;

bool is_hurt_box_;

float damage_;
bool is_projectile_;

float damage_;
float knock_back_;

private:

};

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<std::string> inputs);

MobilityMove();

private:

bool has_invulnerability_;

float x_velocity_change_;

float y_velocity_change_;
};


class Shield : public Move {

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<std::string> inputs);

public:
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<std::string> inputs);

Throw();

private:

};


} //namespace models

Expand Down
192 changes: 191 additions & 1 deletion include/core/player_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,205 @@
#pragma once

#include <nlohmann/json.hpp>

#include <Box2D/Box2D.h>
#include <cinder/app/KeyEvent.h>

#include "move_model.h"

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<std::string> neutral_air_input{"j"};
std::vector<std::string> forward_air_inputs{"jd", "dj", "ja", "aj"};
std::vector<std::string> back_air_inputs{"jd", "dj", "ja", "aj"};
std::vector<std::string> up_air_inputs{"jw", "wj"};
std::vector<std::string> 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<std::string> neutral_special_input{"k"};
std::vector<std::string> forward_special_inputs{"kd", "dk", "ka", "ak"};
std::vector<std::string> down_special_inputs{"ks", "sk"};
std::vector<std::string> 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<std::string> jap_input{"j"};
std::vector<std::string> forward_tilt_inputs{"jd", "dj", "ja", "aj"};
std::vector<std::string> up_tilt_inputs{"jw", "wj"};
std::vector<std::string> down_tilt_inputs{"js", "sj"};

std::vector<std::string> forward_strong_inputs{"jd", "dj", "ja", "aj"};
std::vector<std::string> up_strong_inputs{"jw", "wj"};
std::vector<std::string> 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 Defense {

public:
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Defense, shield, roll_left, roll_right, spot_dodge,
air_dodge);

private:
std::vector<std::string> shield_input{"shift"};
std::vector<std::string> roll_left_inputs{"ashift", "shifta"};
std::vector<std::string> roll_right_inputs{"shiftd", "dshift"};
std::vector<std::string> spot_dodge_inputs{"shiftw", "wshift", "dshift", "shiftd"};
std::vector<std::string> 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);
// grounded_normals, air_attacks, specials

private:
std::vector<std::string> jump_input{"space"};

MobilityMove jump = MobilityMove(jump_input);
Defense defense;
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;

std::string jump;
std::string run;
std::string turn;
};

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:

float health_;

std::string character_name;

float fall_speed_multiplier;
float fast_fall_speed_multiplier;
float run_speed;
float jump_height;

MoveSet move_set;

SpriteSet sprite_set;

std::vector<b2CircleShapeDataHolder> hurt_boxes_data;

std::vector<b2CircleShape> hurt_boxes;

};

class Player {

public:

Player();

void GeneratePlayer(const std::string& json_path);

void InitiateMove(Move& move);

void ParseInput();

std::vector<std::string> input_list_;
std::map<std::string, int> 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_;



};

Expand Down
Loading