├── .gitignore ├── FightingGameProject.sln ├── FightingGameProject ├── AABB.h ├── AnimationController.cpp ├── AnimationController.h ├── AnimationRenderer.h ├── AnimationSpecs.h ├── AnimationStatus.h ├── BodyToBodyCollisions.h ├── BodyType.h ├── BottomSegments.h ├── BoxCollider.cpp ├── BoxCollider.h ├── BoxColliderData │ └── Fighter_0 │ │ ├── fighter_0_crouch.collider │ │ ├── fighter_0_hadouken_fire.collider │ │ ├── fighter_0_hadouken_recover.collider │ │ ├── fighter_0_hitreaction_side.collider │ │ ├── fighter_0_hitreaction_up.collider │ │ ├── fighter_0_idle.collider │ │ ├── fighter_0_jab.collider │ │ ├── fighter_0_jump_fall.collider │ │ ├── fighter_0_jump_prep_back.collider │ │ ├── fighter_0_jump_prep_forward.collider │ │ ├── fighter_0_jump_prep_vertical.collider │ │ ├── fighter_0_jump_up_back.collider │ │ ├── fighter_0_jump_up_forward.collider │ │ ├── fighter_0_jump_up_vertical.collider │ │ ├── fighter_0_jump_weakpunch.collider │ │ ├── fighter_0_uppercut.collider │ │ ├── fighter_0_walk.collider │ │ └── fighter_0_walkback.collider ├── BoxRenderer.h ├── BufferChecker.h ├── CMakeLists.txt ├── Camera.cpp ├── Camera.h ├── CheckCollisionMessage.h ├── ColliderLoader.h ├── CollidingSideType.h ├── CollisionData.h ├── CollisionStay.h ├── ConvertedInputType.h ├── CreateProjectileMessage.h ├── DamageData.h ├── DevSettings.cpp ├── DevSettings.h ├── DiagonalOverlap.cpp ├── DiagonalOverlap.h ├── Directions.h ├── DummySelector.h ├── FightScene.cpp ├── FightScene.h ├── FighterDirection.h ├── FighterGroundToGroundCollision.h ├── FighterJump.h ├── Fighter_0_Crouch.h ├── Fighter_0_Hadouken_Fire.h ├── Fighter_0_Hadouken_Recover.h ├── Fighter_0_HitReaction_Side.h ├── Fighter_0_HitReaction_Up.h ├── Fighter_0_Idle.h ├── Fighter_0_Jab.h ├── Fighter_0_Jump_Fall.h ├── Fighter_0_Jump_Prep_Back.h ├── Fighter_0_Jump_Prep_Forward.h ├── Fighter_0_Jump_Prep_Vertical.h ├── Fighter_0_Jump_Up_Back.h ├── Fighter_0_Jump_Up_Forward.h ├── Fighter_0_Jump_Up_Vertical.h ├── Fighter_0_Jump_WeakPunch.h ├── Fighter_0_Uppercut.h ├── Fighter_0_WalkBack.h ├── Fighter_0_WalkForward.h ├── Fighter_1_Idle.h ├── FightersFixedUpdater.h ├── FightersGroup.cpp ├── FightersGroup.h ├── FightersHitStopMessage.cpp ├── FightersHitStopMessage.h ├── FightingGameProject.vcxproj ├── FightingGameProject.vcxproj.filters ├── Game.h ├── GameObj.cpp ├── GameObj.h ├── GameSettings.cpp ├── GameSettings.h ├── Hadouken.h ├── Hadouken_MoveForward.h ├── HitBoxEditorScene.h ├── HitStopMessage.h ├── IGroupComponent.h ├── ImpactEffect_Hit_0.h ├── ImpactEffectsGroup.cpp ├── ImpactEffectsGroup.h ├── Input.h ├── InputBuffer.cpp ├── InputBuffer.h ├── InputBufferRenderer.h ├── InputData.cpp ├── InputData.h ├── InputElement.h ├── InputType.h ├── JumpCalculator.cpp ├── JumpCalculator.h ├── JumpSpecs.h ├── Key.h ├── KeyType.h ├── MeleeCollisionResult.h ├── MeleeReaction.h ├── Normalize.h ├── ObjBase.h ├── ObjData.cpp ├── ObjData.h ├── ObjGroup.cpp ├── ObjGroup.h ├── ObjType.h ├── OffsetType.h ├── PNG files │ ├── BoxColliderEditor │ │ ├── editor_copy.png │ │ ├── editor_left_sel.png │ │ ├── editor_playframe.png │ │ ├── editor_right_sel.png │ │ └── editor_save.png │ ├── DebugElements │ │ ├── 1whitesq.png │ │ └── 1whitesq_tr80.png │ ├── Fighter_0 │ │ ├── fighter_0_crouch.png │ │ ├── fighter_0_hadouken_fire.png │ │ ├── fighter_0_hadouken_recover.png │ │ ├── fighter_0_hitreaction_side.png │ │ ├── fighter_0_hitreaction_up.png │ │ ├── fighter_0_idle.png │ │ ├── fighter_0_jab.png │ │ ├── fighter_0_jump_fall.png │ │ ├── fighter_0_jump_prep_back.png │ │ ├── fighter_0_jump_prep_forward.png │ │ ├── fighter_0_jump_prep_vertical.png │ │ ├── fighter_0_jump_up_back.png │ │ ├── fighter_0_jump_up_forward.png │ │ ├── fighter_0_jump_up_vertical.png │ │ ├── fighter_0_jump_weakpunch.png │ │ ├── fighter_0_uppercut.png │ │ ├── fighter_0_walk.png │ │ └── fighter_0_walkback.png │ ├── Fighter_1 │ │ └── fighter_1_idle.png │ ├── ImpactEffects │ │ └── hiteffect_0.png │ ├── InputBuffer │ │ ├── down.png │ │ ├── downleft.png │ │ ├── downright.png │ │ ├── kick.png │ │ ├── left.png │ │ ├── punch.png │ │ ├── right.png │ │ ├── up.png │ │ ├── upleft.png │ │ └── upright.png │ └── Projectiles │ │ └── hadouken_ball.png ├── PlayerInput.h ├── PlayerToPlayerCollision.h ├── PlayerToProjectileCollision.h ├── PlayerToProjectileCollisionResult.h ├── PlayerType.h ├── Preload_Fighter_0.h ├── PreviousPositionRenderer.h ├── ProjectileCollisionReaction.h ├── ProjectileGroup.cpp ├── ProjectileGroup.h ├── ProjectileType.h ├── ProjectilesFixedUpdater.h ├── ProjectilesHitStopMessage.cpp ├── ProjectilesHitStopMessage.h ├── RandomInteger.h ├── RenderMode.h ├── Scene.cpp ├── Scene.h ├── SceneController.cpp ├── SceneController.h ├── SceneType.h ├── ScreenVector.h ├── SpecialMove.h ├── SpecialMoveProcessor.h ├── SpriteLoader.cpp ├── SpriteLoader.h ├── SpriteType.h ├── State.cpp ├── State.h ├── StateController.cpp ├── StateController.h ├── StopCountData.h ├── StringNotification.h ├── TargetBodyType.h ├── Timer.h ├── UIElement.h ├── Updater.h ├── main.cpp └── olcPixelGameEngine.h └── README.md /FightingGameProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31019.35 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FightingGameProject", "FightingGameProject\FightingGameProject.vcxproj", "{93D7307C-1EA8-4D60-8DB8-201CD0323A0B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Debug|x64.ActiveCfg = Debug|x64 17 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Debug|x64.Build.0 = Debug|x64 18 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Debug|x86.ActiveCfg = Debug|Win32 19 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Debug|x86.Build.0 = Debug|Win32 20 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Release|x64.ActiveCfg = Release|x64 21 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Release|x64.Build.0 = Release|x64 22 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Release|x86.ActiveCfg = Release|Win32 23 | {93D7307C-1EA8-4D60-8DB8-201CD0323A0B}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F76DFC8A-EEC2-49CD-BED2-D616475C276E} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /FightingGameProject/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "BoxCollider.h" 4 | 5 | namespace RB 6 | { 7 | class AABB 8 | { 9 | public: 10 | static bool IsColliding(BoxCollider& boxCol1, olc::vi2d p1Position, BoxCollider& boxCol2, olc::vi2d p2Position) 11 | { 12 | std::array p1Quad; 13 | p1Quad[0] = boxCol1.RelativePoint0() + p1Position; 14 | p1Quad[1] = boxCol1.RelativePoint1() + p1Position; 15 | p1Quad[2] = boxCol1.RelativePoint2() + p1Position; 16 | p1Quad[3] = boxCol1.RelativePoint3() + p1Position; 17 | 18 | std::array p2Quad; 19 | p2Quad[0] = boxCol2.RelativePoint0() + p2Position; 20 | p2Quad[1] = boxCol2.RelativePoint1() + p2Position; 21 | p2Quad[2] = boxCol2.RelativePoint2() + p2Position; 22 | p2Quad[3] = boxCol2.RelativePoint3() + p2Position; 23 | 24 | if (p1Quad[0].x < p2Quad[3].x && //top left vs top right 25 | p1Quad[3].x > p2Quad[0].x) //top right vs top left 26 | { 27 | return true; 28 | } 29 | 30 | return false; 31 | } 32 | }; 33 | } -------------------------------------------------------------------------------- /FightingGameProject/AnimationController.cpp: -------------------------------------------------------------------------------- 1 | #include "AnimationController.h" 2 | 3 | namespace RB 4 | { 5 | void AnimationController::SetParams(SpriteType _spriteType, int32_t _totalWith, int32_t _totalHeight, int32_t _tileCountX, int32_t _tileCountY, int32_t _totalTileCount) 6 | { 7 | status.spriteType = _spriteType; 8 | 9 | specs.totalWidth = _totalWith; 10 | specs.totalHeight = _totalHeight; 11 | specs.tileCountX = _tileCountX; 12 | specs.tileCountY = _tileCountY; 13 | specs.totalTiles = _totalTileCount; 14 | } 15 | 16 | void AnimationController::NextTileIndex() 17 | { 18 | status.nDelayCount++; 19 | 20 | if (status.nDelayCount >= status.nTransitionDelay) 21 | { 22 | status.nDelayCount = 0; 23 | status.nCurrentTile++; 24 | } 25 | 26 | ResetTileIndex(); 27 | } 28 | 29 | void AnimationController::ResetTileIndex() 30 | { 31 | if (status.nCurrentTile >= specs.totalTiles) 32 | { 33 | if (status.bPlayOnce) 34 | { 35 | status.nCurrentTile = specs.totalTiles - 1; 36 | } 37 | else 38 | { 39 | status.nCurrentTile = 0; 40 | } 41 | } 42 | } 43 | 44 | AnimationStatus* AnimationController::UpdateSource() 45 | { 46 | if (specs.tileCountX > 0 && specs.tileCountY > 0) 47 | { 48 | status.sourceSize.x = specs.totalWidth / specs.tileCountX; 49 | status.sourceSize.y = specs.totalHeight / specs.tileCountY; 50 | 51 | if (status.sourceSize.x != 0 && status.sourceSize.y > 0) 52 | { 53 | status.sourcePos.x = (status.nCurrentTile % specs.tileCountX) * status.sourceSize.x; 54 | status.sourcePos.y = (int32_t)floor(status.nCurrentTile / specs.tileCountX) * status.sourceSize.y; 55 | } 56 | 57 | return &status; 58 | } 59 | else 60 | { 61 | return nullptr; 62 | } 63 | } 64 | 65 | bool AnimationController::OnLastAnimationFrame() 66 | { 67 | if (status.nCurrentTile == specs.totalTiles - 1) 68 | { 69 | return true; 70 | } 71 | else 72 | { 73 | return false; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /FightingGameProject/AnimationController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "AnimationSpecs.h" 3 | #include "AnimationStatus.h" 4 | #include "SpriteType.h" 5 | #include "BoxCollider.h" 6 | #include "ColliderLoader.h" 7 | 8 | namespace RB 9 | { 10 | class AnimationController 11 | { 12 | private: 13 | AnimationSpecs specs; 14 | std::string colliderPath = "none"; 15 | std::string spritePath = "none"; 16 | 17 | public: 18 | AnimationStatus status; 19 | 20 | void SetColliderFile(std::string _name) { colliderPath = _name; } 21 | std::string GetColliderPath() { return colliderPath; } 22 | std::string GetSpritePath() { return spritePath; } 23 | void SetSpritePath(std::string str) { spritePath = str; } 24 | int32_t TotalTiles() { return specs.tileCountX * specs.tileCountY; } 25 | int32_t GetTotalTiles() { return specs.totalTiles; } 26 | 27 | void SetParams(SpriteType _spriteType, int32_t _totalWith, int32_t _totalHeight, int32_t _tileCountX, int32_t _tileCountY, int32_t _totalTileCount); 28 | void NextTileIndex(); 29 | void ResetTileIndex(); 30 | AnimationStatus* UpdateSource(); 31 | bool OnLastAnimationFrame(); 32 | }; 33 | } -------------------------------------------------------------------------------- /FightingGameProject/AnimationSpecs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | class AnimationSpecs 7 | { 8 | public: 9 | int32_t totalWidth = 0; 10 | int32_t totalHeight = 0; 11 | int32_t tileCountX = 0; 12 | int32_t tileCountY = 0; 13 | int32_t totalTiles = 0; 14 | }; 15 | } -------------------------------------------------------------------------------- /FightingGameProject/AnimationStatus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "SpriteType.h" 4 | 5 | namespace RB 6 | { 7 | class AnimationStatus 8 | { 9 | public: 10 | SpriteType spriteType = SpriteType::NONE; 11 | int32_t decalTypeIndex = 0; 12 | int32_t nCurrentTile = 0; 13 | int32_t nDelayCount = 0; 14 | int32_t nTransitionDelay = 0; 15 | 16 | bool bPlayOnce = false; 17 | 18 | olc::vi2d sourcePos = { 0, 0 }; 19 | olc::vi2d sourceSize = { 0, 0 }; 20 | }; 21 | } -------------------------------------------------------------------------------- /FightingGameProject/BodyToBodyCollisions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "CheckCollisionMessage.h" 5 | #include "AnimationController.h" 6 | 7 | namespace RB 8 | { 9 | class BodyToBodyCollisions 10 | { 11 | public: 12 | int32_t currentCollisionCount = 0; 13 | int32_t maxCollisions = 0; 14 | std::vector vecCheckCollisions; 15 | 16 | CheckCollisionMessage* GetCheckCollisionMessage(AnimationController& animationController) 17 | { 18 | for (size_t i = 0; i < vecCheckCollisions.size(); i++) 19 | { 20 | if (vecCheckCollisions[i].animationTile == animationController.status.nCurrentTile) 21 | { 22 | return &vecCheckCollisions[i]; 23 | } 24 | else 25 | { 26 | int n = 0; 27 | } 28 | } 29 | 30 | return nullptr; 31 | } 32 | }; 33 | } -------------------------------------------------------------------------------- /FightingGameProject/BodyType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class BodyType 6 | { 7 | HEAD = 0, 8 | 9 | UPPERBODY, 10 | LOWERBODY, 11 | 12 | LEFT_ELBOW, 13 | LEFT_FOREARM, 14 | LEFT_HAND, 15 | 16 | RIGHT_ELBOW, 17 | RIGHT_FOREARM, 18 | RIGHT_HAND, 19 | 20 | LEFT_KNEE, 21 | LEFT_LOWERLEG, 22 | LEFT_FOOT, 23 | 24 | RIGHT_KNEE, 25 | RIGHT_LOWERLEG, 26 | RIGHT_FOOT, 27 | }; 28 | } -------------------------------------------------------------------------------- /FightingGameProject/BottomSegments.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "olcPixelGameEngine.h" 4 | #include "ObjData.h" 5 | #include "BoxCollider.h" 6 | 7 | namespace RB 8 | { 9 | class MoveSegments 10 | { 11 | private: 12 | std::array _vecBottomSegment_left = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 13 | std::array _vecBottomSegment_right = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 14 | 15 | std::array _vecTopSegment_left = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 16 | std::array _vecTopSegment_right = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 17 | 18 | ObjData* _objData; 19 | BoxCollider* _objBoxCollider = nullptr; 20 | //olc::vi2d* _currentPosition = nullptr; 21 | //olc::vi2d* _previousPosition = nullptr; 22 | 23 | public: 24 | MoveSegments(ObjData* objData, BoxCollider* objBoxCollider) 25 | { 26 | _objData = objData; 27 | _objBoxCollider = objBoxCollider; 28 | } 29 | 30 | void SetSegments() 31 | { 32 | //start with default 0 33 | _vecBottomSegment_left = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 34 | _vecBottomSegment_right = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 35 | _vecTopSegment_left = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 36 | _vecTopSegment_right = { olc::vi2d{0, 0}, olc::vi2d{0, 0} }; 37 | 38 | //set new segments 39 | olc::vi2d bottomLeft = _objBoxCollider->RelativePoint1() + _objData->GetPosition(); 40 | olc::vi2d bottomRight = _objBoxCollider->RelativePoint2() + _objData->GetPosition(); 41 | 42 | olc::vi2d prevBottomLeft = _objBoxCollider->RelativePoint1() + _objData->GetPreviousPosition(); 43 | olc::vi2d prevBottomRight = _objBoxCollider->RelativePoint2() + _objData->GetPreviousPosition(); 44 | 45 | olc::vi2d topLeft = _objBoxCollider->RelativePoint0() + _objData->GetPosition(); 46 | olc::vi2d topRight = _objBoxCollider->RelativePoint3() + _objData->GetPosition(); 47 | 48 | olc::vi2d prevTopLeft = _objBoxCollider->RelativePoint0() + _objData->GetPreviousPosition(); 49 | olc::vi2d prevTopRight = _objBoxCollider->RelativePoint3() + _objData->GetPreviousPosition(); 50 | 51 | if (bottomLeft != prevBottomLeft) 52 | { 53 | olc::vi2d dir = prevBottomLeft - bottomLeft; 54 | _vecBottomSegment_left[0] = bottomLeft + (dir * 5); 55 | _vecBottomSegment_left[1] = bottomLeft - (dir * 5); 56 | } 57 | 58 | if (bottomRight != prevBottomRight) 59 | { 60 | olc::vi2d dir = prevBottomRight - bottomRight; 61 | _vecBottomSegment_right[0] = bottomRight + (dir * 5); 62 | _vecBottomSegment_right[1] = bottomRight - (dir * 5); 63 | } 64 | 65 | if (topLeft != prevTopLeft) 66 | { 67 | olc::vi2d dir = prevTopLeft - topLeft; 68 | _vecTopSegment_left[0] = topLeft + (dir * 5); 69 | _vecTopSegment_left[1] = topLeft - (dir * 5); 70 | } 71 | 72 | if (topRight != prevTopRight) 73 | { 74 | olc::vi2d dir = prevTopRight - topRight; 75 | _vecTopSegment_right[0] = topRight + (dir * 5); 76 | _vecTopSegment_right[1] = topRight - (dir * 5); 77 | } 78 | } 79 | 80 | std::array GetBottomLeftSegment() 81 | { 82 | return _vecBottomSegment_left; 83 | } 84 | 85 | std::array GetBottomRightSegment() 86 | { 87 | return _vecBottomSegment_right; 88 | } 89 | 90 | std::array GetTopLeftSegment() 91 | { 92 | return _vecTopSegment_left; 93 | } 94 | 95 | std::array GetTopRightSegment() 96 | { 97 | return _vecTopSegment_right; 98 | } 99 | }; 100 | } -------------------------------------------------------------------------------- /FightingGameProject/BoxCollider.cpp: -------------------------------------------------------------------------------- 1 | #include "BoxCollider.h" 2 | 3 | namespace RB 4 | { 5 | BoxCollider::BoxCollider(olc::vi2d _pos, int32_t _width, int32_t _height, float _rotation) 6 | { 7 | relativePos = _pos; 8 | width = _width; 9 | height = _height; 10 | rotation = _rotation; 11 | 12 | SetQuad(OffsetType::CENTER_CENTER); 13 | } 14 | 15 | void BoxCollider::MovePosition(bool left, bool right, bool up, bool down) 16 | { 17 | if (left && right || !left && !right) 18 | { 19 | 20 | } 21 | else if (left) 22 | { 23 | relativePos.x -= 1; 24 | } 25 | else if (right) 26 | { 27 | relativePos.x += 1; 28 | } 29 | 30 | if (up && down || !up && !down) 31 | { 32 | 33 | } 34 | else if (up) 35 | { 36 | relativePos.y -= 1; 37 | } 38 | else if (down) 39 | { 40 | relativePos.y += 1; 41 | } 42 | } 43 | 44 | void BoxCollider::RotateCounterClockwise() 45 | { 46 | rotation -= 0.01f; 47 | } 48 | 49 | void BoxCollider::RotateClockwise() 50 | { 51 | rotation += 0.01f; 52 | } 53 | 54 | void BoxCollider::UpdateRotation() 55 | { 56 | for (int i = 0; i < quad.size(); i++) 57 | { 58 | float fX = ((float)quad[i].x * cosf(rotation)) - ((float)quad[i].y * sinf(rotation)); 59 | float fY = ((float)quad[i].x * sinf(rotation)) + ((float)quad[i].y * cosf(rotation)); 60 | 61 | rotatedQuad[i] = { (int32_t)std::round(fX), (int32_t)std::round(fY) }; 62 | } 63 | } 64 | 65 | void BoxCollider::SetQuad(OffsetType offsetType) 66 | { 67 | int32_t topLeftX = 0; 68 | int32_t topLeftY = 0; 69 | 70 | if (offsetType == OffsetType::CENTER_CENTER) 71 | { 72 | topLeftX = (int32_t)std::round(-(float)width / 2.0f); 73 | topLeftY = (int32_t)std::round(-(float)height / 2.0f); 74 | } 75 | else if (offsetType == OffsetType::BOTTOM_CENTER) 76 | { 77 | topLeftX = (int32_t)std::round(-(float)width / 2.0f); 78 | topLeftY = (int32_t)std::round(-(float)height); 79 | } 80 | 81 | olc::vi2d topLeft = { topLeftX, topLeftY }; 82 | olc::vi2d bottomLeft = topLeft + olc::vi2d{ 0, height }; 83 | olc::vi2d topRight = topLeft + olc::vi2d{ width, 0 }; 84 | olc::vi2d bottomRight = topLeft + olc::vi2d{ width, height }; 85 | 86 | quad[0] = topLeft; 87 | quad[1] = bottomLeft; 88 | quad[2] = bottomRight; 89 | quad[3] = topRight; 90 | } 91 | 92 | void BoxCollider::Render(Camera& cam, olc::vi2d playerPos, olc::Pixel _color) 93 | { 94 | std::array quad; 95 | quad[0] = ScreenVector::GetScreenPosition(RelativePoint0() + playerPos, cam); 96 | quad[1] = ScreenVector::GetScreenPosition(RelativePoint1() + playerPos, cam); 97 | quad[2] = ScreenVector::GetScreenPosition(RelativePoint2() + playerPos, cam); 98 | quad[3] = ScreenVector::GetScreenPosition(RelativePoint3() + playerPos, cam); 99 | 100 | if (_color == olc::RED) 101 | { 102 | std::array floats; 103 | floats[0] = quad[0]; 104 | floats[1] = quad[1]; 105 | floats[2] = quad[2]; 106 | floats[3] = quad[3]; 107 | 108 | BoxRenderer::Render(floats, _color); 109 | } 110 | 111 | if (DevSettings::renderMode == RenderMode::DEBUG_ONLY || DevSettings::renderMode == RenderMode::SPRITES_AND_DEBUG) 112 | { 113 | olc::Renderer::ptrPGE->DrawLine(quad[0], quad[1], _color); 114 | olc::Renderer::ptrPGE->DrawLine(quad[1], quad[2], _color); 115 | olc::Renderer::ptrPGE->DrawLine(quad[2], quad[3], _color); 116 | olc::Renderer::ptrPGE->DrawLine(quad[3], quad[0], _color); 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /FightingGameProject/BoxCollider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "olcPixelGameEngine.h" 4 | #include "ScreenVector.h" 5 | #include "BoxRenderer.h" 6 | #include "OffsetType.h" 7 | 8 | namespace RB 9 | { 10 | class BoxCollider 11 | { 12 | private: 13 | olc::vi2d relativePos = { 0, 0 }; 14 | int32_t width = 0; 15 | int32_t height = 0; 16 | float rotation = 0.0f; 17 | 18 | std::array quad; 19 | std::array rotatedQuad; 20 | 21 | public: 22 | BoxCollider() 23 | { 24 | 25 | } 26 | 27 | olc::vi2d RelativePoint0() { return rotatedQuad[0] + relativePos; } //topleft 28 | olc::vi2d RelativePoint1() { return rotatedQuad[1] + relativePos; } //bottomleft 29 | olc::vi2d RelativePoint2() { return rotatedQuad[2] + relativePos; } //bottomright 30 | olc::vi2d RelativePoint3() { return rotatedQuad[3] + relativePos; } //topright 31 | 32 | olc::vi2d RelativePosition() { return relativePos; } 33 | void SetRelativePos(int32_t _x, int32_t _y) { relativePos.x = _x; relativePos.y = _y; } 34 | int32_t Width() { return width; } 35 | void SetWidth(int32_t _width) { width = _width; } 36 | int32_t Height() { return height; } 37 | void SetHeight(int32_t _height) { height = _height; } 38 | float Rotation() { return rotation; } 39 | void SetRotation(float _rotation) { rotation = _rotation; } 40 | void IncreaseWidth(int32_t _width) { width += _width; } 41 | void IncreaseHeight(int32_t _height) { height += _height; } 42 | void DecreaseWidth(int32_t _width) { width -= _width; } 43 | void DecreaseHeight(int32_t _height) { height -= _height; } 44 | 45 | BoxCollider(olc::vi2d _pos, int32_t _width, int32_t _height, float _rotation); 46 | void MovePosition(bool left, bool right, bool up, bool down); 47 | void RotateCounterClockwise(); 48 | void RotateClockwise(); 49 | void UpdateRotation(); 50 | void SetQuad(OffsetType offsetType); 51 | void Render(Camera& cam, olc::vi2d playerPos, olc::Pixel _color); 52 | }; 53 | } -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_crouch.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_hadouken_fire.collider: -------------------------------------------------------------------------------- 1 | 60 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 33 248 | -105 249 | 10 250 | 12 251 | 0.28 252 | 27 253 | -92 254 | 22 255 | 19 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_hadouken_recover.collider: -------------------------------------------------------------------------------- 1 | 75 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 33 248 | -105 249 | 10 250 | 12 251 | 0.28 252 | 27 253 | -92 254 | 22 255 | 19 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | 14 303 | -151 304 | 51 305 | 61 306 | 0.02 307 | 6 308 | -105 309 | 44 310 | 31 311 | -0.0200001 312 | 3 313 | -78 314 | 35 315 | 21 316 | -0.03 317 | 29 318 | -112 319 | 9 320 | 17 321 | -1.25 322 | 33 323 | -105 324 | 10 325 | 12 326 | 0.28 327 | 27 328 | -92 329 | 22 330 | 19 331 | 0 332 | -22 333 | -112 334 | 20 335 | 7 336 | -1.01 337 | -19 338 | -105 339 | 23 340 | 7 341 | -0.14 342 | 2 343 | -110 344 | 21 345 | 24 346 | 0.03 347 | 24 348 | -51 349 | 8 350 | 38 351 | -0.42 352 | 25 353 | -17 354 | 6 355 | 33 356 | 0.37 357 | 27 358 | -2 359 | 29 360 | 5 361 | -0.00999998 362 | -23 363 | -51 364 | 7 365 | 40 366 | 0.46 367 | -27 368 | -18 369 | 5 370 | 36 371 | -0.28 372 | -30 373 | -1 374 | 23 375 | 7 376 | -0.01 377 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_hitreaction_side.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_hitreaction_up.collider: -------------------------------------------------------------------------------- 1 | 60 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 33 248 | -105 249 | 10 250 | 12 251 | 0.28 252 | 27 253 | -92 254 | 22 255 | 19 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_idle.collider: -------------------------------------------------------------------------------- 1 | 75 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 33 248 | -105 249 | 10 250 | 12 251 | 0.28 252 | 27 253 | -92 254 | 22 255 | 19 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | 14 303 | -151 304 | 51 305 | 61 306 | 0.02 307 | 6 308 | -105 309 | 44 310 | 31 311 | -0.0200001 312 | 3 313 | -78 314 | 35 315 | 21 316 | -0.03 317 | 29 318 | -112 319 | 9 320 | 17 321 | -1.25 322 | 33 323 | -105 324 | 10 325 | 12 326 | 0.28 327 | 27 328 | -92 329 | 22 330 | 19 331 | 0 332 | -22 333 | -112 334 | 20 335 | 7 336 | -1.01 337 | -19 338 | -105 339 | 23 340 | 7 341 | -0.14 342 | 2 343 | -110 344 | 21 345 | 24 346 | 0.03 347 | 24 348 | -51 349 | 8 350 | 38 351 | -0.42 352 | 25 353 | -17 354 | 6 355 | 33 356 | 0.37 357 | 27 358 | -2 359 | 29 360 | 5 361 | -0.00999998 362 | -23 363 | -51 364 | 7 365 | 40 366 | 0.46 367 | -27 368 | -18 369 | 5 370 | 36 371 | -0.28 372 | -30 373 | -1 374 | 23 375 | 7 376 | -0.01 377 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jab.collider: -------------------------------------------------------------------------------- 1 | 90 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 65 173 | -129 174 | 21 175 | 5 176 | -0.07 177 | 84 178 | -130 179 | 17 180 | 20 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 69 248 | -129 249 | 19 250 | 5 251 | -0.07 252 | 84 253 | -130 254 | 14 255 | 16 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | 14 303 | -151 304 | 51 305 | 61 306 | 0.02 307 | 6 308 | -105 309 | 44 310 | 31 311 | -0.0200001 312 | 3 313 | -78 314 | 35 315 | 21 316 | -0.03 317 | 29 318 | -112 319 | 9 320 | 17 321 | -1.25 322 | 33 323 | -105 324 | 10 325 | 12 326 | 0.28 327 | 27 328 | -92 329 | 22 330 | 19 331 | 0 332 | -22 333 | -112 334 | 20 335 | 7 336 | -1.01 337 | -19 338 | -105 339 | 23 340 | 7 341 | -0.14 342 | 2 343 | -110 344 | 21 345 | 24 346 | 0.03 347 | 24 348 | -51 349 | 8 350 | 38 351 | -0.42 352 | 25 353 | -17 354 | 6 355 | 33 356 | 0.37 357 | 27 358 | -2 359 | 29 360 | 5 361 | -0.00999998 362 | -23 363 | -51 364 | 7 365 | 40 366 | 0.46 367 | -27 368 | -18 369 | 5 370 | 36 371 | -0.28 372 | -30 373 | -1 374 | 23 375 | 7 376 | -0.01 377 | 14 378 | -151 379 | 51 380 | 61 381 | 0.02 382 | 6 383 | -105 384 | 44 385 | 31 386 | -0.0200001 387 | 3 388 | -78 389 | 35 390 | 21 391 | -0.03 392 | 29 393 | -112 394 | 9 395 | 17 396 | -1.25 397 | 33 398 | -105 399 | 10 400 | 12 401 | 0.28 402 | 27 403 | -92 404 | 22 405 | 19 406 | 0 407 | -22 408 | -112 409 | 20 410 | 7 411 | -1.01 412 | -19 413 | -105 414 | 23 415 | 7 416 | -0.14 417 | 2 418 | -110 419 | 21 420 | 24 421 | 0.03 422 | 24 423 | -51 424 | 8 425 | 38 426 | -0.42 427 | 25 428 | -17 429 | 6 430 | 33 431 | 0.37 432 | 27 433 | -2 434 | 29 435 | 5 436 | -0.00999998 437 | -23 438 | -51 439 | 7 440 | 40 441 | 0.46 442 | -27 443 | -18 444 | 5 445 | 36 446 | -0.28 447 | -30 448 | -1 449 | 23 450 | 7 451 | -0.01 452 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_fall.collider: -------------------------------------------------------------------------------- 1 | 30 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_prep_back.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_prep_forward.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_prep_vertical.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_up_back.collider: -------------------------------------------------------------------------------- 1 | 45 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_up_forward.collider: -------------------------------------------------------------------------------- 1 | 45 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_up_vertical.collider: -------------------------------------------------------------------------------- 1 | 45 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_jump_weakpunch.collider: -------------------------------------------------------------------------------- 1 | 15 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 48 28 | -51 29 | 18 30 | 20 31 | -0.01 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 31 48 | -44 49 | 8 50 | 35 51 | -0.71 52 | 24 53 | -34 54 | 6 55 | 36 56 | 1.73 57 | 5 58 | -29 59 | 23 60 | 4 61 | 1.63 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | -------------------------------------------------------------------------------- /FightingGameProject/BoxColliderData/Fighter_0/fighter_0_walk.collider: -------------------------------------------------------------------------------- 1 | 90 2 | 14 3 | -151 4 | 51 5 | 61 6 | 0.02 7 | 6 8 | -105 9 | 44 10 | 31 11 | -0.0200001 12 | 3 13 | -78 14 | 35 15 | 21 16 | -0.03 17 | 29 18 | -112 19 | 9 20 | 17 21 | -1.25 22 | 33 23 | -105 24 | 10 25 | 12 26 | 0.28 27 | 27 28 | -92 29 | 22 30 | 19 31 | 0 32 | -22 33 | -112 34 | 20 35 | 7 36 | -1.01 37 | -19 38 | -105 39 | 23 40 | 7 41 | -0.14 42 | 2 43 | -110 44 | 21 45 | 24 46 | 0.03 47 | 24 48 | -51 49 | 8 50 | 38 51 | -0.42 52 | 25 53 | -17 54 | 6 55 | 33 56 | 0.37 57 | 27 58 | -2 59 | 29 60 | 5 61 | -0.00999998 62 | -23 63 | -51 64 | 7 65 | 40 66 | 0.46 67 | -27 68 | -18 69 | 5 70 | 36 71 | -0.28 72 | -30 73 | -1 74 | 23 75 | 7 76 | -0.01 77 | 14 78 | -151 79 | 51 80 | 61 81 | 0.02 82 | 6 83 | -105 84 | 44 85 | 31 86 | -0.0200001 87 | 3 88 | -78 89 | 35 90 | 21 91 | -0.03 92 | 29 93 | -112 94 | 9 95 | 17 96 | -1.25 97 | 33 98 | -105 99 | 10 100 | 12 101 | 0.28 102 | 27 103 | -92 104 | 22 105 | 19 106 | 0 107 | -22 108 | -112 109 | 20 110 | 7 111 | -1.01 112 | -19 113 | -105 114 | 23 115 | 7 116 | -0.14 117 | 2 118 | -110 119 | 21 120 | 24 121 | 0.03 122 | 24 123 | -51 124 | 8 125 | 38 126 | -0.42 127 | 25 128 | -17 129 | 6 130 | 33 131 | 0.37 132 | 27 133 | -2 134 | 29 135 | 5 136 | -0.00999998 137 | -23 138 | -51 139 | 7 140 | 40 141 | 0.46 142 | -27 143 | -18 144 | 5 145 | 36 146 | -0.28 147 | -30 148 | -1 149 | 23 150 | 7 151 | -0.01 152 | 14 153 | -151 154 | 51 155 | 61 156 | 0.02 157 | 6 158 | -105 159 | 44 160 | 31 161 | -0.0200001 162 | 3 163 | -78 164 | 35 165 | 21 166 | -0.03 167 | 29 168 | -112 169 | 9 170 | 17 171 | -1.25 172 | 33 173 | -105 174 | 10 175 | 12 176 | 0.28 177 | 27 178 | -92 179 | 22 180 | 19 181 | 0 182 | -22 183 | -112 184 | 20 185 | 7 186 | -1.01 187 | -19 188 | -105 189 | 23 190 | 7 191 | -0.14 192 | 2 193 | -110 194 | 21 195 | 24 196 | 0.03 197 | 24 198 | -51 199 | 8 200 | 38 201 | -0.42 202 | 25 203 | -17 204 | 6 205 | 33 206 | 0.37 207 | 27 208 | -2 209 | 29 210 | 5 211 | -0.00999998 212 | -23 213 | -51 214 | 7 215 | 40 216 | 0.46 217 | -27 218 | -18 219 | 5 220 | 36 221 | -0.28 222 | -30 223 | -1 224 | 23 225 | 7 226 | -0.01 227 | 14 228 | -151 229 | 51 230 | 61 231 | 0.02 232 | 6 233 | -105 234 | 44 235 | 31 236 | -0.0200001 237 | 3 238 | -78 239 | 35 240 | 21 241 | -0.03 242 | 29 243 | -112 244 | 9 245 | 17 246 | -1.25 247 | 33 248 | -105 249 | 10 250 | 12 251 | 0.28 252 | 27 253 | -92 254 | 22 255 | 19 256 | 0 257 | -22 258 | -112 259 | 20 260 | 7 261 | -1.01 262 | -19 263 | -105 264 | 23 265 | 7 266 | -0.14 267 | 2 268 | -110 269 | 21 270 | 24 271 | 0.03 272 | 24 273 | -51 274 | 8 275 | 38 276 | -0.42 277 | 25 278 | -17 279 | 6 280 | 33 281 | 0.37 282 | 27 283 | -2 284 | 29 285 | 5 286 | -0.00999998 287 | -23 288 | -51 289 | 7 290 | 40 291 | 0.46 292 | -27 293 | -18 294 | 5 295 | 36 296 | -0.28 297 | -30 298 | -1 299 | 23 300 | 7 301 | -0.01 302 | 14 303 | -151 304 | 51 305 | 61 306 | 0.02 307 | 6 308 | -105 309 | 44 310 | 31 311 | -0.0200001 312 | 3 313 | -78 314 | 35 315 | 21 316 | -0.03 317 | 29 318 | -112 319 | 9 320 | 17 321 | -1.25 322 | 33 323 | -105 324 | 10 325 | 12 326 | 0.28 327 | 27 328 | -92 329 | 22 330 | 19 331 | 0 332 | -22 333 | -112 334 | 20 335 | 7 336 | -1.01 337 | -19 338 | -105 339 | 23 340 | 7 341 | -0.14 342 | 2 343 | -110 344 | 21 345 | 24 346 | 0.03 347 | 24 348 | -51 349 | 8 350 | 38 351 | -0.42 352 | 25 353 | -17 354 | 6 355 | 33 356 | 0.37 357 | 27 358 | -2 359 | 29 360 | 5 361 | -0.00999998 362 | -23 363 | -51 364 | 7 365 | 40 366 | 0.46 367 | -27 368 | -18 369 | 5 370 | 36 371 | -0.28 372 | -30 373 | -1 374 | 23 375 | 7 376 | -0.01 377 | 14 378 | -151 379 | 51 380 | 61 381 | 0.02 382 | 6 383 | -105 384 | 44 385 | 31 386 | -0.0200001 387 | 3 388 | -78 389 | 35 390 | 21 391 | -0.03 392 | 29 393 | -112 394 | 9 395 | 17 396 | -1.25 397 | 33 398 | -105 399 | 10 400 | 12 401 | 0.28 402 | 27 403 | -92 404 | 22 405 | 19 406 | 0 407 | -22 408 | -112 409 | 20 410 | 7 411 | -1.01 412 | -19 413 | -105 414 | 23 415 | 7 416 | -0.14 417 | 2 418 | -110 419 | 21 420 | 24 421 | 0.03 422 | 24 423 | -51 424 | 8 425 | 38 426 | -0.42 427 | 25 428 | -17 429 | 6 430 | 33 431 | 0.37 432 | 27 433 | -2 434 | 29 435 | 5 436 | -0.00999998 437 | -23 438 | -51 439 | 7 440 | 40 441 | 0.46 442 | -27 443 | -18 444 | 5 445 | 36 446 | -0.28 447 | -30 448 | -1 449 | 23 450 | 7 451 | -0.01 452 | -------------------------------------------------------------------------------- /FightingGameProject/BoxRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "SpriteLoader.h" 4 | 5 | namespace RB 6 | { 7 | class BoxRenderer 8 | { 9 | public: 10 | static void Render(std::array& points, olc::Pixel color) 11 | { 12 | static size_t hash = 0; 13 | static olc::Decal* d = nullptr; 14 | 15 | if (hash == 0) 16 | { 17 | hash = std::hash{}("PNG files/DebugElements/1whitesq_tr80.png"); 18 | 19 | IF_COUT{ std::cout << "collider png hash: " << hash << std::endl; }; 20 | } 21 | 22 | if (d == nullptr) 23 | { 24 | d = SpriteLoader::ptr->FindDecal(hash, (size_t)SpriteType::DEBUG_ELEMENTS); 25 | } 26 | else 27 | { 28 | olc::Renderer::ptrPGE->DrawPartialWarpedDecal(d, points, { 245, 245 }, { 0, 0 }, color); 29 | } 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /FightingGameProject/BufferChecker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "SpecialMove.h" 4 | 5 | namespace RB 6 | { 7 | class BufferChecker 8 | { 9 | public: 10 | static bool Correct(SpecialMove& move, std::vector& vecInputs, ObjBase& obj) 11 | { 12 | for (size_t i = 0; i < vecInputs.size(); i++) 13 | { 14 | move.Check(vecInputs[i], i, obj.objData); 15 | } 16 | 17 | if (move.IsMatching()) 18 | { 19 | for (size_t i = 0; i < move.correctBuffers.size(); i++) 20 | { 21 | size_t correctIndex = move.correctBuffers[i]; 22 | 23 | if (correctIndex < vecInputs.size()) 24 | { 25 | vecInputs[correctIndex].processed = true; 26 | } 27 | } 28 | 29 | return true; 30 | } 31 | 32 | return false; 33 | } 34 | }; 35 | } -------------------------------------------------------------------------------- /FightingGameProject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | set(CMAKE_BUILD_TYPE Release) 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") 5 | 6 | project(CPPFightingGame) 7 | 8 | add_executable(CPPFightingGame 9 | AnimationController.cpp 10 | BoxCollider.cpp 11 | Camera.cpp 12 | DevSettings.cpp 13 | DiagonalOverlap.cpp 14 | FightersGroup.cpp 15 | FightersHitStopMessage.cpp 16 | FightScene.cpp 17 | GameObj.cpp 18 | GameSettings.cpp 19 | ImpactEffectsGroup.cpp 20 | InputBuffer.cpp 21 | InputData.cpp 22 | JumpCalculator.cpp 23 | main.cpp 24 | ObjData.cpp 25 | ObjGroup.cpp 26 | ProjectileGroup.cpp 27 | ProjectilesHitStopMessage.cpp 28 | Scene.cpp 29 | SceneController.cpp 30 | SpriteLoader.cpp 31 | State.cpp 32 | StateController.cpp 33 | ) 34 | 35 | target_link_libraries(CPPFightingGame -lX11 -lGL -lpthread -lpng -lstdc++fs) 36 | -------------------------------------------------------------------------------- /FightingGameProject/Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "Camera.h" 2 | 3 | namespace RB 4 | { 5 | Camera::Camera() 6 | { 7 | 8 | } 9 | 10 | void Camera::Update() 11 | { 12 | InputData& inputData = *InputData::ptr; 13 | 14 | if (inputData.key_j && inputData.key_l || !inputData.key_j && !inputData.key_l) 15 | { 16 | // double press (do nothing) 17 | } 18 | else if (inputData.key_j) 19 | { 20 | position.x -= 4; 21 | } 22 | else if (inputData.key_l) 23 | { 24 | 25 | position.x += 4; 26 | } 27 | 28 | if (inputData.key_i && inputData.key_k || !inputData.key_i && !inputData.key_k) 29 | { 30 | // double press (do nothing) 31 | } 32 | else if (inputData.key_i) 33 | { 34 | zoomScale += 0.005f; 35 | } 36 | else if (inputData.key_k) 37 | { 38 | zoomScale -= 0.005f; 39 | } 40 | 41 | float y = -(float)GameSettings::window_height * 0.4f / zoomScale; 42 | position.y = (int32_t)std::round(y); 43 | } 44 | } -------------------------------------------------------------------------------- /FightingGameProject/Camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "GameSettings.h" 4 | #include "InputData.h" 5 | 6 | namespace RB 7 | { 8 | class Camera 9 | { 10 | private: 11 | olc::vi2d position{ 0, 0 }; 12 | float zoomScale = 1.0f; 13 | 14 | public: 15 | Camera(); 16 | 17 | float GetZoom() { return zoomScale; } 18 | olc::vi2d GetPosition() { return position; } 19 | 20 | void Update(); 21 | }; 22 | } -------------------------------------------------------------------------------- /FightingGameProject/CheckCollisionMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BodyType.h" 3 | #include "DamageData.h" 4 | 5 | namespace RB 6 | { 7 | class CheckCollisionMessage 8 | { 9 | public: 10 | std::vector vecBodies; 11 | int32_t animationTile = 0; 12 | DamageData damageData; 13 | }; 14 | } -------------------------------------------------------------------------------- /FightingGameProject/ColliderLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "BoxCollider.h" 4 | #include "BodyType.h" 5 | #include "DevSettings.h" 6 | 7 | namespace RB 8 | { 9 | class ColliderLoader 10 | { 11 | public: 12 | static size_t TotalBodyParts() 13 | { 14 | return (size_t)BodyType::RIGHT_FOOT + 1; 15 | } 16 | 17 | static void SetFighterBodyParts(std::vector& vecColliders, size_t frames) 18 | { 19 | vecColliders.reserve(ColliderLoader::TotalBodyParts() * frames); 20 | 21 | for (int32_t i = 0; i < ColliderLoader::TotalBodyParts() * frames; i++) 22 | { 23 | int32_t x = (int32_t)floor(i / ColliderLoader::TotalBodyParts() * frames) * 1; 24 | int32_t y = -170 + (i % ColliderLoader::TotalBodyParts()) * 12; 25 | vecColliders.push_back(BoxCollider({ x, y }, 40, 50, 0.0f)); 26 | } 27 | } 28 | 29 | static void LoadColliderData(std::vector& vecColliders, std::string colliderFileName) 30 | { 31 | std::string path = colliderFileName; 32 | 33 | IF_COUT{ std::cout << "loading collider: " << path << std::endl; }; 34 | 35 | std::ifstream file(path); 36 | 37 | if (file.is_open()) 38 | { 39 | size_t size = 0; 40 | file >> size; 41 | 42 | IF_COUT{ std::cout << "data size: " << size << std::endl; } 43 | IF_COUT{ std::cout << "collider size: " << vecColliders.size() << std::endl; } 44 | 45 | if (size == vecColliders.size()) 46 | { 47 | for (size_t i = 0; i < vecColliders.size(); i++) 48 | { 49 | int32_t x = 0; 50 | int32_t y = 0; 51 | int32_t width = 0; 52 | int32_t height = 0; 53 | float rotation = 0.0f; 54 | 55 | file >> x; 56 | file >> y; 57 | file >> width; 58 | file >> height; 59 | file >> rotation; 60 | 61 | IF_COUT 62 | { 63 | std::cout << "vec[" << i << "]: " << x << ", " << y << ", " << width << ", " << height << ", " << rotation << std::endl; 64 | }; 65 | 66 | vecColliders[i].SetRelativePos(x, y); 67 | vecColliders[i].SetWidth(width); 68 | vecColliders[i].SetHeight(height); 69 | vecColliders[i].SetRotation(rotation); 70 | } 71 | } 72 | 73 | file.close(); 74 | } 75 | } 76 | 77 | static void SaveColliderData(std::vector& vecColliders, std::string colliderFileName) 78 | { 79 | std::string path = "BoxColliderData/"; 80 | 81 | if (colliderFileName.compare("none") != 0) // "none" is initialization string 82 | { 83 | path += colliderFileName; 84 | 85 | std::ofstream file(path); 86 | 87 | if (file.is_open()) 88 | { 89 | size_t vecSize = vecColliders.size(); 90 | 91 | IF_COUT{ std::cout << "vec size: " << vecSize << std::endl; } 92 | 93 | file << vecSize << std::endl; 94 | 95 | IF_COUT{ std::cout << "saving collider data.." << std::endl; } 96 | 97 | for (size_t i = 0; i < vecColliders.size(); i++) 98 | { 99 | int32_t x = vecColliders[i].RelativePosition().x; 100 | int32_t y = vecColliders[i].RelativePosition().y; 101 | int32_t width = vecColliders[i].Width(); 102 | int32_t height = vecColliders[i].Height(); 103 | float rotation = vecColliders[i].Rotation(); 104 | 105 | file << x << std::endl;; 106 | file << y << std::endl;; 107 | file << width << std::endl;; 108 | file << height << std::endl;; 109 | file << rotation << std::endl;; 110 | 111 | IF_COUT 112 | { 113 | std::cout << "vec[" << i << "]: " << x << ", " << y << ", " << width << ", " << height << ", " << rotation << std::endl; 114 | }; 115 | } 116 | 117 | file.flush(); 118 | file.close(); 119 | } 120 | } 121 | } 122 | }; 123 | } -------------------------------------------------------------------------------- /FightingGameProject/CollidingSideType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class CollidingSideType 6 | { 7 | LEFT = 0, 8 | RIGHT = 1, 9 | UP = 2, 10 | DOWN = 3, 11 | }; 12 | } -------------------------------------------------------------------------------- /FightingGameProject/CollisionData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "ObjData.h" 4 | #include "BoxCollider.h" 5 | #include "BottomSegments.h" 6 | 7 | namespace RB 8 | { 9 | class CollisionData 10 | { 11 | private: 12 | ObjData* _objData = nullptr; 13 | 14 | public: 15 | BoxCollider objBoxCollider; 16 | MoveSegments* moveSegments = nullptr; 17 | 18 | CollisionData(ObjData* objData) 19 | { 20 | _objData = objData; 21 | moveSegments = new MoveSegments(objData, &objBoxCollider); 22 | } 23 | 24 | ~CollisionData() 25 | { 26 | delete (moveSegments); 27 | } 28 | }; 29 | } -------------------------------------------------------------------------------- /FightingGameProject/CollisionStay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CollidingSideType.h" 4 | 5 | namespace RB 6 | { 7 | class CollisionStay 8 | { 9 | private: 10 | ObjData* _objData = nullptr; 11 | std::array _arrIsColliding = { false, false, false, false }; 12 | 13 | public: 14 | CollisionStay(ObjData* objData) 15 | { 16 | _objData = objData; 17 | } 18 | 19 | void AddCollidingSide(CollidingSideType sideType) 20 | { 21 | _arrIsColliding[(size_t)sideType] = true; 22 | } 23 | 24 | void AddHorizontalCollidingSide(olc::vi2d midPoint) 25 | { 26 | if (midPoint.x < _objData->GetPosition().x) 27 | { 28 | AddCollidingSide(CollidingSideType::LEFT); 29 | } 30 | else if (midPoint.x > _objData->GetPosition().x) 31 | { 32 | AddCollidingSide(CollidingSideType::RIGHT); 33 | } 34 | } 35 | 36 | void ClearAllSides() 37 | { 38 | for (size_t i = 0; i < _arrIsColliding.size(); i++) 39 | { 40 | _arrIsColliding[i] = false; 41 | } 42 | } 43 | 44 | bool IsColliding(CollidingSideType sideType) 45 | { 46 | return _arrIsColliding[(size_t)sideType]; 47 | } 48 | }; 49 | } -------------------------------------------------------------------------------- /FightingGameProject/ConvertedInputType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class ConvertedInputType 6 | { 7 | NONE, 8 | 9 | FORWARD, 10 | BACK, 11 | UP, 12 | DOWN, 13 | 14 | UP_FORWARD, 15 | DOWN_FORWARD, 16 | DOWN_BACK, 17 | UP_BACK, 18 | 19 | WEAK_PUNCH, 20 | WEAK_KICK, 21 | 22 | STRONG_PUNCH, 23 | STRONG_KICK, 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/CreateProjectileMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ProjectileType.h" 3 | #include "olcPixelGameEngine.h" 4 | 5 | namespace RB 6 | { 7 | class CreateProjectileMessage 8 | { 9 | public: 10 | ProjectileType projectileType = ProjectileType::NONE; 11 | olc::vi2d forward = { 0, 0 }; 12 | olc::vi2d startPos = { 0, 0 }; 13 | size_t ownerObjCreationID = 0; 14 | }; 15 | } -------------------------------------------------------------------------------- /FightingGameProject/DamageData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | class DamageData 7 | { 8 | public: 9 | int32_t sidePush = 0; 10 | int32_t upPush = 0; 11 | }; 12 | } -------------------------------------------------------------------------------- /FightingGameProject/DevSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "DevSettings.h" 2 | 3 | namespace RB 4 | { 5 | RenderMode DevSettings::renderMode = RenderMode::SPRITES_ONLY; 6 | 7 | void DevSettings::UpdateDebugBoxSettings() 8 | { 9 | InputData& inputData = *InputData::ptr; 10 | 11 | if (inputData.key_f8) 12 | { 13 | if (!inputData.key_f8->processed) 14 | { 15 | inputData.key_f8->processed = true; 16 | ChangeRenderMode(); 17 | } 18 | 19 | } 20 | } 21 | 22 | void DevSettings::ChangeRenderMode() 23 | { 24 | int32_t mode = (int32_t)renderMode; 25 | 26 | mode++; 27 | 28 | if (mode < 0) 29 | { 30 | mode = (int32_t)RenderMode::COUNT - 1; 31 | } 32 | 33 | if (mode >= (int32_t)RenderMode::COUNT) 34 | { 35 | mode = 0; 36 | } 37 | 38 | renderMode = (RenderMode)mode; 39 | 40 | IF_COUT{ std::cout << "render mode: " << (int32_t)renderMode << std::endl; } 41 | } 42 | } -------------------------------------------------------------------------------- /FightingGameProject/DevSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "RenderMode.h" 4 | #include "InputData.h" 5 | 6 | namespace RB 7 | { 8 | #define IF_COUT if (DevSettings::use_cout) 9 | 10 | class DevSettings 11 | { 12 | public: 13 | const static bool use_cout = true; 14 | static RenderMode renderMode; 15 | 16 | static void UpdateDebugBoxSettings(); 17 | static void ChangeRenderMode(); 18 | }; 19 | } -------------------------------------------------------------------------------- /FightingGameProject/DiagonalOverlap.cpp: -------------------------------------------------------------------------------- 1 | #include "DiagonalOverlap.h" 2 | 3 | namespace RB 4 | { 5 | bool DiagonalOverlap::Overlapping(olc::vi2d& p1Pos, std::array& p1Quads, olc::vi2d& p2Pos, std::array& p2Quads) 6 | { 7 | olc::vi2d* r1 = &p1Pos; 8 | std::array* r1Quads = &p1Quads; 9 | 10 | olc::vi2d* r2 = &p2Pos; 11 | std::array* r2Quads = &p2Quads; 12 | 13 | for (size_t shape = 0; shape < 2; shape++) 14 | { 15 | //switch 16 | if (shape == 1) 17 | { 18 | r1 = &p2Pos; 19 | r1Quads = &p2Quads; 20 | 21 | r2 = &p1Pos; 22 | r2Quads = &p1Quads; 23 | } 24 | 25 | // Check diagonals of polygon... 26 | for (size_t p = 0; p < r1Quads->size(); p++) 27 | { 28 | olc::vi2d line_r1s = *r1; 29 | olc::vi2d line_r1e = (*r1Quads)[p]; 30 | 31 | // ...against edges of the other 32 | for (size_t q = 0; q < r2Quads->size(); q++) 33 | { 34 | olc::vi2d line_r2s = (*r2Quads)[q]; 35 | olc::vi2d line_r2e = (*r2Quads)[(q + 1) % r2Quads->size()]; 36 | 37 | // Standard "off the shelf" line segment intersection 38 | float h = (float)(line_r2e.x - line_r2s.x) * (float)(line_r1s.y - line_r1e.y) - (float)(line_r1s.x - line_r1e.x) * (float)(line_r2e.y - line_r2s.y); 39 | float t1 = ((float)(line_r2s.y - line_r2e.y) * (float)(line_r1s.x - line_r2s.x) + (float)(line_r2e.x - line_r2s.x) * (float)(line_r1s.y - line_r2s.y)) / h; 40 | float t2 = ((float)(line_r1s.y - line_r1e.y) * (float)(line_r1s.x - line_r2s.x) + (float)(line_r1e.x - line_r1s.x) * (float)(line_r1s.y - line_r2s.y)) / h; 41 | 42 | if (t1 >= 0.0f && t1 < 1.0f && t2 >= 0.0f && t2 < 1.0f) 43 | { 44 | return true; 45 | } 46 | } 47 | } 48 | } 49 | 50 | return false; 51 | } 52 | } -------------------------------------------------------------------------------- /FightingGameProject/DiagonalOverlap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "BodyType.h" 4 | 5 | namespace RB 6 | { 7 | class DiagonalOverlap 8 | { 9 | public: 10 | static bool Overlapping(olc::vi2d& p1Pos, std::array& p1Quads, olc::vi2d& p2Pos, std::array& p2Quads); 11 | }; 12 | } -------------------------------------------------------------------------------- /FightingGameProject/Directions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PlayerInput.h" 3 | 4 | namespace RB 5 | { 6 | class Directions 7 | { 8 | public: 9 | bool forward = false; 10 | bool back = false; 11 | bool up = false; 12 | bool down = false; 13 | 14 | static Directions Get(bool isFacingRight, PlayerInput& playerInput) 15 | { 16 | Directions d; 17 | 18 | if (isFacingRight) 19 | { 20 | if (playerInput.left && playerInput.right || !playerInput.left && !playerInput.right) 21 | { 22 | //double press 23 | } 24 | else if (playerInput.left) 25 | { 26 | d.back = true; 27 | } 28 | else if (playerInput.right) 29 | { 30 | d.forward = true; 31 | } 32 | } 33 | else 34 | { 35 | if (playerInput.left && playerInput.right || !playerInput.left && !playerInput.right) 36 | { 37 | //double press 38 | } 39 | else if (playerInput.left) 40 | { 41 | d.forward = true; 42 | } 43 | else if (playerInput.right) 44 | { 45 | d.back = true; 46 | } 47 | } 48 | 49 | if (playerInput.up) 50 | { 51 | d.up = true; 52 | } 53 | 54 | if (playerInput.down) 55 | { 56 | d.down = true; 57 | } 58 | 59 | return d; 60 | } 61 | 62 | static int32_t GetForwardSpeed(bool isFacingRight, int32_t speed) 63 | { 64 | if (isFacingRight) 65 | { 66 | return speed; 67 | } 68 | else 69 | { 70 | return -speed; 71 | } 72 | } 73 | 74 | static int32_t GetBackSpeed(bool isFacingRight, int32_t speed) 75 | { 76 | if (isFacingRight) 77 | { 78 | return -speed; 79 | } 80 | else 81 | { 82 | return speed; 83 | } 84 | } 85 | }; 86 | } -------------------------------------------------------------------------------- /FightingGameProject/FightScene.cpp: -------------------------------------------------------------------------------- 1 | #include "FightScene.h" 2 | 3 | namespace RB 4 | { 5 | FightScene::FightScene() 6 | { 7 | IF_COUT{ std::cout << "constructing FightScene" << std::endl; }; 8 | 9 | _cam = new Camera(); 10 | 11 | _fighters = new FightersGroup(_cam); 12 | _projectiles = new ProjectileGroup(_cam); 13 | _impactEffects = new ImpactEffectsGroup(_cam); 14 | 15 | DevSettings::renderMode = RenderMode::SPRITES_ONLY; 16 | } 17 | 18 | FightScene::~FightScene() 19 | { 20 | IF_COUT{ std::cout << "destructing FightScene" << std::endl; }; 21 | 22 | delete _fighters; 23 | delete _projectiles; 24 | delete _impactEffects; 25 | 26 | delete _playerToPlayerCollision; 27 | delete _meleeReaction; 28 | delete _playerToProjectileCollision; 29 | delete _projectileCollisionReaction; 30 | } 31 | 32 | void FightScene::InitScene() 33 | { 34 | _fighters->CreateFighterObj(olc::vi2d(-100, 0), PlayerType::PLAYER_1); 35 | _fighters->CreateFighterObj(olc::vi2d(100, 0), PlayerType::PLAYER_2); 36 | 37 | _fighters->GetObj(0)->SetCurrentState(State::NewState(_fighters->GetObj(0))); 38 | _fighters->GetObj(1)->SetCurrentState(State::NewState(_fighters->GetObj(1))); 39 | 40 | _playerToPlayerCollision = new PlayerToPlayerCollision(_fighters->GetObj(0), _fighters->GetObj(1)); 41 | _meleeReaction = new MeleeReaction(_fighters->GetObj(0), _fighters->GetObj(1), _impactEffects); 42 | 43 | _playerToProjectileCollision = new PlayerToProjectileCollision(_fighters->GetVecObjs(), _projectiles->GetVecObjs()); 44 | _projectileCollisionReaction = new ProjectileCollisionReaction(_fighters, _projectiles, _impactEffects); 45 | } 46 | 47 | void FightScene::UpdateScene() 48 | { 49 | PlayerToProjectileCollisionResult projColResult0 = _playerToProjectileCollision->FighterCollidesWithProjectile(0); 50 | PlayerToProjectileCollisionResult projColResult1 = _playerToProjectileCollision->FighterCollidesWithProjectile(1); 51 | _projectileCollisionReaction->Update(0, projColResult0); 52 | _projectileCollisionReaction->Update(1, projColResult1); 53 | 54 | MeleeCollisionResult F0HitsF1 = _playerToPlayerCollision->Fighter0HitsFighter1(); 55 | MeleeCollisionResult F1HitsF0 = _playerToPlayerCollision->Fighter1HitsFighter0(); 56 | _meleeReaction->Update(1, F0HitsF1); 57 | _meleeReaction->Update(0, F1HitsF0); 58 | 59 | std::vector* p1 = &_fighters->GetObj(0)->GetCurrentState()->vecCreateProjectiles; 60 | std::vector* p2 = &_fighters->GetObj(1)->GetCurrentState()->vecCreateProjectiles; 61 | _projectiles->CreateProjectiles(*p1); 62 | _projectiles->CreateProjectiles(*p2); 63 | p1->clear(); 64 | p2->clear(); 65 | 66 | _fighters->UpdateStates(); 67 | _impactEffects->UpdateStates(); 68 | _projectiles->UpdateStates(); 69 | } 70 | 71 | void FightScene::RenderObjs() 72 | { 73 | ShowZeroPosition(*_cam); 74 | 75 | _fighters->RenderObjPosition(); 76 | _projectiles->RenderObjPosition(); 77 | _impactEffects->RenderObjPosition(); 78 | } 79 | 80 | void FightScene::RenderStates() 81 | { 82 | _fighters->RenderStates(); 83 | _fighters->RenderBoxColliders(); 84 | 85 | _projectiles->RenderStates(); 86 | _impactEffects->RenderStates(); 87 | } 88 | } -------------------------------------------------------------------------------- /FightingGameProject/FightScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Scene.h" 3 | #include "FightersGroup.h" 4 | #include "ProjectileGroup.h" 5 | #include "ImpactEffectsGroup.h" 6 | #include "PlayerToPlayerCollision.h" 7 | #include "MeleeReaction.h" 8 | #include "PlayerToProjectileCollision.h" 9 | #include "ProjectileCollisionReaction.h" 10 | 11 | //temp 12 | #include "Fighter_1_Idle.h" 13 | 14 | namespace RB 15 | { 16 | class FightScene : public Scene 17 | { 18 | private: 19 | FightersGroup* _fighters = nullptr; 20 | ProjectileGroup* _projectiles = nullptr; 21 | ImpactEffectsGroup* _impactEffects = nullptr; 22 | 23 | PlayerToPlayerCollision* _playerToPlayerCollision = nullptr; 24 | MeleeReaction* _meleeReaction = nullptr; 25 | PlayerToProjectileCollision* _playerToProjectileCollision = nullptr; 26 | ProjectileCollisionReaction* _projectileCollisionReaction = nullptr; 27 | 28 | public: 29 | FightScene(); 30 | ~FightScene() override; 31 | 32 | void InitScene() override; 33 | void UpdateScene() override; 34 | void RenderObjs() override; 35 | void RenderStates() override; 36 | }; 37 | } -------------------------------------------------------------------------------- /FightingGameProject/FighterDirection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IGroupComponent.h" 4 | 5 | namespace RB 6 | { 7 | class FighterDirection : public IGroupComponent 8 | { 9 | private: 10 | std::vector* _vecFighters = nullptr; 11 | 12 | public: 13 | FighterDirection(std::vector* vecFighters) 14 | { 15 | _vecFighters = vecFighters; 16 | } 17 | 18 | void Update() override 19 | { 20 | std::vector& vec = *_vecFighters; 21 | UpdateFigherDirection(vec[0]->objData, vec[1]->objData); 22 | UpdateFigherDirection(vec[1]->objData, vec[0]->objData); 23 | } 24 | 25 | void UpdateFigherDirection(ObjData& me, ObjData& enemy) 26 | { 27 | //only turn when grounded 28 | if (me.GetPosition().y == 0) 29 | { 30 | if (me.GetPosition().x < enemy.GetPosition().x) 31 | { 32 | me.SetLeftSide(true); 33 | me.FaceRight(true); 34 | } 35 | else if (me.GetPosition().x > enemy.GetPosition().x) 36 | { 37 | me.SetLeftSide(false); 38 | me.FaceRight(false); 39 | } 40 | } 41 | } 42 | }; 43 | } -------------------------------------------------------------------------------- /FightingGameProject/FighterGroundToGroundCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IGroupComponent.h" 4 | #include "RandomInteger.h" 5 | #include "AABB.h" 6 | #include "Normalize.h" 7 | 8 | namespace RB 9 | { 10 | class FighterGroundToGroundCollision : public IGroupComponent 11 | { 12 | private: 13 | std::vector* _vecFighters = nullptr; 14 | RandomInteger randomInteger; 15 | 16 | public: 17 | FighterGroundToGroundCollision(std::vector* vecFighters) 18 | { 19 | _vecFighters = vecFighters; 20 | } 21 | 22 | void Update() override 23 | { 24 | std::vector& vec = *_vecFighters; 25 | 26 | vec[0]->collisionStay->ClearAllSides(); 27 | vec[1]->collisionStay->ClearAllSides(); 28 | 29 | //ground vs ground 30 | if (vec[0]->objData.GetPosition().y == 0 && vec[1]->objData.GetPosition().y == 0) 31 | { 32 | //fighters shouldn't have same position 33 | int32_t distance = std::abs(vec[0]->objData.GetPosition().x - vec[1]->objData.GetPosition().x); 34 | if (distance <= 1) 35 | { 36 | int index = randomInteger.GetInteger(0, 1); 37 | olc::vi2d newPos = vec[index]->objData.GetPosition() + olc::vi2d(10, 0); 38 | vec[index]->objData.SetPosition(newPos); 39 | 40 | IF_COUT{ std::cout << "distance between fighters: " << distance << std::endl; }; 41 | IF_COUT{ std::cout << "resolving same position" << std::endl; }; 42 | IF_COUT{ std::cout << "random index: " << index << std::endl; }; 43 | } 44 | 45 | if (AABB::IsColliding( 46 | vec[0]->collisionData.objBoxCollider, vec[0]->objData.GetPosition(), //p1 obj boxcollider 47 | vec[1]->collisionData.objBoxCollider, vec[1]->objData.GetPosition())) //p2 obj boxcollider 48 | { 49 | olc::vi2d relMidPoint = vec[1]->objData.GetPosition() - vec[0]->objData.GetPosition(); 50 | relMidPoint.x = (int32_t)std::round(relMidPoint.x / 2.0f); 51 | relMidPoint.y = (int32_t)std::round(relMidPoint.y / 2.0f); 52 | olc::vf2d midPoint = vec[0]->objData.GetPosition() + relMidPoint; 53 | 54 | olc::vi2d p1Dir = vec[0]->objData.GetPosition() - midPoint; 55 | olc::vi2d p2Dir = vec[1]->objData.GetPosition() - midPoint; 56 | 57 | olc::vf2d p1rel = (olc::vf2d)Normalize::Norm(p1Dir) * (float)vec[0]->collisionData.objBoxCollider.Width() / 2.0f; 58 | olc::vf2d p2rel = (olc::vf2d)Normalize::Norm(p2Dir) * (float)vec[1]->collisionData.objBoxCollider.Width() / 2.0f; 59 | 60 | olc::vf2d p1Resolved = midPoint + p1rel; 61 | olc::vf2d p2Resolved = midPoint + p2rel; 62 | 63 | olc::vi2d p1Rounded{ 0, 0 }; 64 | olc::vi2d p2Rounded{ 0, 0 }; 65 | 66 | p1Rounded.x = (int32_t)std::round(p1Resolved.x); 67 | p2Rounded.x = (int32_t)std::round(p2Resolved.x); 68 | 69 | vec[0]->objData.SetPosition(p1Rounded); 70 | vec[1]->objData.SetPosition(p2Rounded); 71 | 72 | vec[0]->collisionStay->AddHorizontalCollidingSide(midPoint); 73 | vec[1]->collisionStay->AddHorizontalCollidingSide(midPoint); 74 | } 75 | } 76 | } 77 | }; 78 | } -------------------------------------------------------------------------------- /FightingGameProject/FighterJump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IGroupComponent.h" 3 | 4 | namespace RB 5 | { 6 | class FighterJump : public IGroupComponent 7 | { 8 | private: 9 | std::vector* _vecFighters = nullptr; 10 | 11 | public: 12 | FighterJump(std::vector* vecFighters) 13 | { 14 | _vecFighters = vecFighters; 15 | } 16 | 17 | void Update() override 18 | { 19 | std::vector& vec = *_vecFighters; 20 | 21 | for (size_t i = 0; i < vec.size(); i++) 22 | { 23 | ProcessJump(*vec[i]); 24 | } 25 | } 26 | 27 | void ProcessJump(ObjBase& obj) 28 | { 29 | //process jump 30 | if (obj.objData.ptrJumpCalculator != nullptr) 31 | { 32 | PlayerInput p = PlayerInput::Get(obj.objData.GetPlayerType()); 33 | Directions d = Directions::Get(obj.objData.IsFacingRight(), p); 34 | 35 | obj.objData.ptrJumpCalculator->UpdateJump(d.up, d.forward, d.back); 36 | 37 | if (obj.objData.GetPosition().y <= 0) 38 | { 39 | olc::vi2d vertical = obj.objData.GetPosition() - olc::vi2d(0, obj.objData.ptrJumpCalculator->GetUpForce()); 40 | obj.objData.SetPosition(vertical); 41 | 42 | olc::vi2d horizontalForce = olc::vi2d{ 0, 0 }; 43 | 44 | if (obj.objData.IsFacingRight()) 45 | { 46 | horizontalForce = olc::vi2d(obj.objData.ptrJumpCalculator->GetSideForce(), 0); 47 | } 48 | else 49 | { 50 | horizontalForce = olc::vi2d(obj.objData.ptrJumpCalculator->GetSideForce() * -1, 0); 51 | } 52 | 53 | if (!obj.objData.ptrJumpCalculator->MoveBack()) 54 | { 55 | olc::vi2d horizontal = obj.objData.GetPosition() + horizontalForce; 56 | obj.objData.SetPosition(horizontal); 57 | } 58 | else 59 | { 60 | olc::vi2d horizontal = obj.objData.GetPosition() - horizontalForce; 61 | obj.objData.SetPosition(horizontal); 62 | } 63 | } 64 | } 65 | 66 | //clear jump 67 | if (obj.objData.GetPosition().y > 0) 68 | { 69 | olc::vi2d groundPos = olc::vi2d(obj.objData.GetPosition().x, 0); 70 | obj.objData.SetPosition(groundPos); 71 | 72 | delete obj.objData.ptrJumpCalculator; 73 | obj.objData.ptrJumpCalculator = nullptr; 74 | } 75 | } 76 | }; 77 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Crouch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Uppercut; 8 | 9 | class Fighter_0_Crouch : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_Crouch() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_crouch.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_crouch.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 21 | } 22 | 23 | void OnEnter() override 24 | { 25 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 26 | } 27 | 28 | void OnUpdate() override 29 | { 30 | UpdateColliderParts(); 31 | 32 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 33 | 34 | if (p.strongpunch) 35 | { 36 | nextState = State::NewState(_ownerObj); 37 | } 38 | else 39 | { 40 | if (!p.down) 41 | { 42 | nextState = State::NewState(_ownerObj); 43 | } 44 | } 45 | } 46 | 47 | std::vector& GetColliders() override { static std::vector vec; return vec; } 48 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 49 | }; 50 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Hadouken_Fire.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Hadouken_Recover; 7 | 8 | class Fighter_0_Hadouken_Fire : public State 9 | { 10 | private: 11 | bool fired = false; 12 | 13 | protected: 14 | size_t& Hash() override { static size_t hash = 0; return hash; } 15 | 16 | public: 17 | Fighter_0_Hadouken_Fire() 18 | { 19 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_hadouken_fire.png"); 20 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_hadouken_fire.collider"); 21 | 22 | animationController.SetParams(SpriteType::FIGHTER_0, 1600, 200, 4, 1, 4); 23 | animationController.status.nTransitionDelay = 5; 24 | animationController.status.bPlayOnce = true; 25 | } 26 | 27 | void OnEnter() override 28 | { 29 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 30 | } 31 | 32 | void OnUpdate() override 33 | { 34 | UpdateColliderParts(); 35 | 36 | if (animationController.status.nCurrentTile == 3) 37 | { 38 | if (!fired) 39 | { 40 | fired = true; 41 | CreateProjectileMessage p; 42 | p.projectileType = ProjectileType::HADOUKEN; 43 | 44 | p.startPos = _ownerObj->objData.GetPosition() + olc::vi2d(0, -105); 45 | 46 | if (_ownerObj->objData.IsFacingRight()) 47 | { 48 | p.forward = { 1, 0 }; 49 | p.startPos += olc::vi2d(55, 0); 50 | } 51 | else 52 | { 53 | p.forward = { -1, 0 }; 54 | p.startPos += olc::vi2d(-55, 0); 55 | } 56 | 57 | p.ownerObjCreationID = _ownerObj->objData.GetCreationID(); 58 | 59 | vecCreateProjectiles.push_back(p); 60 | } 61 | } 62 | 63 | int32_t targetdelay = 8; 64 | size_t end = (size_t)animationController.status.nTransitionDelay * (size_t)targetdelay; 65 | 66 | if (stateUpdateCount >= end) 67 | { 68 | nextState = State::NewState(_ownerObj); 69 | } 70 | } 71 | 72 | std::vector& GetColliders() override { static std::vector vec; return vec; } 73 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 74 | }; 75 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Hadouken_Recover.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_Hadouken_Recover : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Hadouken_Recover() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_hadouken_recover.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_hadouken_recover.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 2000, 200, 5, 1, 5); 20 | animationController.status.nTransitionDelay = 4; 21 | animationController.status.bPlayOnce = true; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | int32_t tiles = animationController.GetTotalTiles() - (int32_t)1; 34 | size_t end = (size_t)tiles * (size_t)animationController.status.nTransitionDelay; 35 | 36 | if (stateUpdateCount >= end) 37 | { 38 | nextState = State::NewState(_ownerObj); 39 | } 40 | } 41 | 42 | std::vector& GetColliders() override { static std::vector vec; return vec; } 43 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 44 | }; 45 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_HitReaction_Side.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_HitReaction_Side : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_HitReaction_Side() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_hitreaction_side.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_hitreaction_side.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 20 | animationController.status.nTransitionDelay = 8; 21 | } 22 | 23 | void OnEnter() override 24 | { 25 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 26 | } 27 | 28 | void OnUpdate() override 29 | { 30 | UpdateColliderParts(); 31 | 32 | int32_t e0 = animationController.status.nTransitionDelay * (int32_t)1; 33 | int32_t e1 = animationController.status.nTransitionDelay * (int32_t)2; 34 | int32_t e2 = animationController.status.nTransitionDelay * (int32_t)3; 35 | 36 | if (stateUpdateCount == 0 && stateUpdateCount < e0) 37 | { 38 | int32_t speed = Directions::GetBackSpeed(_ownerObj->objData.IsFacingRight(), 2); 39 | olc::vi2d pos = _ownerObj->objData.GetPosition(); 40 | pos.x += speed; 41 | _ownerObj->objData.SetPosition(pos); 42 | } 43 | else if (stateUpdateCount < e1) 44 | { 45 | int32_t speed = Directions::GetBackSpeed(_ownerObj->objData.IsFacingRight(), 1); 46 | olc::vi2d pos = _ownerObj->objData.GetPosition(); 47 | pos.x += speed; 48 | _ownerObj->objData.SetPosition(pos); 49 | } 50 | else if (stateUpdateCount >= e2) 51 | { 52 | nextState = State::NewState(_ownerObj); 53 | } 54 | } 55 | 56 | std::vector& GetColliders() override { static std::vector vec; return vec; } 57 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 58 | }; 59 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_HitReaction_Up.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_HitReaction_Up : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_HitReaction_Up() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_hitreaction_up.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_hitreaction_up.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 1600, 200, 4, 1, 4); 20 | animationController.status.nTransitionDelay = 7; 21 | animationController.status.bPlayOnce = true; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | } 33 | 34 | std::vector& GetColliders() override { static std::vector vec; return vec; } 35 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 36 | }; 37 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Idle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_WalkForward; 7 | class Fighter_0_WalkBack; 8 | class Fighter_0_Jab; 9 | class Fighter_0_Jump_Prep_Vertical; 10 | class Fighter_0_Jump_Prep_Forward; 11 | class Fighter_0_Jump_Prep_Back; 12 | class Fighter_0_Crouch; 13 | 14 | class Fighter_0_Idle : public State 15 | { 16 | protected: 17 | size_t& Hash() override { static size_t hash = 0; return hash; } 18 | 19 | public: 20 | Fighter_0_Idle() 21 | { 22 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_idle.png"); 23 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_idle.collider"); 24 | 25 | animationController.SetParams(SpriteType::FIGHTER_0, 2000, 200, 5, 1, 5); 26 | animationController.status.nTransitionDelay = 6; 27 | } 28 | 29 | void OnEnter() override 30 | { 31 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 32 | 33 | _ownerObj->collisionData.objBoxCollider.SetWidth(76); 34 | _ownerObj->collisionData.objBoxCollider.SetHeight(170); 35 | _ownerObj->collisionData.objBoxCollider.SetQuad(OffsetType::BOTTOM_CENTER); 36 | _ownerObj->collisionData.objBoxCollider.UpdateRotation(); 37 | } 38 | 39 | void OnUpdate() override 40 | { 41 | UpdateColliderParts(); 42 | 43 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 44 | Directions d = Directions::Get(_ownerObj->objData.IsFacingRight(), p); 45 | 46 | if (p.weakpunch) 47 | { 48 | InputData& inputData = *InputData::ptr; 49 | Key* wp = inputData.GetWeakPunchKey(_ownerObj->objData.GetPlayerType()); 50 | wp->processed = true; 51 | 52 | nextState = State::NewState(_ownerObj); 53 | } 54 | 55 | else if (d.forward) 56 | { 57 | nextState = State::NewState(_ownerObj); 58 | } 59 | else if (d.back) 60 | { 61 | nextState = State::NewState(_ownerObj); 62 | } 63 | 64 | else if (d.up && !d.forward && !d.back) 65 | { 66 | nextState = State::NewState(_ownerObj); 67 | } 68 | else if (d.up && d.forward) 69 | { 70 | nextState = State::NewState(_ownerObj); 71 | } 72 | else if (d.up && d.back) 73 | { 74 | nextState = State::NewState(_ownerObj); 75 | } 76 | else if (d.down && !d.up) 77 | { 78 | nextState = State::NewState(_ownerObj); 79 | } 80 | } 81 | 82 | std::vector& GetColliders() override { static std::vector vec; return vec; } 83 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 84 | }; 85 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jab.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_Jab : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Jab() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jab.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jab.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 2400, 200, 6, 1, 6); 20 | animationController.status.nTransitionDelay = 3; 21 | 22 | CheckCollisionMessage c0; 23 | CheckCollisionMessage c1; 24 | 25 | c0.vecBodies.push_back(BodyType::LEFT_FOREARM); 26 | c0.vecBodies.push_back(BodyType::LEFT_HAND); 27 | c0.animationTile = 2; 28 | 29 | c1.vecBodies.push_back(BodyType::LEFT_FOREARM); 30 | c1.vecBodies.push_back(BodyType::LEFT_HAND); 31 | c1.animationTile = 3; 32 | 33 | bodyToBodyCollisions.vecCheckCollisions.push_back(c0); 34 | bodyToBodyCollisions.vecCheckCollisions.push_back(c1); 35 | 36 | bodyToBodyCollisions.maxCollisions = 1; 37 | } 38 | 39 | void OnEnter() override 40 | { 41 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 42 | } 43 | 44 | void OnUpdate() override 45 | { 46 | UpdateColliderParts(); 47 | 48 | size_t end = ((size_t)animationController.GetTotalTiles() - (size_t)1) * (size_t)animationController.status.nTransitionDelay; 49 | 50 | if (stateUpdateCount >= end) 51 | { 52 | nextState = State::NewState(_ownerObj); 53 | } 54 | } 55 | 56 | std::vector& GetColliders() override { static std::vector vec; return vec; } 57 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 58 | }; 59 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Fall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_WeakPunch; 8 | 9 | class Fighter_0_Jump_Fall : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_Jump_Fall() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_fall.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_fall.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 800, 200, 2, 1, 2); 21 | animationController.status.nTransitionDelay = 10; 22 | animationController.status.bPlayOnce = true; 23 | } 24 | 25 | void OnEnter() override 26 | { 27 | _ownerObj->objData.SetSpriteSize({ 420, 220 }); 28 | } 29 | 30 | void OnUpdate() override 31 | { 32 | UpdateColliderParts(); 33 | 34 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 35 | 36 | if (_ownerObj->objData.GetPosition().y >= 0 && stateUpdateCount != 0) 37 | { 38 | nextState = State::NewState(_ownerObj); 39 | } 40 | 41 | else if (p.weakpunch) 42 | { 43 | nextState = State::NewState(_ownerObj); 44 | } 45 | } 46 | 47 | std::vector& GetColliders() override { static std::vector vec; return vec; } 48 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 49 | }; 50 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Prep_Back.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Jump_Up_Back; 7 | 8 | class Fighter_0_Jump_Prep_Back : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Jump_Prep_Back() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_prep_back.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_prep_back.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 20 | animationController.status.nTransitionDelay = 4; 21 | animationController.status.bPlayOnce = true; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | if (stateUpdateCount >= 3) 34 | { 35 | nextState = State::NewState(_ownerObj); 36 | } 37 | } 38 | 39 | std::vector& GetColliders() override { static std::vector vec; return vec; } 40 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 41 | }; 42 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Prep_Forward.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Jump_Up_Forward; 7 | 8 | class Fighter_0_Jump_Prep_Forward : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Jump_Prep_Forward() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_prep_forward.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_prep_forward.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 20 | animationController.status.nTransitionDelay = 4; 21 | animationController.status.bPlayOnce = true; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | if (stateUpdateCount >= 3) 34 | { 35 | nextState = State::NewState(_ownerObj); 36 | } 37 | } 38 | 39 | std::vector& GetColliders() override { static std::vector vec; return vec; } 40 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 41 | }; 42 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Prep_Vertical.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Jump_Up_Vertical; 7 | 8 | class Fighter_0_Jump_Prep_Vertical : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Jump_Prep_Vertical() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_prep_vertical.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_prep_vertical.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 20 | animationController.status.nTransitionDelay = 4; 21 | animationController.status.bPlayOnce = true; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | if (stateUpdateCount >= 3) 34 | { 35 | nextState = State::NewState(_ownerObj); 36 | } 37 | } 38 | 39 | std::vector& GetColliders() override { static std::vector vec; return vec; } 40 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 41 | }; 42 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Up_Back.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_Fall; 8 | 9 | class Fighter_0_Jump_Up_Back : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_Jump_Up_Back() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_up_back.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_up_back.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 1200, 200, 3, 1, 3); 21 | animationController.status.nTransitionDelay = 6; 22 | animationController.status.bPlayOnce = true; 23 | } 24 | 25 | void OnEnter() override 26 | { 27 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 28 | 29 | JumpSpecs jumpSpecs(15, 4, 3, true, true, true); 30 | 31 | _ownerObj->objData.CreateNewJumpCalculator(); 32 | _ownerObj->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 33 | } 34 | 35 | void OnUpdate() override 36 | { 37 | UpdateColliderParts(); 38 | 39 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 40 | 41 | if (_ownerObj->objData.GetPosition().y >= 0 && stateUpdateCount != 0) 42 | { 43 | nextState = State::NewState(_ownerObj); 44 | } 45 | 46 | else if (_ownerObj->objData.ptrJumpCalculator != nullptr) 47 | { 48 | if (_ownerObj->objData.ptrJumpCalculator->GetUpForce() <= 0) 49 | { 50 | nextState = State::NewState(_ownerObj); 51 | } 52 | } 53 | 54 | else if (p.weakpunch) 55 | { 56 | nextState = State::NewState(_ownerObj); 57 | } 58 | } 59 | 60 | std::vector& GetColliders() override { static std::vector vec; return vec; } 61 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 62 | }; 63 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Up_Forward.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_Fall; 8 | 9 | class Fighter_0_Jump_Up_Forward : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_Jump_Up_Forward() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_up_forward.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_up_forward.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 1200, 200, 3, 1, 3); 21 | animationController.status.nTransitionDelay = 6; 22 | animationController.status.bPlayOnce = true; 23 | } 24 | 25 | void OnEnter() override 26 | { 27 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 28 | 29 | JumpSpecs jumpSpecs(15, 5, 3, true, false, true); 30 | 31 | _ownerObj->objData.CreateNewJumpCalculator(); 32 | _ownerObj->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 33 | } 34 | 35 | void OnUpdate() override 36 | { 37 | UpdateColliderParts(); 38 | 39 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 40 | 41 | if (_ownerObj->objData.GetPosition().y >= 0 && stateUpdateCount != 0) 42 | { 43 | nextState = State::NewState(_ownerObj); 44 | } 45 | 46 | else if (_ownerObj->objData.ptrJumpCalculator != nullptr) 47 | { 48 | if (_ownerObj->objData.ptrJumpCalculator->GetUpForce() <= 0) 49 | { 50 | nextState = State::NewState(_ownerObj); 51 | } 52 | } 53 | 54 | else if (p.weakpunch) 55 | { 56 | nextState = State::NewState(_ownerObj); 57 | } 58 | } 59 | 60 | std::vector& GetColliders() override { static std::vector vec; return vec; } 61 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 62 | }; 63 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_Up_Vertical.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_Fall; 8 | class Fighter_0_Jump_WeakPunch; 9 | 10 | class Fighter_0_Jump_Up_Vertical : public State 11 | { 12 | protected: 13 | size_t& Hash() override { static size_t hash = 0; return hash; } 14 | 15 | public: 16 | Fighter_0_Jump_Up_Vertical() 17 | { 18 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_up_vertical.png"); 19 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_up_vertical.collider"); 20 | 21 | animationController.SetParams(SpriteType::FIGHTER_0, 1200, 200, 3, 1, 3); 22 | animationController.status.nTransitionDelay = 6; 23 | animationController.status.bPlayOnce = true; 24 | } 25 | 26 | void OnEnter() override 27 | { 28 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 29 | 30 | JumpSpecs jumpSpecs(15, 0, 0, false, false, true); 31 | 32 | _ownerObj->objData.CreateNewJumpCalculator(); 33 | _ownerObj->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 34 | } 35 | 36 | void OnUpdate() override 37 | { 38 | UpdateColliderParts(); 39 | 40 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 41 | 42 | if (_ownerObj->objData.GetPosition().y >= 0 && stateUpdateCount != 0) 43 | { 44 | nextState = State::NewState(_ownerObj); 45 | } 46 | 47 | else if (_ownerObj->objData.ptrJumpCalculator != nullptr) 48 | { 49 | if (_ownerObj->objData.ptrJumpCalculator->GetUpForce() <= 0) 50 | { 51 | nextState = State::NewState(_ownerObj); 52 | } 53 | } 54 | 55 | else if (p.weakpunch) 56 | { 57 | nextState = State::NewState(_ownerObj); 58 | } 59 | } 60 | 61 | std::vector& GetColliders() override { static std::vector vec; return vec; } 62 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 63 | }; 64 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Jump_WeakPunch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_Jump_WeakPunch : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Jump_WeakPunch() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_jump_weakpunch.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_jump_weakpunch.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 400, 200, 1, 1, 1); 20 | animationController.status.bPlayOnce = true; 21 | 22 | CheckCollisionMessage c0; 23 | 24 | c0.vecBodies.push_back(BodyType::LEFT_HAND); 25 | c0.vecBodies.push_back(BodyType::LEFT_KNEE); 26 | c0.vecBodies.push_back(BodyType::LEFT_LOWERLEG); 27 | c0.animationTile = 0; 28 | 29 | bodyToBodyCollisions.vecCheckCollisions.push_back(c0); 30 | 31 | bodyToBodyCollisions.maxCollisions = 1; 32 | } 33 | 34 | void OnEnter() override 35 | { 36 | _ownerObj->objData.SetSpriteSize({ 420, 230 }); 37 | } 38 | 39 | void OnUpdate() override 40 | { 41 | UpdateColliderParts(); 42 | 43 | if (_ownerObj->objData.GetPosition().y >= 0 && stateUpdateCount != 0) 44 | { 45 | nextState = State::NewState(_ownerObj); 46 | } 47 | } 48 | 49 | std::vector& GetColliders() override { static std::vector vec; return vec; } 50 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 51 | }; 52 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_Uppercut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | 8 | class Fighter_0_Uppercut : public State 9 | { 10 | protected: 11 | size_t& Hash() override { static size_t hash = 0; return hash; } 12 | 13 | public: 14 | Fighter_0_Uppercut() 15 | { 16 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_uppercut.png"); 17 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_uppercut.collider"); 18 | 19 | animationController.SetParams(SpriteType::FIGHTER_0, 4000, 200, 10, 1, 10); 20 | animationController.status.nTransitionDelay = 5; 21 | 22 | CheckCollisionMessage c0; 23 | CheckCollisionMessage c1; 24 | 25 | c0.vecBodies.push_back(BodyType::RIGHT_FOREARM); 26 | c0.vecBodies.push_back(BodyType::RIGHT_HAND); 27 | c0.animationTile = 4; 28 | c0.damageData.upPush = 14; 29 | c0.damageData.sidePush = 2; 30 | 31 | c1.vecBodies.push_back(BodyType::RIGHT_FOREARM); 32 | c1.vecBodies.push_back(BodyType::RIGHT_HAND); 33 | c1.animationTile = 5; 34 | c1.damageData.upPush = 14; 35 | c1.damageData.sidePush = 2; 36 | 37 | bodyToBodyCollisions.vecCheckCollisions.push_back(c0); 38 | bodyToBodyCollisions.vecCheckCollisions.push_back(c1); 39 | 40 | bodyToBodyCollisions.maxCollisions = 1; 41 | } 42 | 43 | void OnEnter() override 44 | { 45 | _ownerObj->objData.SetSpriteSize({ 450, 250 }); 46 | } 47 | 48 | void OnUpdate() override 49 | { 50 | UpdateColliderParts(); 51 | 52 | size_t end = ((size_t)animationController.GetTotalTiles() - (size_t)1) * (size_t)animationController.status.nTransitionDelay; 53 | 54 | if (stateUpdateCount >= end) 55 | { 56 | nextState = State::NewState(_ownerObj); 57 | } 58 | } 59 | 60 | std::vector& GetColliders() override { static std::vector vec; return vec; } 61 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 62 | }; 63 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_WalkBack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_Prep_Back; 8 | 9 | class Fighter_0_WalkBack : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_WalkBack() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_walkback.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_walkback.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 2400, 200, 6, 1, 6); 21 | animationController.status.nTransitionDelay = 5; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 34 | Directions d = Directions::Get(_ownerObj->objData.IsFacingRight(), p); 35 | 36 | if (d.up) 37 | { 38 | nextState = State::NewState( _ownerObj); 39 | } 40 | 41 | else if (d.back) 42 | { 43 | int32_t speed = Directions::GetBackSpeed(_ownerObj->objData.IsFacingRight(), 2); 44 | 45 | olc::vi2d pos = _ownerObj->objData.GetPosition(); 46 | pos.x += speed; 47 | _ownerObj->objData.SetPosition(pos); 48 | } 49 | 50 | else 51 | { 52 | nextState = State::NewState(_ownerObj); 53 | } 54 | } 55 | 56 | std::vector& GetColliders() override { static std::vector vec; return vec; } 57 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 58 | }; 59 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_0_WalkForward.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_0_Idle; 7 | class Fighter_0_Jump_Prep_Forward; 8 | 9 | class Fighter_0_WalkForward : public State 10 | { 11 | protected: 12 | size_t& Hash() override { static size_t hash = 0; return hash; } 13 | 14 | public: 15 | Fighter_0_WalkForward() 16 | { 17 | animationController.SetSpritePath("PNG files/Fighter_0/fighter_0_walk.png"); 18 | animationController.SetColliderFile("BoxColliderData/Fighter_0/fighter_0_walk.collider"); 19 | 20 | animationController.SetParams(SpriteType::FIGHTER_0, 2400, 200, 6, 1, 6); 21 | animationController.status.nTransitionDelay = 5; 22 | } 23 | 24 | void OnEnter() override 25 | { 26 | _ownerObj->objData.SetSpriteSize({ 400, 230 }); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | UpdateColliderParts(); 32 | 33 | PlayerInput p = PlayerInput::Get(_ownerObj->objData.GetPlayerType()); 34 | Directions d = Directions::Get(_ownerObj->objData.IsFacingRight(), p); 35 | 36 | if (d.up) 37 | { 38 | nextState = State::NewState(_ownerObj); 39 | } 40 | 41 | else if (d.forward) 42 | { 43 | int32_t speed = Directions::GetForwardSpeed(_ownerObj->objData.IsFacingRight(), 2); 44 | 45 | olc::vi2d pos = _ownerObj->objData.GetPosition(); 46 | pos.x += speed; 47 | _ownerObj->objData.SetPosition(pos); 48 | } 49 | 50 | else 51 | { 52 | nextState = State::NewState(_ownerObj); 53 | } 54 | } 55 | 56 | void OnAnimationUpdate() override 57 | { 58 | //could update on animation 59 | } 60 | 61 | std::vector& GetColliders() override { static std::vector vec; return vec; } 62 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 63 | }; 64 | } -------------------------------------------------------------------------------- /FightingGameProject/Fighter_1_Idle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Fighter_1_Idle : public State 7 | { 8 | protected: 9 | size_t& Hash() override { static size_t hash = 0; return hash; } 10 | 11 | public: 12 | Fighter_1_Idle() 13 | { 14 | animationController.SetSpritePath("PNG files/Fighter_1/fighter_1_idle.png"); 15 | 16 | animationController.SetParams(SpriteType::FIGHTER_1, 1080, 180, 6, 1, 6); 17 | animationController.status.nTransitionDelay = 12; 18 | } 19 | 20 | void OnEnter() override 21 | { 22 | _ownerObj->objData.SetSpriteSize({ 180, 180 }); 23 | } 24 | 25 | void OnUpdate() override 26 | { 27 | 28 | } 29 | }; 30 | } -------------------------------------------------------------------------------- /FightingGameProject/FightersFixedUpdater.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ObjGroup.h" 4 | #include "Updater.h" 5 | #include "InputBuffer.h" 6 | #include "IGroupComponent.h" 7 | 8 | namespace RB 9 | { 10 | class FightersFixedUpdater : public Updater 11 | { 12 | private: 13 | ObjGroup* _fighters = nullptr; 14 | std::vector* _vecUpdateComponents; 15 | 16 | public: 17 | FightersFixedUpdater(ObjGroup* fighters, std::vector* updateComponents) 18 | { 19 | _fighters = fighters; 20 | 21 | _vecUpdateComponents = updateComponents; 22 | } 23 | 24 | void CustomUpdate() override 25 | { 26 | if (_stopCount > 0) 27 | { 28 | _stopCount--; 29 | } 30 | else 31 | { 32 | RunUpdate(); 33 | } 34 | } 35 | 36 | void RunUpdate() 37 | { 38 | InputBuffer::ptr->AddInputs(); 39 | std::vector& vecFighters = *_fighters->GetVecObjs(); 40 | 41 | for (size_t i = 0; i < vecFighters.size(); i++) 42 | { 43 | vecFighters[i]->objData.SetPreviousPosition(vecFighters[i]->objData.GetPosition()); 44 | } 45 | 46 | for (size_t i = 0; i < (*_vecUpdateComponents).size(); i++) 47 | { 48 | (*_vecUpdateComponents)[i]->Update(); 49 | } 50 | 51 | for (size_t i = 0; i < vecFighters.size(); i++) 52 | { 53 | vecFighters[i]->GetStateController()->MakeStateTransition(); 54 | 55 | State* state = vecFighters[i]->GetCurrentState(); 56 | 57 | if (state != nullptr) 58 | { 59 | state->RunUpdateProcess(); 60 | } 61 | 62 | vecFighters[i]->collisionData.moveSegments->SetSegments(); 63 | } 64 | 65 | _fighters->UpdateSpriteTileIndex(); 66 | 67 | ProcessStopCounts(); 68 | UpdateUpdateCount(); 69 | } 70 | }; 71 | } -------------------------------------------------------------------------------- /FightingGameProject/FightersGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "FightersGroup.h" 2 | 3 | namespace RB 4 | { 5 | FightersGroup::FightersGroup(Camera* camera) 6 | { 7 | _camera = camera; 8 | _preloadFighter0 = new Preload_Fighter_0(); 9 | 10 | _vecUpdateComponents.push_back(new FighterDirection(&_vecObjs)); 11 | _vecUpdateComponents.push_back(new FighterJump(&_vecObjs)); 12 | _vecUpdateComponents.push_back(new FighterGroundToGroundCollision(&_vecObjs)); 13 | _vecUpdateComponents.push_back(new SpecialMoveProcessor(&_vecObjs)); 14 | 15 | _vecRenderComponents.push_back(new AnimationRenderer(&_vecObjs, _camera)); 16 | _vecRenderComponents.push_back(new PreviousPositionRenderer(&_vecObjs, _camera)); 17 | 18 | _inputBufferRenderer = new InputBufferRenderer(); 19 | 20 | _updater = new FightersFixedUpdater(this, &_vecUpdateComponents); 21 | 22 | FightersHitStopMessage::SetReceiver(_updater); 23 | } 24 | 25 | FightersGroup::~FightersGroup() 26 | { 27 | if (_vecObjs.size() != 0) 28 | { 29 | IF_COUT{ std::cout << std::endl; }; 30 | 31 | for (size_t i = 0; i < _vecObjs.size(); i++) 32 | { 33 | IF_COUT{ std::cout << "destructing fighter: " << i << std::endl; }; 34 | delete _vecObjs[i]; 35 | } 36 | 37 | IF_COUT{ std::cout << std::endl; }; 38 | } 39 | 40 | for (size_t i = 0; i < _vecUpdateComponents.size(); i++) 41 | { 42 | delete _vecUpdateComponents[i]; 43 | } 44 | 45 | for (size_t i = 0; i < _vecRenderComponents.size(); i++) 46 | { 47 | delete _vecRenderComponents[i]; 48 | } 49 | 50 | delete _inputBufferRenderer; 51 | delete _preloadFighter0; 52 | delete _updater; 53 | } 54 | 55 | void FightersGroup::UpdateStates() 56 | { 57 | _updater->CustomUpdate(); 58 | } 59 | 60 | void FightersGroup::RenderStates() 61 | { 62 | for (size_t i = 0; i < _vecRenderComponents.size(); i++) 63 | { 64 | _vecRenderComponents[i]->Update(); 65 | } 66 | } 67 | 68 | void FightersGroup::UpdateSpriteTileIndex() 69 | { 70 | for (size_t i = 0; i < _vecObjs.size(); i++) 71 | { 72 | if (_vecObjs[i] != nullptr) 73 | { 74 | _vecObjs[i]->GetCurrentState()->animationController.NextTileIndex(); 75 | } 76 | } 77 | } 78 | 79 | void FightersGroup::RenderObjPosition() 80 | { 81 | for (size_t i = 0; i < _vecObjs.size(); i++) 82 | { 83 | ObjBase& obj = *_vecObjs[i]; 84 | 85 | obj.RenderPosition(*_camera); 86 | obj.collisionData.objBoxCollider.Render(*_camera, obj.objData.GetPosition(), olc::GREEN); 87 | 88 | if (obj.GetCurrentState() != nullptr) 89 | { 90 | CheckCollisionMessage* check = obj.GetCurrentState()->GetCheckCollisionMessage(); 91 | 92 | if (check) 93 | { 94 | for (size_t c = 0; c < check->vecBodies.size(); c++) 95 | { 96 | obj.RenderCollisionTiming(check->vecBodies[c], *_camera); 97 | } 98 | } 99 | } 100 | } 101 | 102 | _inputBufferRenderer->Update(); 103 | } 104 | 105 | void FightersGroup::RenderBoxColliders() 106 | { 107 | for (int32_t i = 0; i < _vecObjs.size(); i++) 108 | { 109 | _vecObjs[i]->GetCurrentState()->RenderColliderQuads(*_camera); 110 | } 111 | } 112 | 113 | void FightersGroup::CreateFighterObj(olc::vi2d _startingPos, PlayerType _playerType) 114 | { 115 | _vecObjs.push_back(new GameObj()); 116 | _vecObjs.back()->objData.SetCreationID(_vecObjs.size()); 117 | _vecObjs.back()->objData.SetOffsetType(OffsetType::BOTTOM_CENTER); 118 | _vecObjs.back()->objData.SetPosition(_startingPos); 119 | _vecObjs.back()->objData.SetPlayerType(_playerType); 120 | } 121 | } -------------------------------------------------------------------------------- /FightingGameProject/FightersGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "ObjGroup.h" 5 | #include "FightersFixedUpdater.h" 6 | #include "FightersHitStopMessage.h" 7 | 8 | //update components 9 | #include "FighterDirection.h" 10 | #include "FighterJump.h" 11 | #include "FighterGroundToGroundCollision.h" 12 | #include "SpecialMoveProcessor.h" 13 | #include "InputBufferRenderer.h" 14 | 15 | //render components 16 | #include "AnimationRenderer.h" 17 | #include "PreviousPositionRenderer.h" 18 | 19 | //loading (temp) 20 | #include "Preload_Fighter_0.h" 21 | 22 | namespace RB 23 | { 24 | class FightersGroup : public ObjGroup 25 | { 26 | private: 27 | std::vector _vecUpdateComponents; 28 | std::vector _vecRenderComponents; 29 | 30 | IGroupComponent* _inputBufferRenderer = nullptr; 31 | 32 | Preload_Fighter_0* _preloadFighter0 = nullptr; 33 | 34 | RandomInteger randomInteger; 35 | 36 | public: 37 | FightersGroup(Camera* camera); 38 | ~FightersGroup(); 39 | 40 | void UpdateStates() override; 41 | void RenderStates() override; 42 | void UpdateSpriteTileIndex() override; 43 | 44 | void RenderObjPosition() override; 45 | void RenderBoxColliders() override; 46 | 47 | void CreateFighterObj(olc::vi2d _startingPos, PlayerType _playerType); 48 | }; 49 | } -------------------------------------------------------------------------------- /FightingGameProject/FightersHitStopMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "FightersHitStopMessage.h" 2 | 3 | namespace RB 4 | { 5 | Updater* FightersHitStopMessage::_fightersFixedUpdater = nullptr; 6 | } -------------------------------------------------------------------------------- /FightingGameProject/FightersHitStopMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HitStopMessage.h" 3 | #include "Updater.h" 4 | 5 | namespace RB 6 | { 7 | class FightersHitStopMessage : public HitStopMessage 8 | { 9 | private: 10 | static Updater* _fightersFixedUpdater; 11 | 12 | public: 13 | static void SetReceiver(Updater* fixedUpdater) 14 | { 15 | _fightersFixedUpdater = fixedUpdater; 16 | } 17 | 18 | void Register(int32_t stopCount) override 19 | { 20 | StopCountData data; 21 | data.stopCount = stopCount; 22 | _fightersFixedUpdater->AddStopCountQueue(data); 23 | } 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define OLC_PGE_APPLICATION 0 3 | #include "olcPixelGameEngine.h" 4 | #include "Timer.h" 5 | #include "SceneController.h" 6 | #include "GameSettings.h" 7 | #include "Input.h" 8 | 9 | namespace RB 10 | { 11 | class Game : public olc::PixelGameEngine 12 | { 13 | private: 14 | InputBuffer inputBuffer; 15 | Timer timer; 16 | 17 | Input* _input = nullptr; 18 | SceneController* _sceneController = nullptr; 19 | 20 | public: 21 | ~Game() 22 | { 23 | IF_COUT{ std::cout << std::endl; }; 24 | IF_COUT{ std::cout << "destructing Game" << std::endl; }; 25 | 26 | delete _input; 27 | delete _sceneController; 28 | } 29 | 30 | bool OnUserCreate() override 31 | { 32 | sAppName = "C++FightingGame"; 33 | 34 | InputBuffer::ptr = &inputBuffer; 35 | 36 | _input = new Input(); 37 | _sceneController = new SceneController(); 38 | 39 | _sceneController->Load(); 40 | _sceneController->CreateScene(GameSettings::startingScene); 41 | 42 | return true; 43 | } 44 | 45 | bool OnUserUpdate(float fElapsedTime) override 46 | { 47 | olc::Pixel grayBackground(20, 20, 20); 48 | Clear(grayBackground); 49 | 50 | InputData::ResetInputData(); 51 | 52 | _input->UpdateInput(); 53 | 54 | if (timer.UpdateTime(fElapsedTime)) 55 | { 56 | _input->UpdateGameData(); 57 | 58 | DevSettings::UpdateDebugBoxSettings(); 59 | GameSettings::UpdateTargetFrame(); 60 | 61 | _sceneController->ChangeScene(); 62 | _sceneController->currentScene->_cam->Update(); 63 | _sceneController->currentScene->UpdateScene(); 64 | _sceneController->currentScene->RenderStates(); 65 | 66 | //only clear after update 67 | _input->ClearKeyQueues(); 68 | 69 | inputBuffer.Update(); 70 | } 71 | else 72 | { 73 | _sceneController->currentScene->RenderStates(); 74 | } 75 | 76 | _sceneController->currentScene->RenderObjs(); 77 | timer.ShowUpdateCount(); 78 | 79 | if (DevSettings::renderMode == RenderMode::DEBUG_ONLY) 80 | { 81 | olc::Renderer::ptrPGE->DrawString({ 0, 28 }, "render mode: debug only"); 82 | } 83 | else if (DevSettings::renderMode == RenderMode::SPRITES_ONLY) 84 | { 85 | olc::Renderer::ptrPGE->DrawString({ 0, 28 }, "render mode: sprites only"); 86 | } 87 | else if (DevSettings::renderMode == RenderMode::SPRITES_AND_DEBUG) 88 | { 89 | olc::Renderer::ptrPGE->DrawString({ 0, 28 }, "render mode: sprites and debug"); 90 | } 91 | 92 | return true; 93 | } 94 | 95 | void Run() 96 | { 97 | if (Construct(GameSettings::window_width, GameSettings::window_height, 1, 1)) 98 | { 99 | Start(); 100 | } 101 | } 102 | }; 103 | } -------------------------------------------------------------------------------- /FightingGameProject/GameObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ObjBase.h" 3 | #include "StateController.h" 4 | #include "Camera.h" 5 | #include "BodyType.h" 6 | #include "ScreenVector.h" 7 | #include "DevSettings.h" 8 | 9 | namespace RB 10 | { 11 | class GameObj : public ObjBase 12 | { 13 | private: 14 | StateController* _stateController = nullptr; 15 | 16 | public: 17 | GameObj(); 18 | ~GameObj(); 19 | 20 | State* GetCurrentState() override; 21 | bool SetNextState(State* ptrState) override; 22 | void SetCurrentState(State* state) override; 23 | 24 | StateController* GetStateController() override; 25 | 26 | void RenderPosition(Camera& cam) override; 27 | void RenderSpriteSize(Camera& cam) override; 28 | void RenderCollisionTiming(BodyType _bodyType, Camera& cam) override; 29 | 30 | olc::vi2d GetBodyWorldPos(BodyType bodyType) override; 31 | std::array GetBodyWorldQuad(BodyType bodyType) override; 32 | 33 | olc::vi2d GetBoxColliderWorldPos() override; 34 | std::array GetBoxColliderWorldQuad() override; 35 | }; 36 | } -------------------------------------------------------------------------------- /FightingGameProject/GameSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "GameSettings.h" 2 | 3 | namespace RB 4 | { 5 | const int32_t GameSettings::window_width = 854; 6 | const int32_t GameSettings::window_height = 480; 7 | const SceneType GameSettings::startingScene = SceneType::FIGHT_SCENE; 8 | 9 | float GameSettings::TargetFrameTime(ChangeTimer _change) 10 | { 11 | static float target = 1.0f / 80.0f; 12 | 13 | if (_change == ChangeTimer::NONE) 14 | { 15 | // do nothing 16 | } 17 | else if (_change == ChangeTimer::HALF) 18 | { 19 | target *= 0.5f; 20 | } 21 | else if (_change == ChangeTimer::DOUBLE) 22 | { 23 | target *= 2.0f; 24 | } 25 | 26 | return target; 27 | } 28 | 29 | void GameSettings::UpdateTargetFrame() 30 | { 31 | InputData& inputData = *InputData::ptr; 32 | 33 | if (inputData.key_f9) 34 | { 35 | inputData.key_f9->processed = true; 36 | TargetFrameTime(ChangeTimer::DOUBLE); 37 | } 38 | 39 | if (inputData.key_f10) 40 | { 41 | inputData.key_f10->processed = true; 42 | TargetFrameTime(ChangeTimer::HALF); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /FightingGameProject/GameSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "SceneType.h" 4 | #include "InputData.h" 5 | 6 | namespace RB 7 | { 8 | enum class ChangeTimer 9 | { 10 | NONE, 11 | HALF, 12 | DOUBLE, 13 | }; 14 | 15 | class GameSettings 16 | { 17 | public: 18 | const static int32_t window_width; 19 | const static int32_t window_height; 20 | const static SceneType startingScene; 21 | 22 | static float TargetFrameTime(ChangeTimer _change); 23 | static void UpdateTargetFrame(); 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/Hadouken.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "SpecialMove.h" 4 | 5 | namespace RB 6 | { 7 | class Hadouken : public SpecialMove 8 | { 9 | private: 10 | std::array arr = { 11 | ConvertedInputType::DOWN, 12 | ConvertedInputType::DOWN_FORWARD, 13 | ConvertedInputType::FORWARD, 14 | ConvertedInputType::WEAK_PUNCH 15 | }; 16 | 17 | public: 18 | void Check(InputElement& _inputElement, size_t bufferIndex, ObjData& objData) override 19 | { 20 | if (currIndex < arr.size()) 21 | { 22 | if (!_inputElement.processed) 23 | { 24 | ConvertedInputType converted = GetConvert(_inputElement.inputType, objData); 25 | 26 | if (converted == arr[currIndex]) 27 | { 28 | correctBuffers.push_back(bufferIndex); 29 | currIndex++; 30 | } 31 | } 32 | } 33 | } 34 | 35 | bool IsMatching() override 36 | { 37 | if (currIndex >= arr.size()) 38 | { 39 | return true; 40 | } 41 | else 42 | { 43 | return false; 44 | } 45 | } 46 | }; 47 | } -------------------------------------------------------------------------------- /FightingGameProject/Hadouken_MoveForward.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class Hadouken_MoveForward : public State 7 | { 8 | protected: 9 | size_t& Hash() override { static size_t hash = 0; return hash; } 10 | 11 | public: 12 | Hadouken_MoveForward() 13 | { 14 | animationController.SetSpritePath("PNG files/Projectiles/hadouken_ball.png"); 15 | animationController.SetParams(SpriteType::PROJECTILES, 78, 46, 1, 1, 1); 16 | } 17 | 18 | void OnEnter() override 19 | { 20 | _ownerObj->objData.SetOffsetType(OffsetType::CENTER_CENTER); 21 | _ownerObj->objData.SetSpriteSize({ 78, 46 }); 22 | 23 | _ownerObj->collisionData.objBoxCollider.SetWidth(80); 24 | _ownerObj->collisionData.objBoxCollider.SetHeight(60); 25 | _ownerObj->collisionData.objBoxCollider.SetQuad(OffsetType::CENTER_CENTER); 26 | _ownerObj->collisionData.objBoxCollider.UpdateRotation(); 27 | } 28 | 29 | void OnUpdate() override 30 | { 31 | int32_t speed = Directions::GetForwardSpeed(_ownerObj->objData.IsFacingRight(), 4); 32 | 33 | olc::vi2d pos = _ownerObj->objData.GetPosition(); 34 | pos.x += speed; 35 | _ownerObj->objData.SetPosition(pos); 36 | } 37 | 38 | std::vector& GetColliders() override { static std::vector vec; return vec; } 39 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 40 | }; 41 | } -------------------------------------------------------------------------------- /FightingGameProject/HitStopMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | class HitStopMessage 7 | { 8 | public: 9 | virtual void Register(int32_t stopCount) = 0; 10 | }; 11 | } -------------------------------------------------------------------------------- /FightingGameProject/IGroupComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | class IGroupComponent 6 | { 7 | public: 8 | virtual void Update() = 0; 9 | }; 10 | } -------------------------------------------------------------------------------- /FightingGameProject/ImpactEffect_Hit_0.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | 4 | namespace RB 5 | { 6 | class ImpactEffect_Hit_0 : public State 7 | { 8 | protected: 9 | size_t& Hash() override { static size_t hash = 0; return hash; } 10 | 11 | public: 12 | ImpactEffect_Hit_0() 13 | { 14 | animationController.SetSpritePath("PNG files/ImpactEffects/hiteffect_0.png"); 15 | animationController.SetParams(SpriteType::IMPACT_EFFECTS, 1840, 384, 5, 1, 5); 16 | animationController.status.nTransitionDelay = 4; 17 | } 18 | 19 | void OnEnter() override 20 | { 21 | _ownerObj->objData.SetOffsetType(OffsetType::CENTER_CENTER); 22 | 23 | float originalWidth = 368.0f; 24 | float originalHeight = 384.0f; 25 | 26 | int32_t roundedW = (int32_t)std::round(originalWidth * 0.7f); 27 | int32_t roundedH = (int32_t)std::round(originalHeight * 0.7f); 28 | 29 | _ownerObj->objData.SetSpriteSize({ roundedW, roundedH }); 30 | } 31 | 32 | void OnUpdate() override 33 | { 34 | 35 | } 36 | 37 | std::vector& GetColliders() override { static std::vector vec; return vec; } 38 | std::vector& GetColliderQuads() override { static std::vector vec; return vec; } 39 | }; 40 | } -------------------------------------------------------------------------------- /FightingGameProject/ImpactEffectsGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "ImpactEffectsGroup.h" 2 | 3 | namespace RB 4 | { 5 | ImpactEffectsGroup::ImpactEffectsGroup(Camera* camera) 6 | { 7 | _camera = camera; 8 | ptrAnimationRenderer = new AnimationRenderer(&_vecObjs, _camera); 9 | } 10 | 11 | ImpactEffectsGroup::~ImpactEffectsGroup() 12 | { 13 | delete ptrAnimationRenderer; 14 | 15 | if (_vecObjs.size() != 0) 16 | { 17 | IF_COUT{ std::cout << std::endl; }; 18 | 19 | for (size_t i = 0; i < _vecObjs.size(); i++) 20 | { 21 | if (_vecObjs[i] != nullptr) 22 | { 23 | IF_COUT{ std::cout << "destructing effect: " << _vecObjs[i]->objData.GetCreationID() << std::endl; }; 24 | delete _vecObjs[i]; 25 | } 26 | } 27 | 28 | IF_COUT{ std::cout << std::endl; }; 29 | } 30 | } 31 | 32 | void ImpactEffectsGroup::UpdateStates() 33 | { 34 | for (size_t i = 0; i < _vecObjs.size(); i++) 35 | { 36 | if (_vecObjs[i] != nullptr) 37 | { 38 | ObjBase& obj = *_vecObjs[i]; 39 | State* state = _vecObjs[i]->GetCurrentState(); 40 | 41 | if (state != nullptr) 42 | { 43 | state->RunUpdateProcess(); 44 | 45 | size_t end = (size_t)state->animationController.GetTotalTiles() * (size_t)state->animationController.status.nTransitionDelay; 46 | 47 | if (state->stateUpdateCount >= end - (size_t)1) 48 | { 49 | delete _vecObjs[i]; 50 | _vecObjs[i] = nullptr; 51 | } 52 | } 53 | } 54 | } 55 | 56 | for (size_t i = 0; i < _vecObjs.size(); i++) 57 | { 58 | if (_vecObjs[i] == nullptr) 59 | { 60 | _vecObjs.erase(_vecObjs.begin() + i); 61 | break; 62 | } 63 | } 64 | 65 | UpdateSpriteTileIndex(); 66 | }; 67 | 68 | void ImpactEffectsGroup::RenderObjPosition() 69 | { 70 | 71 | }; 72 | 73 | void ImpactEffectsGroup::RenderStates() 74 | { 75 | ptrAnimationRenderer->Update(); 76 | }; 77 | 78 | void ImpactEffectsGroup::RenderBoxColliders() 79 | { 80 | 81 | }; 82 | 83 | void ImpactEffectsGroup::CreateObj(ObjType objType, olc::vi2d startPos) 84 | { 85 | ObjBase* obj = new GameObj(); 86 | _vecObjs.push_back(obj); 87 | _vecObjs.back()->objData.SetCreationID(_vecObjs.size()); 88 | 89 | if (objType == ObjType::HIT_EFFECT_0) 90 | { 91 | obj->SetCurrentState(State::NewState(obj)); 92 | } 93 | 94 | obj->objData.SetPosition(startPos); 95 | } 96 | } -------------------------------------------------------------------------------- /FightingGameProject/ImpactEffectsGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ObjGroup.h" 3 | #include "ObjType.h" 4 | #include "ImpactEffect_Hit_0.h" 5 | 6 | //components 7 | #include "AnimationRenderer.h" 8 | 9 | namespace RB 10 | { 11 | class ImpactEffectsGroup : public ObjGroup 12 | { 13 | private: 14 | AnimationRenderer* ptrAnimationRenderer = nullptr; 15 | 16 | public: 17 | ImpactEffectsGroup(Camera* camera); 18 | ~ImpactEffectsGroup(); 19 | 20 | void UpdateStates() override; 21 | void RenderStates() override; 22 | 23 | void RenderObjPosition() override; 24 | void RenderBoxColliders() override; 25 | 26 | void CreateObj(ObjType objType, olc::vi2d startPos) override; 27 | }; 28 | } -------------------------------------------------------------------------------- /FightingGameProject/InputBuffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/InputBuffer.cpp -------------------------------------------------------------------------------- /FightingGameProject/InputBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "InputElement.h" 4 | #include "DevSettings.h" 5 | 6 | namespace RB 7 | { 8 | class InputBuffer 9 | { 10 | private: 11 | //player1 12 | bool p1_upright = false; 13 | bool p1_downright = false; 14 | bool p1_downleft = false; 15 | bool p1_upleft = false; 16 | 17 | bool p1_left = false; 18 | bool p1_right = false; 19 | bool p1_up = false; 20 | bool p1_down = false; 21 | 22 | bool p1_weakpunch = false; 23 | 24 | //player2 25 | bool p2_upright = false; 26 | bool p2_downright = false; 27 | bool p2_downleft = false; 28 | bool p2_upleft = false; 29 | 30 | bool p2_left = false; 31 | bool p2_right = false; 32 | bool p2_up = false; 33 | bool p2_down = false; 34 | 35 | bool p2_weakpunch = false; 36 | 37 | public: 38 | static InputBuffer* ptr; 39 | 40 | std::vector vecP1Inputs; 41 | std::vector vecP2Inputs; 42 | 43 | void AddInputs(); 44 | void Update(); 45 | bool QuadruplePress(Key* up, Key* down, Key* left, Key* right); 46 | bool TriplePress(Key* up, Key* down, Key* left, Key* right); 47 | void AddInputBuffer( 48 | Key* keyUp, Key* keyDown, Key* keyLeft, Key* keyRight, 49 | Key* keyWeakPunch, 50 | std::vector& vecBuffer, 51 | bool& bUpRight, bool& bDownRight, bool& bDownLeft, bool& bUpLeft, 52 | bool& bLeft, bool& bRight, bool& bUp, bool& bDown, 53 | bool& bWeakPunch); 54 | }; 55 | } -------------------------------------------------------------------------------- /FightingGameProject/InputBufferRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IGroupComponent.h" 3 | #include "UIElement.h" 4 | #include "SpriteType.h" 5 | #include "InputBuffer.h" 6 | 7 | namespace RB 8 | { 9 | class InputBufferRenderer : public IGroupComponent 10 | { 11 | private: 12 | UIElement upleft; 13 | UIElement upright; 14 | UIElement downleft; 15 | UIElement downright; 16 | 17 | UIElement left; 18 | UIElement right; 19 | UIElement down; 20 | UIElement up; 21 | 22 | UIElement punch; 23 | 24 | olc::Decal* GetBufferDecal(InputType inputType) 25 | { 26 | switch (inputType) 27 | { 28 | case InputType::UP_RIGHT: 29 | return upright.ptrDecal; 30 | case InputType::DOWN_RIGHT: 31 | return downright.ptrDecal; 32 | case InputType::DOWN_LEFT: 33 | return downleft.ptrDecal; 34 | case InputType::UP_LEFT: 35 | return upleft.ptrDecal; 36 | 37 | case InputType::LEFT: 38 | return left.ptrDecal; 39 | case InputType::RIGHT: 40 | return right.ptrDecal; 41 | case InputType::DOWN: 42 | return down.ptrDecal; 43 | case InputType::UP: 44 | return up.ptrDecal; 45 | 46 | case InputType::WEAK_PUNCH: 47 | return punch.ptrDecal; 48 | } 49 | 50 | return nullptr; 51 | } 52 | public: 53 | InputBufferRenderer() 54 | { 55 | upleft.path = "PNG files/InputBuffer/upleft.png"; 56 | upleft.spriteType = SpriteType::INPUT_BUFFER; 57 | upleft.SetHash(); 58 | upleft.SetDecal(); 59 | 60 | upright.path = "PNG files/InputBuffer/upright.png"; 61 | upright.spriteType = SpriteType::INPUT_BUFFER; 62 | upright.SetHash(); 63 | upright.SetDecal(); 64 | 65 | downleft.path = "PNG files/InputBuffer/downleft.png"; 66 | downleft.spriteType = SpriteType::INPUT_BUFFER; 67 | downleft.SetHash(); 68 | downleft.SetDecal(); 69 | 70 | downright.path = "PNG files/InputBuffer/downright.png"; 71 | downright.spriteType = SpriteType::INPUT_BUFFER; 72 | downright.SetHash(); 73 | downright.SetDecal(); 74 | 75 | left.path = "PNG files/InputBuffer/left.png"; 76 | left.spriteType = SpriteType::INPUT_BUFFER; 77 | left.SetHash(); 78 | left.SetDecal(); 79 | 80 | right.path = "PNG files/InputBuffer/right.png"; 81 | right.spriteType = SpriteType::INPUT_BUFFER; 82 | right.SetHash(); 83 | right.SetDecal(); 84 | 85 | down.path = "PNG files/InputBuffer/down.png"; 86 | down.spriteType = SpriteType::INPUT_BUFFER; 87 | down.SetHash(); 88 | down.SetDecal(); 89 | 90 | up.path = "PNG files/InputBuffer/up.png"; 91 | up.spriteType = SpriteType::INPUT_BUFFER; 92 | up.SetHash(); 93 | up.SetDecal(); 94 | 95 | punch.path = "PNG files/InputBuffer/punch.png"; 96 | punch.spriteType = SpriteType::INPUT_BUFFER; 97 | punch.SetHash(); 98 | punch.SetDecal(); 99 | 100 | } 101 | 102 | void Update() override 103 | { 104 | olc::vi2d startPos1(20, 100); 105 | RenderInputBuffer(startPos1, InputBuffer::ptr->vecP1Inputs); 106 | 107 | olc::vi2d startPos2(20, 150); 108 | RenderInputBuffer(startPos2, InputBuffer::ptr->vecP2Inputs); 109 | } 110 | 111 | void RenderInputBuffer(olc::vi2d& startPos, std::vector& vecInputs) 112 | { 113 | for (size_t i = 0; i < vecInputs.size(); i++) 114 | { 115 | olc::vf2d pos(0, 0); 116 | pos.x += ((20 * i) + (8 * i)); 117 | pos += startPos; 118 | 119 | std::array points; 120 | 121 | points[0] = { 0, 0 }; 122 | points[1] = { 0, 20 }; 123 | points[2] = { 20, 20 }; 124 | points[3] = { 20, 0 }; 125 | 126 | points[0] += pos; 127 | points[1] += pos; 128 | points[2] += pos; 129 | points[3] += pos; 130 | 131 | olc::Decal* d = GetBufferDecal(vecInputs[i].inputType); 132 | 133 | if (d != nullptr) 134 | { 135 | if (vecInputs[i].inputType == InputType::WEAK_PUNCH) 136 | { 137 | olc::Renderer::ptrPGE->DrawWarpedDecal(d, points, olc::MAGENTA); 138 | } 139 | else 140 | { 141 | olc::Renderer::ptrPGE->DrawWarpedDecal(d, points, olc::RED); 142 | } 143 | } 144 | } 145 | } 146 | }; 147 | } -------------------------------------------------------------------------------- /FightingGameProject/InputData.cpp: -------------------------------------------------------------------------------- 1 | #include "InputData.h" 2 | 3 | namespace RB 4 | { 5 | InputData* InputData::ptr = nullptr; 6 | 7 | Key* InputData::GetWeakPunchKey(PlayerType playerType) 8 | { 9 | if (playerType == PlayerType::PLAYER_1) 10 | { 11 | return key_t; 12 | } 13 | else if (playerType == PlayerType::PLAYER_2) 14 | { 15 | return key_np7; 16 | } 17 | 18 | return nullptr; 19 | } 20 | 21 | void InputData::ResetInputData() 22 | { 23 | if (ptr != nullptr) 24 | { 25 | delete ptr; 26 | } 27 | 28 | ptr = new InputData(); 29 | } 30 | } -------------------------------------------------------------------------------- /FightingGameProject/InputData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SceneType.h" 3 | #include "Key.h" 4 | #include "PlayerType.h" 5 | 6 | namespace RB 7 | { 8 | class InputData 9 | { 10 | public: 11 | static InputData* ptr; 12 | static void ResetInputData(); 13 | 14 | SceneType nextSceneType = SceneType::NONE; 15 | 16 | //get 17 | Key* GetWeakPunchKey(PlayerType playerType); 18 | 19 | //manual camera movement 20 | Key* key_j = nullptr; //cam left 21 | Key* key_l = nullptr; //cam right 22 | Key* key_i = nullptr; //cam zoom 23 | Key* key_k = nullptr; //cam zoom out 24 | 25 | //player1 26 | Key* key_t = nullptr; //weak punch 27 | Key* key_y = nullptr; //strong punch 28 | Key* key_g = nullptr; //weak kick 29 | Key* key_h = nullptr; //strong kick 30 | 31 | Key* key_w = nullptr; //up 32 | Key* key_s = nullptr; //down 33 | Key* key_a = nullptr; //left 34 | Key* key_d = nullptr; //right 35 | 36 | //player2 37 | Key* key_np7 = nullptr; //weak punch 38 | Key* key_np8 = nullptr; //strong punch 39 | Key* key_np4 = nullptr; //weak kick 40 | Key* key_np5 = nullptr; //strong kick 41 | 42 | Key* key_up = nullptr; //up 43 | Key* key_down = nullptr; //down 44 | Key* key_left = nullptr; //left 45 | Key* key_right = nullptr; //right 46 | 47 | //etc 48 | Key* key_mouse0 = nullptr; 49 | Key* key_shift = nullptr; 50 | Key* key_f8 = nullptr; 51 | Key* key_f9 = nullptr; 52 | Key* key_f10 = nullptr; 53 | Key* key_f11 = nullptr; 54 | }; 55 | } -------------------------------------------------------------------------------- /FightingGameProject/InputElement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "InputType.h" 4 | 5 | namespace RB 6 | { 7 | class InputElement 8 | { 9 | public: 10 | InputType inputType; 11 | size_t updateCount = 0; 12 | bool processed = false; 13 | 14 | InputElement(InputType _inputType) 15 | { 16 | inputType = _inputType; 17 | } 18 | }; 19 | } -------------------------------------------------------------------------------- /FightingGameProject/InputType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class InputType 6 | { 7 | RIGHT, 8 | DOWN_RIGHT, 9 | DOWN, 10 | DOWN_LEFT, 11 | LEFT, 12 | UP_LEFT, 13 | UP, 14 | UP_RIGHT, 15 | 16 | WEAK_PUNCH, 17 | STRING_PUNCH, 18 | 19 | WEAK_KICK, 20 | STRONG_KICK, 21 | }; 22 | } -------------------------------------------------------------------------------- /FightingGameProject/JumpCalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "JumpCalculator.h" 2 | 3 | namespace RB 4 | { 5 | JumpCalculator::JumpCalculator() 6 | { 7 | 8 | } 9 | 10 | void JumpCalculator::SetSpecs(JumpSpecs specs) 11 | { 12 | _upForce = specs.mUpForce; 13 | _horizontalForce = specs.mSideForce; 14 | _minimumSideForce = specs.mMinimumSideForce; 15 | 16 | _moveHorizontally = specs.mMoveHorizontally; 17 | _moveBack = specs.mMoveBack; 18 | _allowControl = specs.mAllowControl; 19 | } 20 | 21 | int32_t JumpCalculator::GetUpForce() { return _upForce; } 22 | int32_t JumpCalculator::GetSideForce() { return _horizontalForce; } 23 | bool JumpCalculator::MoveBack() { return _moveBack; } 24 | 25 | void JumpCalculator::UpdateJump(bool upKey, bool forwardKey, bool backKey) 26 | { 27 | //vertical 28 | if (_updateCount % verticalInterval == 0 && _updateCount != 0) 29 | { 30 | //variable up/down speed 31 | if (_allowControl) 32 | { 33 | if (_upForce > 0) 34 | { 35 | if (upKey) 36 | { 37 | _upForce--; 38 | } 39 | else 40 | { 41 | _upForce -= 2; 42 | } 43 | } 44 | else 45 | { 46 | _upForce--; 47 | } 48 | } 49 | //continuous up/down speed 50 | else 51 | { 52 | _upForce--; 53 | } 54 | } 55 | 56 | //horizontal 57 | if (_moveHorizontally) 58 | { 59 | if (_updateCount % horizontalInterval == 0) 60 | { 61 | if (_horizontalForce > 3) 62 | { 63 | //variable side speed 64 | if (_allowControl) 65 | { 66 | //forward 67 | if (!_moveBack) 68 | { 69 | if (forwardKey) 70 | { 71 | _horizontalForce--; 72 | } 73 | else 74 | { 75 | _horizontalForce -= 2; 76 | } 77 | } 78 | //back 79 | else 80 | { 81 | if (backKey) 82 | { 83 | _horizontalForce--; 84 | } 85 | else 86 | { 87 | _horizontalForce -= 2; 88 | } 89 | } 90 | } 91 | } 92 | 93 | if (_horizontalForce <= _minimumSideForce) 94 | { 95 | _horizontalForce = _minimumSideForce; 96 | } 97 | } 98 | } 99 | 100 | _updateCount++; 101 | } 102 | } -------------------------------------------------------------------------------- /FightingGameProject/JumpCalculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "JumpSpecs.h" 5 | 6 | namespace RB 7 | { 8 | class JumpCalculator 9 | { 10 | private: 11 | const int32_t verticalInterval = 2; 12 | const int32_t horizontalInterval = 6; 13 | 14 | size_t _updateCount = 0; 15 | int32_t _upForce = 0; 16 | int32_t _horizontalForce = 0; 17 | int32_t _minimumSideForce = 0; 18 | 19 | bool _moveHorizontally = false; 20 | bool _moveBack = false; 21 | bool _allowControl = false; 22 | 23 | public: 24 | JumpCalculator(); 25 | 26 | void SetSpecs(JumpSpecs jumpSpecs); 27 | 28 | int32_t GetUpForce(); 29 | int32_t GetSideForce(); 30 | bool MoveBack(); 31 | 32 | void UpdateJump(bool upKey, bool forwardKey, bool backKey); 33 | }; 34 | } -------------------------------------------------------------------------------- /FightingGameProject/JumpSpecs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | class JumpSpecs 7 | { 8 | public: 9 | JumpSpecs(int32_t upForce, int32_t sideForce, int32_t minimumSideForce, bool moveHorizontally, bool moveBack, bool allowControl) 10 | { 11 | mUpForce = upForce; 12 | mSideForce = sideForce; 13 | mMinimumSideForce = minimumSideForce; 14 | mMoveHorizontally = moveHorizontally; 15 | mMoveBack = moveBack; 16 | mAllowControl = allowControl; 17 | } 18 | 19 | int32_t mUpForce = 0; 20 | int32_t mSideForce = 0; 21 | int32_t mMinimumSideForce = 0; 22 | 23 | bool mMoveHorizontally = false; 24 | bool mMoveBack = false; 25 | bool mAllowControl = false; 26 | }; 27 | } -------------------------------------------------------------------------------- /FightingGameProject/Key.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "KeyType.h" 3 | 4 | namespace RB 5 | { 6 | class Key 7 | { 8 | public: 9 | KeyType keyType = KeyType::NONE; 10 | bool processed = false; 11 | bool released = false; 12 | }; 13 | } -------------------------------------------------------------------------------- /FightingGameProject/KeyType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class KeyType 6 | { 7 | NONE, 8 | 9 | CAM_ZOOM_IN, 10 | CAM_ZOOM_OUT, 11 | CAM_LEFT, 12 | CAM_RIGHT, 13 | 14 | P1_WeakPunch, 15 | P1_StrongPunch, 16 | P1_WeakKick, 17 | P1_StrongKick, 18 | 19 | P1_UP, 20 | P1_DOWN, 21 | P1_LEFT, 22 | P1_RIGHT, 23 | 24 | P2_WeakPunch, 25 | P2_StrongPunch, 26 | P2_WeakKick, 27 | P2_StrongKick, 28 | 29 | P2_UP, 30 | P2_DOWN, 31 | P2_LEFT, 32 | P2_RIGHT, 33 | 34 | MOUSE_0, //leftclick 35 | MOUSE_1, //rightclick 36 | SHIFT, 37 | F8, 38 | F9, 39 | F10, 40 | F11, 41 | }; 42 | } -------------------------------------------------------------------------------- /FightingGameProject/MeleeCollisionResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "DamageData.h" 4 | #include "GameObj.h" 5 | 6 | namespace RB 7 | { 8 | class MeleeCollisionResult 9 | { 10 | public: 11 | bool isCollided = false; 12 | olc::vi2d midPoint = { 0, 0 }; 13 | DamageData damageData; 14 | }; 15 | } -------------------------------------------------------------------------------- /FightingGameProject/MeleeReaction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "GameObj.h" 4 | #include "MeleeCollisionResult.h" 5 | 6 | //hitstop messages 7 | #include "FightersHitStopMessage.h" 8 | #include "ProjectilesHitStopMessage.h" 9 | 10 | namespace RB 11 | { 12 | class MeleeReaction 13 | { 14 | private: 15 | std::vector _vecFighters; 16 | ImpactEffectsGroup* _impactEffects = nullptr; 17 | 18 | public: 19 | MeleeReaction(ObjBase* fighter0, ObjBase* fighter1, ImpactEffectsGroup* impactEffectsGroup) 20 | { 21 | _vecFighters.push_back(fighter0); 22 | _vecFighters.push_back(fighter1); 23 | _impactEffects = impactEffectsGroup; 24 | } 25 | 26 | void Update(int32_t index, MeleeCollisionResult collisionResult) 27 | { 28 | if (collisionResult.isCollided) 29 | { 30 | IF_COUT{ std::cout << "fighter 0 hits fighter 1!" << std::endl; }; 31 | 32 | _impactEffects->CreateObj(ObjType::HIT_EFFECT_0, collisionResult.midPoint); 33 | 34 | //midair hits 35 | if (_vecFighters[index]->objData.GetPosition().y < 0) 36 | { 37 | JumpSpecs jumpSpecs(10, 2, 1, true, true, false); 38 | 39 | _vecFighters[index]->objData.CreateNewJumpCalculator(); 40 | _vecFighters[index]->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 41 | _vecFighters[index]->SetNextState(State::NewState(_vecFighters[index])); 42 | 43 | FightersHitStopMessage fightersHitStop; 44 | ProjectilesHitStopMessage projectilesHitStop; 45 | fightersHitStop.Register(12); 46 | projectilesHitStop.Register(12); 47 | } 48 | //uppercuts from ground 49 | else if (collisionResult.damageData.upPush > 0) 50 | { 51 | JumpSpecs jumpSpecs(collisionResult.damageData.upPush, collisionResult.damageData.sidePush, 1, true, true, false); 52 | 53 | _vecFighters[index]->objData.CreateNewJumpCalculator(); 54 | _vecFighters[index]->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 55 | _vecFighters[index]->SetNextState(State::NewState(_vecFighters[index])); 56 | 57 | FightersHitStopMessage fightersHitStop; 58 | ProjectilesHitStopMessage projectilesHitStop; 59 | fightersHitStop.Register(12); 60 | projectilesHitStop.Register(12); 61 | } 62 | //straight punches&kicks from ground 63 | else 64 | { 65 | _vecFighters[index]->SetNextState(State::NewState(_vecFighters[index])); 66 | 67 | FightersHitStopMessage fightersHitStop; 68 | ProjectilesHitStopMessage projectilesHitStop; 69 | fightersHitStop.Register(12); 70 | projectilesHitStop.Register(12); 71 | } 72 | } 73 | } 74 | }; 75 | } -------------------------------------------------------------------------------- /FightingGameProject/Normalize.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | 4 | namespace RB 5 | { 6 | class Normalize 7 | { 8 | public: 9 | static olc::vf2d Norm(olc::vi2d vec) 10 | { 11 | olc::vf2d norm = (olc::vf2d)vec * 1.0f / (float)vec.mag(); 12 | return norm; 13 | } 14 | }; 15 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "ObjData.h" 4 | #include "CollisionData.h" 5 | #include "CollisionStay.h" 6 | 7 | namespace RB 8 | { 9 | class State; 10 | class StateController; 11 | class Camera; 12 | enum class BodyType; 13 | 14 | class ObjBase 15 | { 16 | public: 17 | ObjData objData; 18 | CollisionData collisionData{ &objData }; 19 | CollisionStay* collisionStay = nullptr; 20 | 21 | virtual State* GetCurrentState() = 0; 22 | virtual void SetCurrentState(State* state) = 0; 23 | virtual bool SetNextState(State* ptrState) = 0; 24 | virtual StateController* GetStateController() = 0; 25 | 26 | virtual void RenderPosition(Camera& cam) = 0; 27 | virtual void RenderSpriteSize(Camera& cam) = 0; 28 | virtual void RenderCollisionTiming(BodyType _bodyType, Camera& cam) = 0; 29 | 30 | virtual olc::vi2d GetBodyWorldPos(BodyType bodyType) = 0; 31 | virtual std::array GetBodyWorldQuad(BodyType bodyType) = 0; 32 | 33 | virtual olc::vi2d GetBoxColliderWorldPos() = 0; 34 | virtual std::array GetBoxColliderWorldQuad() = 0; 35 | }; 36 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjData.cpp: -------------------------------------------------------------------------------- 1 | #include "ObjData.h" 2 | 3 | namespace RB 4 | { 5 | ObjData::~ObjData() 6 | { 7 | if (ptrJumpCalculator != nullptr) 8 | { 9 | delete ptrJumpCalculator; 10 | } 11 | } 12 | 13 | olc::vi2d ObjData::GetPreviousPosition() { return previousPosition; } 14 | void ObjData::SetPreviousPosition(olc::vi2d pos) { previousPosition = pos; } 15 | 16 | olc::vi2d ObjData::GetPosition() { return position; } 17 | void ObjData::SetPosition(olc::vi2d pos) { position = pos; } 18 | 19 | olc::vi2d ObjData::GetSpriteSize() { return spriteSize; } 20 | void ObjData::SetSpriteSize(olc::vi2d _size) { spriteSize = _size; } 21 | 22 | size_t ObjData::GetCreationID() { return creationID; } 23 | void ObjData::SetCreationID(size_t t) { creationID = t; } 24 | 25 | size_t ObjData::GetOwnerID() { return ownerID; } 26 | void ObjData::SetOwnerID(size_t t) { ownerID = t; } 27 | 28 | OffsetType ObjData::GetOffsetType() { return offsetType; } 29 | void ObjData::SetOffsetType(OffsetType _type) { offsetType = _type; } 30 | 31 | int32_t ObjData::GetAnimationIndex() { return currentAnimationIndex; } 32 | void ObjData::SetAnimationIndex(int32_t _int) { currentAnimationIndex = _int; } 33 | 34 | void ObjData::SetLeftSide(bool _left) { onLeftSide = _left; } 35 | bool ObjData::IsOnLeftSide() { return onLeftSide; } 36 | 37 | void ObjData::FaceRight(bool _faceRight) { faceRight = _faceRight; } 38 | bool ObjData::IsFacingRight() { return faceRight; } 39 | 40 | void ObjData::SetPlayerType(PlayerType _playerType) { playerType = _playerType; } 41 | PlayerType ObjData::GetPlayerType() { return playerType; } 42 | 43 | void ObjData::CreateNewJumpCalculator() 44 | { 45 | if (ptrJumpCalculator != nullptr) 46 | { 47 | delete ptrJumpCalculator; 48 | } 49 | 50 | ptrJumpCalculator = new JumpCalculator(); 51 | } 52 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "OffsetType.h" 4 | #include "PlayerType.h" 5 | #include "JumpCalculator.h" 6 | 7 | namespace RB 8 | { 9 | class ObjData 10 | { 11 | private: 12 | olc::vi2d previousPosition = { 0, 0 }; 13 | olc::vi2d position = { 0, 0 }; 14 | olc::vi2d spriteSize = { 0, 0 }; 15 | size_t creationID = 0; 16 | size_t ownerID = 0; 17 | OffsetType offsetType = OffsetType::NONE; 18 | int32_t currentAnimationIndex = 0; 19 | bool onLeftSide = true; 20 | bool faceRight = true; 21 | PlayerType playerType = PlayerType::NONE; 22 | 23 | public: 24 | JumpCalculator* ptrJumpCalculator = nullptr; 25 | 26 | ~ObjData(); 27 | 28 | olc::vi2d GetPreviousPosition(); 29 | void SetPreviousPosition(olc::vi2d pos); 30 | 31 | olc::vi2d GetPosition(); 32 | void SetPosition(olc::vi2d pos); 33 | 34 | olc::vi2d GetSpriteSize(); 35 | void SetSpriteSize(olc::vi2d _size); 36 | 37 | size_t GetCreationID(); 38 | void SetCreationID(size_t t); 39 | 40 | size_t GetOwnerID(); 41 | void SetOwnerID(size_t t); 42 | 43 | OffsetType GetOffsetType(); 44 | void SetOffsetType(OffsetType _type); 45 | 46 | int32_t GetAnimationIndex(); 47 | void SetAnimationIndex(int32_t _int); 48 | 49 | void SetLeftSide(bool _left); 50 | bool IsOnLeftSide(); 51 | 52 | void FaceRight(bool _faceRight); 53 | bool IsFacingRight(); 54 | 55 | void SetPlayerType(PlayerType _playerType); 56 | PlayerType GetPlayerType(); 57 | 58 | void CreateNewJumpCalculator(); 59 | }; 60 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "ObjGroup.h" 2 | 3 | namespace RB 4 | { 5 | void ObjGroup::UpdateSpriteTileIndex() 6 | { 7 | for (size_t i = 0; i < _vecObjs.size(); i++) 8 | { 9 | if (_vecObjs[i] != nullptr) 10 | { 11 | _vecObjs[i]->GetCurrentState()->animationController.NextTileIndex(); 12 | } 13 | } 14 | } 15 | 16 | ObjBase* ObjGroup::GetObj(int32_t index) 17 | { 18 | if (index >= _vecObjs.size()) 19 | { 20 | return nullptr; 21 | } 22 | else 23 | { 24 | return _vecObjs[index]; 25 | } 26 | } 27 | 28 | void ObjGroup::DeleteObj(size_t index) 29 | { 30 | delete _vecObjs[index]; 31 | _vecObjs[index] = nullptr; 32 | _vecObjs.erase(_vecObjs.begin() + index); 33 | } 34 | 35 | std::vector* ObjGroup::GetVecObjs() 36 | { 37 | return &_vecObjs; 38 | } 39 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "olcPixelGameEngine.h" 4 | #include "ObjType.h" 5 | #include "GameObj.h" 6 | #include "Camera.h" 7 | #include "Updater.h" 8 | 9 | namespace RB 10 | { 11 | class ObjGroup 12 | { 13 | protected: 14 | std::vector _vecObjs; 15 | Camera* _camera = nullptr; 16 | Updater* _updater = nullptr; 17 | 18 | public: 19 | virtual void UpdateStates() = 0; 20 | virtual void RenderStates() = 0; 21 | virtual void RenderObjPosition() = 0; 22 | virtual void RenderBoxColliders() = 0; 23 | 24 | virtual void UpdateSpriteTileIndex(); 25 | 26 | virtual ObjBase* GetObj(int32_t index); 27 | 28 | virtual void CreateObj(ObjType objType, olc::vi2d startPos) {} 29 | virtual void DeleteObj(size_t index); 30 | 31 | virtual std::vector* GetVecObjs(); 32 | }; 33 | } -------------------------------------------------------------------------------- /FightingGameProject/ObjType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class ObjType 6 | { 7 | HIT_EFFECT_0, 8 | }; 9 | } -------------------------------------------------------------------------------- /FightingGameProject/OffsetType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class OffsetType 6 | { 7 | NONE, 8 | 9 | TOP_LEFT, 10 | TOP_CENTER, 11 | TOP_RIGHT, 12 | 13 | CENTER_LEFT, 14 | CENTER_CENTER, 15 | CENTER_RIGHT, 16 | 17 | BOTTOM_LEFT, 18 | BOTTOM_CENTER, 19 | BOTTOM_RIGHT, 20 | }; 21 | } -------------------------------------------------------------------------------- /FightingGameProject/PNG files/BoxColliderEditor/editor_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/BoxColliderEditor/editor_copy.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/BoxColliderEditor/editor_left_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/BoxColliderEditor/editor_left_sel.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/BoxColliderEditor/editor_playframe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/BoxColliderEditor/editor_playframe.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/BoxColliderEditor/editor_right_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/BoxColliderEditor/editor_right_sel.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/BoxColliderEditor/editor_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/BoxColliderEditor/editor_save.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/DebugElements/1whitesq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/DebugElements/1whitesq.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/DebugElements/1whitesq_tr80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/DebugElements/1whitesq_tr80.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_crouch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_crouch.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_hadouken_fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_hadouken_fire.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_hadouken_recover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_hadouken_recover.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_hitreaction_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_hitreaction_side.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_hitreaction_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_hitreaction_up.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_idle.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jab.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_fall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_fall.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_back.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_forward.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_prep_vertical.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_back.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_forward.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_up_vertical.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_jump_weakpunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_jump_weakpunch.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_uppercut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_uppercut.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_walk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_walk.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_0/fighter_0_walkback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_0/fighter_0_walkback.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Fighter_1/fighter_1_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Fighter_1/fighter_1_idle.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/ImpactEffects/hiteffect_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/ImpactEffects/hiteffect_0.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/down.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/downleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/downleft.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/downright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/downright.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/kick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/kick.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/left.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/punch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/punch.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/right.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/up.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/upleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/upleft.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/InputBuffer/upright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/InputBuffer/upright.png -------------------------------------------------------------------------------- /FightingGameProject/PNG files/Projectiles/hadouken_ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoundBearChoi/CPP_FightingGame/a8a6ca3436a4fead70e7e4bedd53145b9accd882/FightingGameProject/PNG files/Projectiles/hadouken_ball.png -------------------------------------------------------------------------------- /FightingGameProject/PlayerInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | class PlayerInput 6 | { 7 | public: 8 | bool up = false; 9 | bool down = false; 10 | bool left = false; 11 | bool right = false; 12 | 13 | bool weakpunch = false; 14 | bool strongpunch = false; 15 | 16 | bool weakkick = false; 17 | bool strongkick = false; 18 | 19 | static PlayerInput Get(PlayerType _playerType) 20 | { 21 | PlayerInput input; 22 | InputData& inputData = *InputData::ptr; 23 | 24 | if (_playerType == PlayerType::PLAYER_1) 25 | { 26 | if (inputData.key_w) { input.up = true; } 27 | if (inputData.key_s) { input.down = true; } 28 | if (inputData.key_a) { input.left = true; } 29 | if (inputData.key_d) { input.right = true; } 30 | 31 | if (inputData.key_t) { input.weakpunch = true; } 32 | if (inputData.key_y) { input.strongpunch = true; } 33 | } 34 | else if (_playerType == PlayerType::PLAYER_2) 35 | { 36 | if (inputData.key_up) { input.up = true; } 37 | if (inputData.key_down) { input.down = true; } 38 | if (inputData.key_left) { input.left = true; } 39 | if (inputData.key_right) { input.right = true; } 40 | 41 | if (inputData.key_np7) { input.weakpunch = true; } 42 | if (inputData.key_np8) { input.strongpunch = true; } 43 | } 44 | 45 | return input; 46 | } 47 | }; 48 | } -------------------------------------------------------------------------------- /FightingGameProject/PlayerToPlayerCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GameObj.h" 3 | #include "MeleeCollisionResult.h" 4 | #include "DiagonalOverlap.h" 5 | 6 | namespace RB 7 | { 8 | class PlayerToPlayerCollision 9 | { 10 | private: 11 | ObjBase* _fighter0 = nullptr; 12 | ObjBase* _fighter1 = nullptr; 13 | 14 | public: 15 | PlayerToPlayerCollision(ObjBase* fighter0, ObjBase* fighter1) 16 | { 17 | _fighter0 = fighter0; 18 | _fighter1 = fighter1; 19 | } 20 | 21 | MeleeCollisionResult Fighter0HitsFighter1() 22 | { 23 | CheckCollisionMessage* fighter0_Message = _fighter0->GetCurrentState()->GetCheckCollisionMessage(); 24 | 25 | if (fighter0_Message != nullptr) 26 | { 27 | MeleeCollisionResult result = GetCollisionResult(fighter0_Message, _fighter0, _fighter1); 28 | 29 | if (result.isCollided) 30 | { 31 | return result; 32 | } 33 | } 34 | 35 | MeleeCollisionResult noCollision; 36 | return noCollision; 37 | } 38 | 39 | MeleeCollisionResult Fighter1HitsFighter0() 40 | { 41 | CheckCollisionMessage* fighter1_Message = _fighter1->GetCurrentState()->GetCheckCollisionMessage(); 42 | 43 | if (fighter1_Message != nullptr) 44 | { 45 | MeleeCollisionResult result = GetCollisionResult(fighter1_Message, _fighter1, _fighter0); 46 | 47 | if (result.isCollided) 48 | { 49 | return result; 50 | } 51 | } 52 | 53 | MeleeCollisionResult noCollision; 54 | return noCollision; 55 | } 56 | 57 | MeleeCollisionResult GetCollisionResult(CheckCollisionMessage* attackerMessage, ObjBase* attacker, ObjBase* target) 58 | { 59 | if (attacker->GetCurrentState()->bodyToBodyCollisions.currentCollisionCount < attacker->GetCurrentState()->bodyToBodyCollisions.maxCollisions) 60 | { 61 | for (BodyType& b : attackerMessage->vecBodies) 62 | { 63 | olc::vi2d attackPos = attacker->GetBodyWorldPos(b); 64 | std::array attackQuad = attacker->GetBodyWorldQuad(b); 65 | 66 | IF_COUT{ std::cout << "attackpos: " << attackPos << std::endl; }; 67 | 68 | //check all body parts 69 | for (int32_t i = 0; i <= (int32_t)BodyType::RIGHT_FOOT; i++) 70 | { 71 | olc::vi2d targetPos = target->GetBodyWorldPos((BodyType)i); 72 | std::array targetQuad = target->GetBodyWorldQuad((BodyType)i); 73 | 74 | if (DiagonalOverlap::Overlapping(attackPos, attackQuad, targetPos, targetQuad)) 75 | { 76 | IF_COUT{ std::cout << "attacker body index: " << (int32_t)b << std::endl; }; 77 | 78 | olc::vf2d distance = targetPos - attackPos; 79 | distance *= 0.5f; 80 | olc::vi2d rounded((int32_t)std::round(distance.x), (int32_t)std::round(distance.y)); 81 | 82 | MeleeCollisionResult result; 83 | result.isCollided = true; 84 | result.midPoint = attackPos + rounded; 85 | result.damageData = attackerMessage->damageData; 86 | 87 | attacker->GetCurrentState()->bodyToBodyCollisions.currentCollisionCount++; 88 | 89 | return result; 90 | } 91 | } 92 | } 93 | } 94 | 95 | MeleeCollisionResult noCollision; 96 | return noCollision; 97 | } 98 | }; 99 | } -------------------------------------------------------------------------------- /FightingGameProject/PlayerToProjectileCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "GameObj.h" 4 | #include "PlayerToProjectileCollisionResult.h" 5 | #include "DiagonalOverlap.h" 6 | 7 | namespace RB 8 | { 9 | class PlayerToProjectileCollision 10 | { 11 | private: 12 | std::vector* _vecFighters = nullptr; 13 | std::vector* _vecProjectiles = nullptr; 14 | 15 | public: 16 | PlayerToProjectileCollision(std::vector* fighters, std::vector* projectiles) 17 | { 18 | _vecFighters = fighters; 19 | _vecProjectiles = projectiles; 20 | } 21 | 22 | PlayerToProjectileCollisionResult FighterCollidesWithProjectile(size_t fighterIndex) 23 | { 24 | std::vector& projectiles = *_vecProjectiles; 25 | std::vector& fighters = *_vecFighters; 26 | 27 | for (size_t projectileIndex = 0; projectileIndex < projectiles.size(); projectileIndex++) 28 | { 29 | size_t id = fighters[fighterIndex]->objData.GetCreationID(); 30 | size_t ownerID = projectiles[projectileIndex]->objData.GetOwnerID(); 31 | 32 | if (id != ownerID) 33 | { 34 | olc::vi2d projectilePos = projectiles[projectileIndex]->GetBoxColliderWorldPos(); 35 | std::arrayprojectileQuads = projectiles[projectileIndex]->GetBoxColliderWorldQuad(); 36 | 37 | //check all body parts 38 | for (int32_t bodyIndex = 0; bodyIndex <= (int32_t)BodyType::RIGHT_FOOT; bodyIndex++) 39 | { 40 | olc::vi2d bodyPos = fighters[fighterIndex]->GetBodyWorldPos((BodyType)bodyIndex); 41 | std::arraybodyQuads = fighters[fighterIndex]->GetBodyWorldQuad((BodyType)bodyIndex); 42 | 43 | if (DiagonalOverlap::Overlapping(projectilePos, projectileQuads, bodyPos, bodyQuads)) 44 | { 45 | PlayerToProjectileCollisionResult result; 46 | result.isCollided = true; 47 | 48 | IF_COUT{ std::cout << "projectile collision against player: " << 0 << std::endl; }; 49 | IF_COUT{ std::cout << "projectile collision against body: " << bodyIndex << std::endl; }; 50 | 51 | result.projectileIndex = projectileIndex; 52 | 53 | olc::vf2d distance = bodyPos - projectilePos; 54 | distance *= 0.5f; 55 | olc::vi2d rounded((int32_t)std::round(distance.x), (int32_t)std::round(distance.y)); 56 | result.midPoint = rounded + projectilePos; 57 | 58 | return result; 59 | } 60 | } 61 | } 62 | } 63 | 64 | PlayerToProjectileCollisionResult noCollision; 65 | return noCollision; 66 | } 67 | 68 | PlayerToProjectileCollisionResult Fighter1_CollidesWithProjectile() 69 | { 70 | PlayerToProjectileCollisionResult noCollision; 71 | return noCollision; 72 | } 73 | }; 74 | } -------------------------------------------------------------------------------- /FightingGameProject/PlayerToProjectileCollisionResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | 4 | namespace RB 5 | { 6 | class PlayerToProjectileCollisionResult 7 | { 8 | public: 9 | bool isCollided = false; 10 | size_t projectileIndex = 0; 11 | olc::vi2d midPoint; 12 | }; 13 | } -------------------------------------------------------------------------------- /FightingGameProject/PlayerType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class PlayerType 6 | { 7 | NONE, 8 | PLAYER_1, 9 | PLAYER_2, 10 | }; 11 | } -------------------------------------------------------------------------------- /FightingGameProject/Preload_Fighter_0.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Fighter_0_Idle.h" 4 | #include "Fighter_0_Idle.h" 5 | #include "Fighter_0_WalkForward.h" 6 | #include "Fighter_0_WalkBack.h" 7 | #include "Fighter_0_Jab.h" 8 | #include "Fighter_0_HitReaction_Side.h" 9 | #include "Fighter_0_HitReaction_Up.h" 10 | #include "Fighter_0_Hadouken_Fire.h" 11 | #include "Fighter_0_Hadouken_Recover.h" 12 | #include "Fighter_0_Jump_Prep_Vertical.h" 13 | #include "Fighter_0_Jump_Prep_Forward.h" 14 | #include "Fighter_0_Jump_Prep_Back.h" 15 | #include "Fighter_0_Jump_Up_Vertical.h" 16 | #include "Fighter_0_Jump_Up_Forward.h" 17 | #include "Fighter_0_Jump_Up_Back.h" 18 | #include "Fighter_0_Jump_Fall.h" 19 | #include "Fighter_0_Jump_WeakPunch.h" 20 | #include "Fighter_0_Crouch.h" 21 | #include "Fighter_0_Uppercut.h" 22 | 23 | namespace RB 24 | { 25 | class Preload_Fighter_0 26 | { 27 | public: 28 | Preload_Fighter_0() 29 | { 30 | std::vector sampleStates; 31 | 32 | sampleStates.push_back(State::NewState(nullptr)); 33 | sampleStates.push_back(State::NewState(nullptr)); 34 | sampleStates.push_back(State::NewState(nullptr)); 35 | sampleStates.push_back(State::NewState(nullptr)); 36 | sampleStates.push_back(State::NewState(nullptr)); 37 | sampleStates.push_back(State::NewState(nullptr)); 38 | sampleStates.push_back(State::NewState(nullptr)); 39 | sampleStates.push_back(State::NewState(nullptr)); 40 | sampleStates.push_back(State::NewState(nullptr)); 41 | sampleStates.push_back(State::NewState(nullptr)); 42 | sampleStates.push_back(State::NewState(nullptr)); 43 | sampleStates.push_back(State::NewState(nullptr)); 44 | sampleStates.push_back(State::NewState(nullptr)); 45 | sampleStates.push_back(State::NewState(nullptr)); 46 | sampleStates.push_back(State::NewState(nullptr)); 47 | sampleStates.push_back(State::NewState(nullptr)); 48 | sampleStates.push_back(State::NewState(nullptr)); 49 | sampleStates.push_back(State::NewState(nullptr)); 50 | 51 | for (size_t i = 0; i < sampleStates.size(); i++) 52 | { 53 | sampleStates[i]->UpdateColliderParts(); 54 | delete sampleStates[i]; 55 | } 56 | } 57 | }; 58 | } -------------------------------------------------------------------------------- /FightingGameProject/PreviousPositionRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IGroupComponent.h" 4 | #include "GameObj.h" 5 | 6 | namespace RB 7 | { 8 | class PreviousPositionRenderer : public IGroupComponent 9 | { 10 | private: 11 | std::vector* _vec = nullptr; 12 | Camera* _cam = nullptr; 13 | 14 | public: 15 | PreviousPositionRenderer(std::vector* targetVec, Camera* cam) 16 | { 17 | _vec = targetVec; 18 | _cam = cam; 19 | } 20 | 21 | void Update() override 22 | { 23 | DrawLines((*_vec)[0]); 24 | DrawLines((*_vec)[1]); 25 | } 26 | 27 | void DrawLines(ObjBase* obj) 28 | { 29 | std::array bottomLeft = obj->collisionData.moveSegments->GetBottomLeftSegment(); 30 | std::array bottomRight = obj->collisionData.moveSegments->GetBottomRightSegment(); 31 | 32 | std::array topLeft = obj->collisionData.moveSegments->GetTopLeftSegment(); 33 | std::array topRight = obj->collisionData.moveSegments->GetTopRightSegment(); 34 | 35 | if (bottomLeft[0] != olc::vi2d{ 0 , 0 } || bottomLeft[1] != olc::vi2d{ 0 , 0 }) 36 | { 37 | olc::vi2d left0 = ScreenVector::GetScreenPosition(bottomLeft[0], *_cam); 38 | olc::vi2d left1 = ScreenVector::GetScreenPosition(bottomLeft[1], *_cam); 39 | olc::Renderer::ptrPGE->DrawLine(left0, left1, olc::CYAN); 40 | } 41 | 42 | if (bottomRight[0] != olc::vi2d{ 0 , 0 } || bottomRight[1] != olc::vi2d{ 0 , 0 }) 43 | { 44 | olc::vi2d right0 = ScreenVector::GetScreenPosition(bottomRight[0], *_cam); 45 | olc::vi2d right1 = ScreenVector::GetScreenPosition(bottomRight[1], *_cam); 46 | olc::Renderer::ptrPGE->DrawLine(right0, right1, olc::CYAN); 47 | } 48 | 49 | if (topLeft[0] != olc::vi2d{ 0 , 0 } || topLeft[1] != olc::vi2d{ 0 , 0 }) 50 | { 51 | olc::vi2d left0 = ScreenVector::GetScreenPosition(topLeft[0], *_cam); 52 | olc::vi2d left1 = ScreenVector::GetScreenPosition(topLeft[1], *_cam); 53 | olc::Renderer::ptrPGE->DrawLine(left0, left1, olc::CYAN); 54 | } 55 | 56 | if (topRight[0] != olc::vi2d{ 0 , 0 } || topRight[1] != olc::vi2d{ 0 , 0 }) 57 | { 58 | olc::vi2d right0 = ScreenVector::GetScreenPosition(topRight[0], *_cam); 59 | olc::vi2d right1 = ScreenVector::GetScreenPosition(topRight[1], *_cam); 60 | olc::Renderer::ptrPGE->DrawLine(right0, right1, olc::CYAN); 61 | } 62 | } 63 | }; 64 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectileCollisionReaction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "PlayerToProjectileCollisionResult.h" 5 | #include "GameObj.h" 6 | 7 | //hitstop messages 8 | #include "FightersHitStopMessage.h" 9 | #include "ProjectilesHitStopMessage.h" 10 | 11 | namespace RB 12 | { 13 | class ProjectileCollisionReaction 14 | { 15 | private: 16 | ObjGroup* _fighters = nullptr; 17 | ObjGroup* _projectiles = nullptr; 18 | ObjGroup* _impactEffects = nullptr; 19 | 20 | public: 21 | ProjectileCollisionReaction(ObjGroup* fighters, ObjGroup* projectiles, ObjGroup* impactEffects) 22 | { 23 | _fighters = fighters; 24 | _projectiles = projectiles; 25 | _impactEffects = impactEffects; 26 | } 27 | 28 | void Update(int32_t fighterIndex, PlayerToProjectileCollisionResult collisionResult) 29 | { 30 | if (collisionResult.isCollided) 31 | { 32 | //midair hits 33 | if (_fighters->GetObj(fighterIndex)->objData.GetPosition().y < 0) 34 | { 35 | _projectiles->DeleteObj(collisionResult.projectileIndex); 36 | _impactEffects->CreateObj(ObjType::HIT_EFFECT_0, collisionResult.midPoint); 37 | 38 | JumpSpecs jumpSpecs(10, 2, 1, true, true, false); 39 | 40 | _fighters->GetObj(fighterIndex)->objData.CreateNewJumpCalculator(); 41 | _fighters->GetObj(fighterIndex)->objData.ptrJumpCalculator->SetSpecs(jumpSpecs); 42 | _fighters->GetObj(fighterIndex)->SetNextState(State::NewState(_fighters->GetObj(fighterIndex))); 43 | 44 | FightersHitStopMessage fightersHitStop; 45 | ProjectilesHitStopMessage projectilesHitStop; 46 | fightersHitStop.Register(12); 47 | projectilesHitStop.Register(12); 48 | } 49 | //ground hits 50 | else 51 | { 52 | _projectiles->DeleteObj(collisionResult.projectileIndex); 53 | _impactEffects->CreateObj(ObjType::HIT_EFFECT_0, collisionResult.midPoint); 54 | 55 | _fighters->GetObj(fighterIndex)->SetNextState(State::NewState(_fighters->GetObj(fighterIndex))); 56 | 57 | FightersHitStopMessage fightersHitStop; 58 | ProjectilesHitStopMessage projectilesHitStop; 59 | fightersHitStop.Register(12); 60 | projectilesHitStop.Register(12); 61 | } 62 | } 63 | } 64 | }; 65 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectileGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "ProjectileGroup.h" 2 | 3 | namespace RB 4 | { 5 | ProjectileGroup::ProjectileGroup(Camera* camera) 6 | { 7 | _camera = camera; 8 | ptrAnimationRenderer = new AnimationRenderer(&_vecObjs, _camera); 9 | 10 | _updater = new ProjectilesFixedUpdater(this); 11 | 12 | ProjectilesHitStopMessage::SetReceiver(_updater); 13 | } 14 | 15 | ProjectileGroup::~ProjectileGroup() 16 | { 17 | delete ptrAnimationRenderer; 18 | delete _updater; 19 | 20 | if (_vecObjs.size() != 0) 21 | { 22 | IF_COUT{ std::cout << std::endl; }; 23 | 24 | for (size_t i = 0; i < _vecObjs.size(); i++) 25 | { 26 | IF_COUT{ std::cout << "destructing projectile: " << _vecObjs[i]->objData.GetCreationID() << std::endl; }; 27 | delete _vecObjs[i]; 28 | } 29 | 30 | IF_COUT{ std::cout << std::endl; }; 31 | } 32 | } 33 | 34 | void ProjectileGroup::UpdateStates() 35 | { 36 | _updater->CustomUpdate(); 37 | } 38 | 39 | void ProjectileGroup::RenderObjPosition() 40 | { 41 | for (size_t i = 0; i < _vecObjs.size(); i++) 42 | { 43 | if (_vecObjs[i] != nullptr) 44 | { 45 | _vecObjs[i]->collisionData.objBoxCollider.Render(*_camera, _vecObjs[i]->objData.GetPosition(), olc::CYAN); 46 | } 47 | } 48 | } 49 | 50 | void ProjectileGroup::RenderStates() 51 | { 52 | ptrAnimationRenderer->Update(); 53 | } 54 | 55 | void ProjectileGroup::RenderBoxColliders() 56 | { 57 | 58 | } 59 | 60 | void ProjectileGroup::CreateProjectiles(std::vector& vecSpecs) 61 | { 62 | for (size_t i = 0; i < vecSpecs.size(); i++) 63 | { 64 | ObjBase* obj = new GameObj(); 65 | _vecObjs.push_back(obj); 66 | _vecObjs.back()->objData.SetCreationID(_vecObjs.size()); 67 | 68 | if (vecSpecs[i].projectileType == ProjectileType::HADOUKEN) 69 | { 70 | obj->SetCurrentState(State::NewState(obj)); 71 | } 72 | 73 | if (vecSpecs[i].forward.x < 0) 74 | { 75 | obj->objData.FaceRight(false); 76 | } 77 | else if (vecSpecs[i].forward.x > 0) 78 | { 79 | obj->objData.FaceRight(true); 80 | } 81 | 82 | obj->objData.SetPosition(vecSpecs[i].startPos); 83 | obj->objData.SetOwnerID(vecSpecs[i].ownerObjCreationID); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectileGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ObjGroup.h" 3 | #include "ProjectilesFixedUpdater.h" 4 | #include "ProjectilesHitStopMessage.h" 5 | 6 | //components 7 | #include "AnimationRenderer.h" 8 | 9 | //projectiles 10 | #include "Hadouken_MoveForward.h" 11 | 12 | namespace RB 13 | { 14 | class ProjectileGroup : public ObjGroup 15 | { 16 | private: 17 | AnimationRenderer* ptrAnimationRenderer = nullptr; 18 | 19 | public: 20 | ProjectileGroup(Camera* camera); 21 | ~ProjectileGroup(); 22 | 23 | void UpdateStates() override; 24 | void RenderStates() override; 25 | 26 | void RenderObjPosition() override; 27 | void RenderBoxColliders() override; 28 | 29 | void CreateProjectiles(std::vector& vecSpecs); 30 | }; 31 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectileType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class ProjectileType 6 | { 7 | NONE, 8 | 9 | HADOUKEN, 10 | 11 | }; 12 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectilesFixedUpdater.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Updater.h" 3 | 4 | namespace RB 5 | { 6 | class ProjectilesFixedUpdater : public Updater 7 | { 8 | private: 9 | ObjGroup* _projectilesGroup = nullptr; 10 | 11 | public: 12 | ProjectilesFixedUpdater(ObjGroup* projectilesGroup) 13 | { 14 | _projectilesGroup = projectilesGroup; 15 | } 16 | 17 | void CustomUpdate() override 18 | { 19 | if (_stopCount > 0) 20 | { 21 | _stopCount--; 22 | } 23 | else 24 | { 25 | DoUpdate(); 26 | } 27 | } 28 | 29 | void DoUpdate() 30 | { 31 | std::vector& vecObjs = *_projectilesGroup->GetVecObjs(); 32 | 33 | for (size_t i = 0; i < vecObjs.size(); i++) 34 | { 35 | if (vecObjs[i] != nullptr) 36 | { 37 | State* state = vecObjs[i]->GetCurrentState(); 38 | 39 | if (state != nullptr) 40 | { 41 | state->RunUpdateProcess(); 42 | } 43 | } 44 | } 45 | 46 | _projectilesGroup->UpdateSpriteTileIndex(); 47 | 48 | ProcessStopCounts(); 49 | UpdateUpdateCount(); 50 | } 51 | }; 52 | } -------------------------------------------------------------------------------- /FightingGameProject/ProjectilesHitStopMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "ProjectilesHitStopMessage.h" 2 | 3 | namespace RB 4 | { 5 | Updater* ProjectilesHitStopMessage::_projectilesFixedUpdater = nullptr; 6 | } 7 | -------------------------------------------------------------------------------- /FightingGameProject/ProjectilesHitStopMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HitStopMessage.h" 3 | #include "Updater.h" 4 | 5 | namespace RB 6 | { 7 | class ProjectilesHitStopMessage : public HitStopMessage 8 | { 9 | private: 10 | static Updater* _projectilesFixedUpdater; 11 | 12 | public: 13 | static void SetReceiver(Updater* fixedUpdater) 14 | { 15 | _projectilesFixedUpdater = fixedUpdater; 16 | } 17 | 18 | void Register(int32_t stopCount) override 19 | { 20 | StopCountData data; 21 | data.stopCount = stopCount; 22 | _projectilesFixedUpdater->AddStopCountQueue(data); 23 | } 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/RandomInteger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | // check out https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution 7 | class RandomInteger 8 | { 9 | public: 10 | /// 11 | /// including min and max 12 | /// 13 | int GetInteger(int min, int max) 14 | { 15 | std::random_device device; 16 | std::mt19937 generator(device()); 17 | std::uniform_int_distribution distribution(min, max); 18 | 19 | return distribution(generator); 20 | } 21 | }; 22 | } -------------------------------------------------------------------------------- /FightingGameProject/RenderMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class RenderMode 6 | { 7 | SPRITES_ONLY = 0, 8 | DEBUG_ONLY, 9 | SPRITES_AND_DEBUG, 10 | 11 | COUNT, 12 | }; 13 | } -------------------------------------------------------------------------------- /FightingGameProject/Scene.cpp: -------------------------------------------------------------------------------- 1 | #include "Scene.h" 2 | 3 | namespace RB 4 | { 5 | Scene::~Scene() 6 | { 7 | IF_COUT{ std::cout << "destructing Scene (virtual)" << std::endl; }; 8 | 9 | delete _cam; 10 | } 11 | 12 | void Scene::ShowZeroPosition(Camera& cam) 13 | { 14 | olc::vi2d bottom{ 0, 7 }; 15 | olc::vi2d top{ 0, -7 }; 16 | olc::vi2d left{ -7, 0 }; 17 | olc::vi2d right{ 7, 0 }; 18 | 19 | olc::vi2d relativeTop = ScreenVector::GetScreenPosition(top, cam); 20 | olc::vi2d relativeBottom = ScreenVector::GetScreenPosition(bottom, cam); 21 | olc::vi2d relativeLeft = ScreenVector::GetScreenPosition(left, cam); 22 | olc::vi2d relativeRight = ScreenVector::GetScreenPosition(right, cam); 23 | 24 | if (DevSettings::renderMode == RenderMode::DEBUG_ONLY || DevSettings::renderMode == RenderMode::SPRITES_AND_DEBUG) 25 | { 26 | olc::Renderer::ptrPGE->DrawLine(relativeTop, relativeBottom, olc::GREEN); 27 | olc::Renderer::ptrPGE->DrawLine(relativeLeft, relativeRight, olc::GREEN); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /FightingGameProject/Scene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Camera.h" 3 | #include "DevSettings.h" 4 | #include "ScreenVector.h" 5 | #include "SceneType.h" 6 | 7 | namespace RB 8 | { 9 | class Scene 10 | { 11 | public: 12 | Camera* _cam = nullptr; 13 | SceneType sceneType = SceneType::NONE; 14 | 15 | virtual void InitScene() = 0; 16 | virtual void UpdateScene() = 0; 17 | virtual void RenderObjs() = 0; 18 | virtual void RenderStates() = 0; 19 | 20 | virtual ~Scene(); 21 | 22 | void ShowZeroPosition(Camera& cam); 23 | }; 24 | } -------------------------------------------------------------------------------- /FightingGameProject/SceneController.cpp: -------------------------------------------------------------------------------- 1 | #include "SceneController.h" 2 | 3 | namespace RB 4 | { 5 | SceneController::SceneController() 6 | { 7 | IF_COUT{ std::cout << "constructing SceneController" << std::endl; }; 8 | } 9 | 10 | SceneController::~SceneController() 11 | { 12 | IF_COUT{ std::cout << "destructing SceneController" << std::endl; }; 13 | 14 | delete currentScene; 15 | } 16 | 17 | void SceneController::CreateScene(SceneType _sceneType) 18 | { 19 | delete currentScene; 20 | 21 | if (_sceneType == SceneType::FIGHT_SCENE) 22 | { 23 | currentScene = new FightScene(); 24 | currentScene->sceneType = _sceneType; 25 | } 26 | else if (_sceneType == SceneType::BOXCOLLIDER_EDITOR) 27 | { 28 | currentScene = new HitBoxEditorScene(); 29 | currentScene->sceneType = _sceneType; 30 | } 31 | 32 | currentScene->InitScene(); 33 | } 34 | 35 | void SceneController::ChangeScene() 36 | { 37 | InputData& inputData = *InputData::ptr; 38 | 39 | if (inputData.key_f11) 40 | { 41 | if (currentScene->sceneType == SceneType::FIGHT_SCENE) 42 | { 43 | CreateScene(SceneType::BOXCOLLIDER_EDITOR); 44 | } 45 | else if (currentScene->sceneType == SceneType::BOXCOLLIDER_EDITOR) 46 | { 47 | CreateScene(SceneType::FIGHT_SCENE); 48 | } 49 | 50 | IF_COUT{ std::cout << "f11 pressed" << std::endl; }; 51 | inputData.key_f11->processed = true; 52 | } 53 | } 54 | 55 | void SceneController::Load() 56 | { 57 | spriteLoader.Load_Fighter_0_Sprites(); 58 | spriteLoader.Load_Fighter_1_Sprites(); 59 | spriteLoader.LoadBoxColliderEditorSprites(); 60 | spriteLoader.LoadDebugElementSprites(); 61 | spriteLoader.LoadInputBufferSprites(); 62 | spriteLoader.LoadProjectileSprites(); 63 | spriteLoader.LoadImpactEffectSprites(); 64 | 65 | SpriteLoader::ptr = &spriteLoader; 66 | } 67 | } -------------------------------------------------------------------------------- /FightingGameProject/SceneController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Scene.h" 3 | #include "SceneType.h" 4 | #include "SpriteLoader.h" 5 | #include "FightScene.h" 6 | #include "HitBoxEditorScene.h" 7 | 8 | namespace RB 9 | { 10 | class SceneController 11 | { 12 | private: 13 | SpriteLoader spriteLoader; 14 | 15 | public: 16 | SceneController(); 17 | ~SceneController(); 18 | 19 | Scene* currentScene = nullptr; 20 | 21 | void CreateScene(SceneType _sceneType); 22 | void ChangeScene(); 23 | void Load(); 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/SceneType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class SceneType 6 | { 7 | NONE, 8 | 9 | FIGHT_SCENE, 10 | 11 | BOXCOLLIDER_EDITOR, 12 | }; 13 | } -------------------------------------------------------------------------------- /FightingGameProject/ScreenVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | #include "GameSettings.h" 4 | #include "Camera.h" 5 | 6 | namespace RB 7 | { 8 | class ScreenVector 9 | { 10 | public: 11 | static olc::vi2d GetScreenPosition(const olc::vi2d& objPos, Camera& cam) 12 | { 13 | olc::vi2d fromCam = objPos - cam.GetPosition(); 14 | 15 | float x = (float)fromCam.x * cam.GetZoom(); 16 | float y = (float)fromCam.y * cam.GetZoom(); 17 | 18 | fromCam = { (int32_t)std::round(x), (int32_t)std::round(y) }; 19 | 20 | olc::vi2d screenCenter{ GameSettings::window_width / 2, GameSettings::window_height / 2 }; 21 | olc::vi2d screenPos = screenCenter + fromCam; 22 | 23 | return screenPos; 24 | } 25 | 26 | static olc::vi2d GetScale(const olc::vi2d& vector, const float& scale) 27 | { 28 | float x = (float)vector.x * scale; 29 | int32_t roundedX = (int32_t)std::round(x); 30 | 31 | float y = (float)vector.y * scale; 32 | int32_t roundedY = (int32_t)std::round(y); 33 | 34 | return { roundedX, roundedY }; 35 | } 36 | }; 37 | } -------------------------------------------------------------------------------- /FightingGameProject/SpecialMove.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "InputElement.h" 4 | #include "ConvertedInputType.h" 5 | 6 | namespace RB 7 | { 8 | class SpecialMove 9 | { 10 | protected: 11 | size_t currIndex = 0; 12 | 13 | public: 14 | virtual void Check(InputElement& _inputElement, size_t bufferIndex, ObjData& objData) = 0; 15 | virtual bool IsMatching() = 0; 16 | std::vector correctBuffers; 17 | 18 | ConvertedInputType GetConvert(InputType& _inputType, ObjData& objData) 19 | { 20 | if (_inputType == InputType::UP) 21 | { 22 | return ConvertedInputType::UP; 23 | } 24 | else if (_inputType == InputType::DOWN) 25 | { 26 | return ConvertedInputType::DOWN; 27 | } 28 | 29 | if (_inputType == InputType::WEAK_PUNCH) 30 | { 31 | return ConvertedInputType::WEAK_PUNCH; 32 | } 33 | 34 | if (objData.IsFacingRight()) 35 | { 36 | switch (_inputType) 37 | { 38 | case InputType::LEFT: 39 | return ConvertedInputType::BACK; 40 | case InputType::RIGHT: 41 | return ConvertedInputType::FORWARD; 42 | 43 | case InputType::UP_RIGHT: 44 | return ConvertedInputType::UP_FORWARD; 45 | case InputType::DOWN_RIGHT: 46 | return ConvertedInputType::DOWN_FORWARD; 47 | case InputType::DOWN_LEFT: 48 | return ConvertedInputType::DOWN_BACK; 49 | case InputType::UP_LEFT: 50 | return ConvertedInputType::UP_BACK; 51 | } 52 | } 53 | else 54 | { 55 | switch (_inputType) 56 | { 57 | case InputType::LEFT: 58 | return ConvertedInputType::FORWARD; 59 | case InputType::RIGHT: 60 | return ConvertedInputType::BACK; 61 | 62 | case InputType::UP_RIGHT: 63 | return ConvertedInputType::UP_BACK; 64 | case InputType::DOWN_RIGHT: 65 | return ConvertedInputType::DOWN_BACK; 66 | case InputType::DOWN_LEFT: 67 | return ConvertedInputType::DOWN_FORWARD; 68 | case InputType::UP_LEFT: 69 | return ConvertedInputType::UP_FORWARD; 70 | } 71 | } 72 | 73 | return ConvertedInputType::NONE; 74 | } 75 | }; 76 | } -------------------------------------------------------------------------------- /FightingGameProject/SpecialMoveProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IGroupComponent.h" 4 | #include "Hadouken.h" 5 | #include "BufferChecker.h" 6 | #include "InputBuffer.h" 7 | 8 | namespace RB 9 | { 10 | class Fighter_0_Hadouken_Fire; 11 | 12 | class SpecialMoveProcessor : public IGroupComponent 13 | { 14 | private: 15 | std::vector* _vecFighters = nullptr; 16 | 17 | public: 18 | SpecialMoveProcessor(std::vector* vecFighters) 19 | { 20 | _vecFighters = vecFighters; 21 | } 22 | 23 | void Update() override 24 | { 25 | std::vector& vec = *_vecFighters; 26 | 27 | for (size_t i = 0; i < vec.size(); i++) 28 | { 29 | TriggerSpecialMove(*vec[i]); 30 | } 31 | } 32 | 33 | void TriggerSpecialMove(ObjBase& obj) 34 | { 35 | Hadouken hadouken; 36 | std::vector* vecInputs = nullptr; 37 | 38 | if (obj.objData.GetCreationID() == 1) 39 | { 40 | vecInputs = &InputBuffer::ptr->vecP1Inputs; 41 | } 42 | else 43 | { 44 | vecInputs = &InputBuffer::ptr->vecP2Inputs; 45 | } 46 | 47 | if (vecInputs != nullptr) 48 | { 49 | if (BufferChecker::Correct(hadouken, *vecInputs, obj)) 50 | { 51 | obj.GetCurrentState()->nextState = State::NewState(&obj); 52 | } 53 | } 54 | } 55 | }; 56 | } -------------------------------------------------------------------------------- /FightingGameProject/SpriteLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "olcPixelGameEngine.h" 6 | #include "DevSettings.h" 7 | #include "SpriteType.h" 8 | 9 | namespace RB 10 | { 11 | class SpriteLoader 12 | { 13 | private: 14 | std::array, (int32_t)SpriteType::COUNT> sprites; 15 | std::array, (int32_t)SpriteType::COUNT> decals; 16 | std::array, (int32_t)SpriteType::COUNT> hashes; 17 | 18 | void LoadSprites(std::string path, std::vector& vecSprites, std::vector& vecDecals, std::vector& vecHash); 19 | 20 | public: 21 | static SpriteLoader* ptr; 22 | 23 | SpriteLoader(); 24 | ~SpriteLoader(); 25 | 26 | void Load_Fighter_0_Sprites(); 27 | void Load_Fighter_1_Sprites(); 28 | void LoadBoxColliderEditorSprites(); 29 | void LoadDebugElementSprites(); 30 | void LoadInputBufferSprites(); 31 | void LoadProjectileSprites(); 32 | void LoadImpactEffectSprites(); 33 | void DeleteSprites(size_t arrayIndex); 34 | olc::Decal* FindDecal(size_t _hash, size_t arrayIndex); 35 | }; 36 | } -------------------------------------------------------------------------------- /FightingGameProject/SpriteType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace RB 4 | { 5 | enum class SpriteType 6 | { 7 | NONE = -1, 8 | 9 | FIGHTER_0, 10 | FIGHTER_1, 11 | 12 | BOXCOLLIDER_EDITOR_UI, 13 | 14 | DEBUG_ELEMENTS, 15 | 16 | INPUT_BUFFER, 17 | 18 | PROJECTILES, 19 | 20 | IMPACT_EFFECTS, 21 | 22 | COUNT, 23 | }; 24 | } -------------------------------------------------------------------------------- /FightingGameProject/State.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ObjBase.h" 4 | #include "BodyToBodyCollisions.h" 5 | #include "DevSettings.h" 6 | #include "AnimationController.h" 7 | #include "Directions.h" 8 | #include "CreateProjectileMessage.h" 9 | 10 | namespace RB 11 | { 12 | class State 13 | { 14 | protected: 15 | bool isNew = true; 16 | virtual size_t& Hash(); 17 | void MakeHash(size_t& _hash); 18 | ObjBase* _ownerObj = nullptr; 19 | 20 | public: 21 | State* nextState = nullptr; 22 | size_t stateUpdateCount = 0; 23 | 24 | BodyToBodyCollisions bodyToBodyCollisions; 25 | AnimationController animationController; 26 | std::vector vecCreateProjectiles; 27 | 28 | virtual ~State(); 29 | virtual void OnEnter() = 0; 30 | virtual void OnUpdate() = 0; 31 | virtual void OnAnimationUpdate() {} 32 | 33 | virtual std::vector& GetColliders(); 34 | virtual std::vector& GetColliderQuads(); 35 | 36 | void RunUpdateProcess(); 37 | size_t GetHash(); 38 | bool IsNew(); 39 | void UpdateColliderParts(); 40 | void RenderColliderQuads(Camera& cam); 41 | void UnloadColliderData(); 42 | olc::vi2d GetColliderWorldPos(BodyType _bodyType); 43 | std::array GetColliderQuadsWorldPos(BodyType _bodyType); 44 | CheckCollisionMessage* GetCheckCollisionMessage(); 45 | 46 | void SetObjData(ObjBase* ownerObj) 47 | { 48 | _ownerObj = ownerObj; 49 | } 50 | 51 | template 52 | static State* NewState(ObjBase* ownerObj) 53 | { 54 | if (std::is_base_of::value) 55 | { 56 | State* state = new T(); 57 | state->SetObjData(ownerObj); 58 | return state; 59 | } 60 | else 61 | { 62 | return nullptr; 63 | } 64 | } 65 | }; 66 | } -------------------------------------------------------------------------------- /FightingGameProject/StateController.cpp: -------------------------------------------------------------------------------- 1 | #include "StateController.h" 2 | 3 | namespace RB 4 | { 5 | StateController::StateController() 6 | { 7 | 8 | } 9 | 10 | StateController::~StateController() 11 | { 12 | IF_COUT{ std::cout << "destructing StateController" << std::endl; }; 13 | delete currentState; 14 | } 15 | 16 | void StateController::MakeStateTransition() 17 | { 18 | State* next = currentState->nextState; 19 | 20 | if (next != nullptr) 21 | { 22 | delete currentState; 23 | currentState = next; 24 | currentState->nextState = nullptr; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /FightingGameProject/StateController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "State.h" 3 | #include "DevSettings.h" 4 | 5 | namespace RB 6 | { 7 | class StateController 8 | { 9 | private: 10 | State* prevState = nullptr; 11 | 12 | public: 13 | State* currentState = nullptr; 14 | 15 | StateController(); 16 | ~StateController(); 17 | 18 | void MakeStateTransition(); 19 | }; 20 | } -------------------------------------------------------------------------------- /FightingGameProject/StopCountData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RB 5 | { 6 | class StopCountData 7 | { 8 | public: 9 | bool oneFrameSkipped = false; 10 | int32_t stopCount = 0; 11 | }; 12 | } -------------------------------------------------------------------------------- /FightingGameProject/StringNotification.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "olcPixelGameEngine.h" 4 | 5 | namespace RB 6 | { 7 | class StringNotification 8 | { 9 | public: 10 | std::string str = "none"; 11 | olc::vi2d pos = { 0, 0 }; 12 | int32_t frames = 0; 13 | olc::Pixel color = olc::WHITE; 14 | 15 | void Show() 16 | { 17 | if (frames > 0) 18 | { 19 | frames--; 20 | 21 | olc::Renderer::ptrPGE->DrawString(pos, str, color); 22 | } 23 | } 24 | }; 25 | } -------------------------------------------------------------------------------- /FightingGameProject/TargetBodyType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BodyType.h" 3 | 4 | namespace RB 5 | { 6 | class TargetBodyType 7 | { 8 | public: 9 | BodyType selectedType = BodyType::HEAD; 10 | 11 | void NextType() 12 | { 13 | int32_t next = (int32_t)selectedType + 1; 14 | 15 | if (next > (int32_t)BodyType::RIGHT_FOOT) 16 | { 17 | next = (int32_t)BodyType::HEAD; 18 | } 19 | 20 | selectedType = (BodyType)next; 21 | } 22 | 23 | void PrevType() 24 | { 25 | int32_t next = (int32_t)selectedType - 1; 26 | 27 | if (next < (int32_t)BodyType::HEAD) 28 | { 29 | next = (int32_t)BodyType::RIGHT_FOOT; 30 | } 31 | 32 | selectedType = (BodyType)next; 33 | } 34 | 35 | std::string GetCurrentSelString() 36 | { 37 | switch (selectedType) 38 | { 39 | case BodyType::HEAD: return "head"; 40 | 41 | case BodyType::UPPERBODY: return "upper body"; 42 | case BodyType::LOWERBODY: return "lower body"; 43 | 44 | case BodyType::LEFT_ELBOW: return "left elbow"; 45 | case BodyType::LEFT_FOREARM: return "left forearm"; 46 | case BodyType::LEFT_HAND: return "left hand"; 47 | 48 | case BodyType::RIGHT_ELBOW: return "right elbow"; 49 | case BodyType::RIGHT_FOREARM: return "right forearm"; 50 | case BodyType::RIGHT_HAND: return "right hand"; 51 | 52 | case BodyType::LEFT_KNEE: return "left knee"; 53 | case BodyType::LEFT_LOWERLEG: return "left lower leg"; 54 | case BodyType::LEFT_FOOT: return "left foot"; 55 | 56 | case BodyType::RIGHT_LOWERLEG: return "right lower leg"; 57 | case BodyType::RIGHT_KNEE: return "right knee"; 58 | case BodyType::RIGHT_FOOT: return "right foot"; 59 | } 60 | 61 | return "none"; 62 | } 63 | }; 64 | } -------------------------------------------------------------------------------- /FightingGameProject/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GameSettings.h" 3 | 4 | namespace RB 5 | { 6 | class Timer 7 | { 8 | private: 9 | float fAccumulatedTime = 0.0f; 10 | 11 | //updates per sec 12 | int32_t nUpdateCount = 0; 13 | int32_t nUpdateCountPerSec = 0; 14 | float fTime = 0.0f; 15 | 16 | public: 17 | bool UpdateTime(float fElapsedTime) 18 | { 19 | fAccumulatedTime += fElapsedTime; 20 | 21 | if (fTime >= 1.0f) 22 | { 23 | nUpdateCountPerSec = nUpdateCount; 24 | nUpdateCount = 0; 25 | fTime = 0.0f; 26 | } 27 | else 28 | { 29 | fTime += fElapsedTime; 30 | } 31 | 32 | if (fAccumulatedTime >= GameSettings::TargetFrameTime(ChangeTimer::NONE)) 33 | { 34 | fAccumulatedTime -= GameSettings::TargetFrameTime(ChangeTimer::NONE); 35 | nUpdateCount++; 36 | return true; 37 | } 38 | else 39 | { 40 | return false; 41 | } 42 | } 43 | 44 | void ShowUpdateCount() 45 | { 46 | olc::Renderer::ptrPGE->DrawString({0, 0}, "update count: " + std::to_string(nUpdateCountPerSec), olc::WHITE); 47 | } 48 | }; 49 | } -------------------------------------------------------------------------------- /FightingGameProject/UIElement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "olcPixelGameEngine.h" 3 | 4 | namespace RB 5 | { 6 | class UIElement 7 | { 8 | public: 9 | olc::vi2d topLeft = { 0, 0 }; 10 | int32_t width = 0; 11 | int32_t height = 0; 12 | olc::Decal* ptrDecal = nullptr; 13 | olc::Pixel tint = olc::WHITE; 14 | std::string path = "none"; 15 | size_t hash = 0; 16 | SpriteType spriteType = SpriteType::NONE; 17 | 18 | void SetHash() 19 | { 20 | IF_COUT{ std::cout << "hashing: " << path << std::endl; } 21 | hash = std::hash{}(path); 22 | IF_COUT{ std::cout << hash << std::endl; }; 23 | } 24 | 25 | void SetDecal() 26 | { 27 | ptrDecal = SpriteLoader::ptr->FindDecal(hash, (size_t)spriteType); 28 | 29 | if (ptrDecal == nullptr) 30 | { 31 | IF_COUT{ std::cout << "decal not found" << std::endl; } 32 | } 33 | } 34 | 35 | bool MouseHovering(olc::vi2d& mousePos) 36 | { 37 | if (width == 0 || height == 0) 38 | { 39 | return false; 40 | } 41 | else if (mousePos.x >= topLeft.x && mousePos.x <= topLeft.x + width) 42 | { 43 | if (mousePos.y >= topLeft.y && mousePos.y <= topLeft.y + height) 44 | { 45 | return true; 46 | } 47 | } 48 | 49 | return false; 50 | } 51 | 52 | void GreenTintOnHover(olc::vi2d& mousePos) 53 | { 54 | if (MouseHovering(mousePos)) 55 | { 56 | tint = olc::GREEN; 57 | } 58 | else 59 | { 60 | tint = olc::WHITE; 61 | } 62 | } 63 | 64 | bool Clicked(olc::vi2d& mousePos) 65 | { 66 | InputData& inputData = *InputData::ptr; 67 | 68 | if (MouseHovering(mousePos)) 69 | { 70 | if (inputData.key_mouse0) 71 | { 72 | inputData.key_mouse0->processed = true; 73 | return true; 74 | } 75 | } 76 | 77 | return false; 78 | } 79 | }; 80 | } -------------------------------------------------------------------------------- /FightingGameProject/Updater.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "StopCountData.h" 4 | 5 | namespace RB 6 | { 7 | class Updater 8 | { 9 | protected: 10 | size_t _updaterUpdateCount = 0; 11 | int32_t _stopCount = 0; 12 | std::vector _vecStopCounts; 13 | 14 | public: 15 | virtual void CustomUpdate() = 0; 16 | 17 | virtual void UpdateUpdateCount() 18 | { 19 | _updaterUpdateCount++; 20 | 21 | if (_updaterUpdateCount >= SIZE_MAX) 22 | { 23 | _updaterUpdateCount = 0; 24 | } 25 | } 26 | 27 | virtual void AddStopCountQueue(StopCountData data) 28 | { 29 | _vecStopCounts.push_back(data); 30 | } 31 | 32 | virtual void ProcessStopCounts() 33 | { 34 | //wait 1 frame before adding hitstops 35 | 36 | std::vector deleteIndexes; 37 | 38 | for (size_t i = 0; i < _vecStopCounts.size(); i++) 39 | { 40 | if (_vecStopCounts[i].oneFrameSkipped) 41 | { 42 | _stopCount += _vecStopCounts[i].stopCount; 43 | deleteIndexes.push_back(i); 44 | } 45 | 46 | if (!_vecStopCounts[i].oneFrameSkipped) 47 | { 48 | _vecStopCounts[i].oneFrameSkipped = true; 49 | } 50 | } 51 | 52 | for (size_t i = 0; i < deleteIndexes.size(); i++) 53 | { 54 | if (_vecStopCounts.size() > deleteIndexes[i]) 55 | { 56 | _vecStopCounts.erase(_vecStopCounts.begin() + deleteIndexes[i]); 57 | } 58 | } 59 | } 60 | }; 61 | } -------------------------------------------------------------------------------- /FightingGameProject/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This project uses olcPixelGameEngine by OneLoneCoder 3 | https://github.com/OneLoneCoder/olcPixelGameEngine 4 | 5 | License (OLC-3) 6 | Copyright 2018, 2019, 2020, 2021 OneLoneCoder.com 7 | 8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions or derivations of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions or derivative works in binary form must reproduce the above copyright notice. This list of conditions and the following disclaimer must be reproduced in the documentation and/or other materials provided with the distribution. 12 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | */ 16 | 17 | #include "Game.h" 18 | 19 | int main() 20 | { 21 | RB::Game game; 22 | game.Run(); 23 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C++ FightingGame by Roundbeargames 2 |
3 | This is an older version 4 |
5 | Latest version of this game is being updated here 6 |
7 | https://github.com/RoundBearChoi/CPP_FightingGame_2 8 | 9 |
10 |
11 | 12 | # Getting Started (Windows) 13 | 14 | 1. Download ZIP or clone repository 15 | 16 | 2. Open FightingGameProject.sln (using Visual Studio 2019 Community) 17 | 18 | https://visualstudio.microsoft.com/downloads 19 | 20 |
21 | 22 | # Getting Started (Linux - Ubuntu) 23 | 24 | 1. Download ZIP or clone repository 25 | 26 | 2. Install CMake, compiler, and packages 27 | 28 | ``` 29 | sudo apt install cmake g++ build-essential libglu1-mesa-dev libpng-dev 30 | ``` 31 | 32 | 3. Navigate to CMakeLists.txt and compile 33 | 34 | ``` 35 | cmake . 36 | make 37 | ./CPPFightingGame 38 | ``` 39 | 40 |
41 | 42 | # Devlog Videos 43 | 44 | https://youtube.com/playlist?list=PLWYGofN_jX5CNMI6tqlxNtTc7v9DkfNbC 45 | 46 |
47 | 48 | # Tutorial Videos & Code 49 | 50 | https://youtube.com/playlist?list=PLWYGofN_jX5Apmb8pJUD8NN3KskHW2lcy 51 | 52 | https://github.com/RoundBearChoi/CPP_Tutorial_Projects 53 | 54 |
55 | 56 | # License (OLC-3) 57 | 58 | This project uses olcPixelGameEngine by OneLoneCoder 59 | 60 |
61 | 62 | Copyright 2018, 2019, 2020, 2021 OneLoneCoder.com 63 | 64 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 65 | 66 | 1. Redistributions or derivations of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 67 | 2. Redistributions or derivative works in binary form must reproduce the above copyright notice. This list of conditions and the following disclaimer must be reproduced in the documentation and/or other materials provided with the distribution. 68 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 69 | 70 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 71 | --------------------------------------------------------------------------------