Skip to content
Permalink
Browse files

finished part 4

  • Loading branch information
thatgamesguy committed Jul 3, 2018
1 parent 734c57c commit d0c063e9a3cba7613f02579d3af92198e50eb659
Showing with 6,664 additions and 62 deletions.
  1. +26 −0 Part 1/src/C_DamageOnCollision.cpp
  2. +25 −0 Part 1/src/C_DamageOnCollision.hpp
  3. +27 −0 Part 1/src/C_DamageOnWallHit.cpp
  4. +26 −0 Part 1/src/C_DamageOnWallHit.hpp
  5. +13 −0 Part 1/src/C_Energy.cpp
  6. +19 −0 Part 1/src/C_Energy.hpp
  7. +26 −0 Part 2/src/C_DamageOnCollision.cpp
  8. +25 −0 Part 2/src/C_DamageOnCollision.hpp
  9. +27 −0 Part 2/src/C_DamageOnWallHit.cpp
  10. +26 −0 Part 2/src/C_DamageOnWallHit.hpp
  11. +13 −0 Part 2/src/C_Energy.cpp
  12. +19 −0 Part 2/src/C_Energy.hpp
  13. +26 −0 Part 3/src/C_DamageOnCollision.cpp
  14. +25 −0 Part 3/src/C_DamageOnCollision.hpp
  15. +27 −0 Part 3/src/C_DamageOnWallHit.cpp
  16. +26 −0 Part 3/src/C_DamageOnWallHit.hpp
  17. +13 −0 Part 3/src/C_Energy.cpp
  18. +19 −0 Part 3/src/C_Energy.hpp
  19. BIN Part 4/resources/that_games_guy_logo.png
  20. BIN Part 4/resources/ufo1.png
  21. BIN Part 4/resources/ufo2.png
  22. BIN Part 4/resources/ufo3.png
  23. BIN Part 4/resources/ufo4.png
  24. +83 −0 Part 4/src/Animation.cpp
  25. +50 −0 Part 4/src/Animation.hpp
  26. +45 −0 Part 4/src/Bitmask.cpp
  27. +26 −0 Part 4/src/Bitmask.hpp
  28. +68 −0 Part 4/src/C_Animation.cpp
  29. +36 −0 Part 4/src/C_Animation.hpp
  30. +26 −0 Part 4/src/C_DamageOnCollision.cpp
  31. +25 −0 Part 4/src/C_DamageOnCollision.hpp
  32. +27 −0 Part 4/src/C_DamageOnWallHit.cpp
  33. +26 −0 Part 4/src/C_DamageOnWallHit.hpp
  34. +13 −0 Part 4/src/C_Energy.cpp
  35. +19 −0 Part 4/src/C_Energy.hpp
  36. +13 −0 Part 4/src/C_InstanceID.cpp
  37. +17 −0 Part 4/src/C_InstanceID.hpp
  38. +63 −0 Part 4/src/C_KeyboardMovement.cpp
  39. +27 −0 Part 4/src/C_KeyboardMovement.hpp
  40. +76 −0 Part 4/src/C_NeuralNetwork.cpp
  41. +38 −0 Part 4/src/C_NeuralNetwork.hpp
  42. +43 −0 Part 4/src/C_ScreenWrapAround.cpp
  43. +21 −0 Part 4/src/C_ScreenWrapAround.hpp
  44. +81 −0 Part 4/src/C_Sight.cpp
  45. +58 −0 Part 4/src/C_Sight.hpp
  46. +70 −0 Part 4/src/C_Sprite.cpp
  47. +36 −0 Part 4/src/C_Sprite.hpp
  48. +50 −0 Part 4/src/C_Transform.cpp
  49. +29 −0 Part 4/src/C_Transform.hpp
  50. +30 −0 Part 4/src/C_Velocity.cpp
  51. +23 −0 Part 4/src/C_Velocity.hpp
  52. +24 −0 Part 4/src/Component.hpp
  53. +55 −0 Part 4/src/Game.cpp
  54. +36 −0 Part 4/src/Game.hpp
  55. +102 −0 Part 4/src/GeneticAlgorithm.cpp
  56. +47 −0 Part 4/src/GeneticAlgorithm.hpp
  57. +41 −0 Part 4/src/Input.cpp
  58. +31 −0 Part 4/src/Input.hpp
  59. +17 −0 Part 4/src/Main.cpp
  60. +80 −0 Part 4/src/NeuralNetwork.cpp
  61. +28 −0 Part 4/src/NeuralNetwork.hpp
  62. +16 −0 Part 4/src/Neuron.cpp
  63. +14 −0 Part 4/src/Neuron.hpp
  64. +12 −0 Part 4/src/NeuronLayer.cpp
  65. +14 −0 Part 4/src/NeuronLayer.hpp
  66. +57 −0 Part 4/src/Object.cpp
  67. +70 −0 Part 4/src/Object.hpp
  68. +80 −0 Part 4/src/ObjectCollection.cpp
  69. +30 −0 Part 4/src/ObjectCollection.hpp
  70. +64 −0 Part 4/src/ResourceAllocator.hpp
  71. +21 −0 Part 4/src/Scene.hpp
  72. +38 −0 Part 4/src/SceneGame.cpp
  73. +37 −0 Part 4/src/SceneGame.hpp
  74. +50 −0 Part 4/src/SceneSplashScreen.cpp
  75. +41 −0 Part 4/src/SceneSplashScreen.hpp
  76. +76 −0 Part 4/src/SceneStateMachine.cpp
  77. +30 −0 Part 4/src/SceneStateMachine.hpp
  78. +27 −0 Part 4/src/Tile.h
  79. +169 −0 Part 4/src/TileMapParser.cpp
  80. +55 −0 Part 4/src/TileMapParser.hpp
  81. +19 −0 Part 4/src/Utilities.h
  82. +56 −0 Part 4/src/Window.cpp
  83. +26 −0 Part 4/src/Window.hpp
  84. +22 −0 Part 4/src/WorkingDirectory.cpp
  85. +24 −0 Part 4/src/WorkingDirectory.hpp
  86. +2,596 −0 Part 4/src/rapidxml.hpp
  87. +174 −0 Part 4/src/rapidxml_iterators.hpp
  88. +421 −0 Part 4/src/rapidxml_print.hpp
  89. +122 −0 Part 4/src/rapidxml_utils.hpp
  90. +24 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO.xcodeproj/project.pbxproj
  91. +26 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_DamageOnCollision.cpp
  92. +25 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_DamageOnCollision.hpp
  93. +27 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_DamageOnWallHit.cpp
  94. +26 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_DamageOnWallHit.hpp
  95. +13 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_Energy.cpp
  96. +19 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/C_Energy.hpp
  97. +102 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/GeneticAlgorithm.cpp
  98. +47 −0 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/GeneticAlgorithm.hpp
  99. +4 −55 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/SceneGame.cpp
  100. +2 −7 Xcode Project/AI Experiments 1 - UFO/AI Experiments 1 - UFO/SceneGame.hpp
@@ -0,0 +1,26 @@
#include "C_DamageOnCollision.hpp"
#include "Object.hpp"

C_DamageOnCollision::C_DamageOnCollision(Object* owner) : Component(owner), energyReducedOnContact(20000.f){}

void C_DamageOnCollision::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnCollision::Update(float deltaTime)
{
const std::vector<UFOData>& agentsInSight = sight->GetAll();
const float agentRadius = sight->GetRadius();

for (int i = 0; i < agentsInSight.size(); i++)
{
const UFOData& data = agentsInSight[i];

if(data.distance <= agentRadius * 0.5f)
{
energy->Set(energy->Get() - energyReducedOnContact * deltaTime);
}
}
}
@@ -0,0 +1,25 @@
#ifndef C_DamageOnCollision_hpp
#define C_DamageOnCollision_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnCollision : public Component
{
public:
C_DamageOnCollision(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;
float energyReducedOnContact;
};

#endif /* C_DamageOnCollision_hpp */


@@ -0,0 +1,27 @@
#include "C_DamageOnWallHit.hpp"
#include "Object.hpp"

C_DamageOnWallHit::C_DamageOnWallHit(Object* owner) : Component(owner), windowSize(1920, 1080) {}

void C_DamageOnWallHit::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnWallHit::Update(float deltaTime)
{
const sf::Vector2f& pos = owner->transform->GetPosition();
const float radius = sight->GetRadius();
const float halfRadius = radius * 0.5f;

if(pos.x <= radius || pos.x >= windowSize.x - halfRadius || pos.y <= radius || pos.y >= windowSize.y - halfRadius)
{
energy->Set(0.f);
}
}

void C_DamageOnWallHit::SetWindowSize(const sf::Vector2u& windowSize)
{
this->windowSize = windowSize;
}
@@ -0,0 +1,26 @@
#ifndef C_DamageOnWallHit_hpp
#define C_DamageOnWallHit_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnWallHit : public Component
{
public:
C_DamageOnWallHit(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

void SetWindowSize(const sf::Vector2u& windowSize);

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;

sf::Vector2u windowSize;
};

#endif /* C_DamageOnWallHit_hpp */
@@ -0,0 +1,13 @@
#include "C_Energy.hpp"

C_Energy::C_Energy(Object* owner) : Component(owner), value(100.f) {}

void C_Energy::Set(float newEnergy)
{
value = newEnergy;
}

float C_Energy::Get() const
{
return value;
}
@@ -0,0 +1,19 @@
#ifndef C_Energy_hpp
#define C_Energy_hpp

#include "Component.hpp"

class C_Energy : public Component
{
public:
C_Energy(Object* owner);

void Set(float value);
float Get() const;

private:
float value;

};

#endif /* C_Energy_hpp */
@@ -0,0 +1,26 @@
#include "C_DamageOnCollision.hpp"
#include "Object.hpp"

C_DamageOnCollision::C_DamageOnCollision(Object* owner) : Component(owner), energyReducedOnContact(20000.f){}

void C_DamageOnCollision::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnCollision::Update(float deltaTime)
{
const std::vector<UFOData>& agentsInSight = sight->GetAll();
const float agentRadius = sight->GetRadius();

for (int i = 0; i < agentsInSight.size(); i++)
{
const UFOData& data = agentsInSight[i];

if(data.distance <= agentRadius * 0.5f)
{
energy->Set(energy->Get() - energyReducedOnContact * deltaTime);
}
}
}
@@ -0,0 +1,25 @@
#ifndef C_DamageOnCollision_hpp
#define C_DamageOnCollision_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnCollision : public Component
{
public:
C_DamageOnCollision(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;
float energyReducedOnContact;
};

#endif /* C_DamageOnCollision_hpp */


@@ -0,0 +1,27 @@
#include "C_DamageOnWallHit.hpp"
#include "Object.hpp"

C_DamageOnWallHit::C_DamageOnWallHit(Object* owner) : Component(owner), windowSize(1920, 1080) {}

void C_DamageOnWallHit::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnWallHit::Update(float deltaTime)
{
const sf::Vector2f& pos = owner->transform->GetPosition();
const float radius = sight->GetRadius();
const float halfRadius = radius * 0.5f;

if(pos.x <= radius || pos.x >= windowSize.x - halfRadius || pos.y <= radius || pos.y >= windowSize.y - halfRadius)
{
energy->Set(0.f);
}
}

void C_DamageOnWallHit::SetWindowSize(const sf::Vector2u& windowSize)
{
this->windowSize = windowSize;
}
@@ -0,0 +1,26 @@
#ifndef C_DamageOnWallHit_hpp
#define C_DamageOnWallHit_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnWallHit : public Component
{
public:
C_DamageOnWallHit(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

void SetWindowSize(const sf::Vector2u& windowSize);

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;

sf::Vector2u windowSize;
};

#endif /* C_DamageOnWallHit_hpp */
@@ -0,0 +1,13 @@
#include "C_Energy.hpp"

C_Energy::C_Energy(Object* owner) : Component(owner), value(100.f) {}

void C_Energy::Set(float newEnergy)
{
value = newEnergy;
}

float C_Energy::Get() const
{
return value;
}
@@ -0,0 +1,19 @@
#ifndef C_Energy_hpp
#define C_Energy_hpp

#include "Component.hpp"

class C_Energy : public Component
{
public:
C_Energy(Object* owner);

void Set(float value);
float Get() const;

private:
float value;

};

#endif /* C_Energy_hpp */
@@ -0,0 +1,26 @@
#include "C_DamageOnCollision.hpp"
#include "Object.hpp"

C_DamageOnCollision::C_DamageOnCollision(Object* owner) : Component(owner), energyReducedOnContact(20000.f){}

void C_DamageOnCollision::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnCollision::Update(float deltaTime)
{
const std::vector<UFOData>& agentsInSight = sight->GetAll();
const float agentRadius = sight->GetRadius();

for (int i = 0; i < agentsInSight.size(); i++)
{
const UFOData& data = agentsInSight[i];

if(data.distance <= agentRadius * 0.5f)
{
energy->Set(energy->Get() - energyReducedOnContact * deltaTime);
}
}
}
@@ -0,0 +1,25 @@
#ifndef C_DamageOnCollision_hpp
#define C_DamageOnCollision_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnCollision : public Component
{
public:
C_DamageOnCollision(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;
float energyReducedOnContact;
};

#endif /* C_DamageOnCollision_hpp */


@@ -0,0 +1,27 @@
#include "C_DamageOnWallHit.hpp"
#include "Object.hpp"

C_DamageOnWallHit::C_DamageOnWallHit(Object* owner) : Component(owner), windowSize(1920, 1080) {}

void C_DamageOnWallHit::Awake()
{
energy = owner->GetComponent<C_Energy>();
sight = owner->GetComponent<C_Sight>();
}

void C_DamageOnWallHit::Update(float deltaTime)
{
const sf::Vector2f& pos = owner->transform->GetPosition();
const float radius = sight->GetRadius();
const float halfRadius = radius * 0.5f;

if(pos.x <= radius || pos.x >= windowSize.x - halfRadius || pos.y <= radius || pos.y >= windowSize.y - halfRadius)
{
energy->Set(0.f);
}
}

void C_DamageOnWallHit::SetWindowSize(const sf::Vector2u& windowSize)
{
this->windowSize = windowSize;
}
@@ -0,0 +1,26 @@
#ifndef C_DamageOnWallHit_hpp
#define C_DamageOnWallHit_hpp

#include "Component.hpp"
#include "C_Energy.hpp"
#include "C_Sight.hpp"

class C_DamageOnWallHit : public Component
{
public:
C_DamageOnWallHit(Object* owner);

void Awake() override;

void Update(float deltaTime) override;

void SetWindowSize(const sf::Vector2u& windowSize);

private:
std::shared_ptr<C_Energy> energy;
std::shared_ptr<C_Sight> sight;

sf::Vector2u windowSize;
};

#endif /* C_DamageOnWallHit_hpp */

0 comments on commit d0c063e

Please sign in to comment.
You can’t perform that action at this time.