Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 11 animations #130

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
93f3e44
Added my own window file
Alcatraz714 Jul 28, 2024
676acb2
Added new Main.cpp
Alcatraz714 Jul 29, 2024
fe06d7c
Shapes added
Alcatraz714 Jul 29, 2024
a096bda
Logo and Sprites
Alcatraz714 Jul 29, 2024
fcc675e
added text and sprites
Alcatraz714 Jul 29, 2024
f3f7ec0
Merge pull request #1 from Alcatraz714/Feature-1-SFML
Alcatraz714 Jul 29, 2024
9b096bb
OOP
Alcatraz714 Jul 29, 2024
1116b79
Added keyboard inputs and getters and setters
Alcatraz714 Jul 29, 2024
f7c02e3
Added move functions
Alcatraz714 Jul 29, 2024
45ea812
Added Header and Source folders with GameService
Alcatraz714 Jul 30, 2024
e527f50
comments and gameloop code shift
Alcatraz714 Jul 30, 2024
5fe3d91
Merge pull request #2 from Alcatraz714/Feature-2-OOP
Alcatraz714 Jul 30, 2024
a5529a7
Added Service Locator header and cpp
Alcatraz714 Jul 30, 2024
067493a
Merge pull request #3 from Alcatraz714/Feature-2-OOP
Alcatraz714 Jul 30, 2024
9c1cd5a
Changed Architecture and added links between units
Alcatraz714 Jul 30, 2024
88e545b
Merge pull request #4 from Alcatraz714/Feature-2-OOP
Alcatraz714 Jul 30, 2024
452befa
added event service header and cpp
Alcatraz714 Jul 30, 2024
c2b5ccf
Merge pull request #5 from Alcatraz714/Feature-2-OOP
Alcatraz714 Jul 30, 2024
abdf09b
Added Player Service Header and cpp
Alcatraz714 Jul 31, 2024
e759f6e
Added time Service
Alcatraz714 Jul 31, 2024
974eae8
Merge pull request #6 from Alcatraz714/Feature-3-Player-Ship
Alcatraz714 Jul 31, 2024
943dfd9
Split the player into 3 different units
Alcatraz714 Jul 31, 2024
63c6c72
Merge pull request #7 from Alcatraz714/Feature-3-Player-Ship
Alcatraz714 Jul 31, 2024
e01b88b
Added code to player units
Alcatraz714 Jul 31, 2024
c642815
Merge pull request #8 from Alcatraz714/Feature-3-Player-Ship
Alcatraz714 Jul 31, 2024
621747d
Delete Space-Invaders/Header directory
Alcatraz714 Aug 1, 2024
4339484
Delete Space-Invaders/Source directory
Alcatraz714 Aug 1, 2024
8df483d
Delete Space-Invaders/main.cpp
Alcatraz714 Aug 1, 2024
f01bc02
Delete Space-Invaders/Space-Invaders.sln
Alcatraz714 Aug 1, 2024
5844287
New Feature 3 Arch branch
Alcatraz714 Aug 1, 2024
58622f5
Delete Space-Invaders/Header directory
Alcatraz714 Aug 1, 2024
4f64943
Delete Space-Invaders/Source directory
Alcatraz714 Aug 1, 2024
97ebea3
Merge pull request #10 from Alcatraz714/Feature-3-Player-Ship
Alcatraz714 Aug 1, 2024
2f3005b
Added Namespaces
Alcatraz714 Aug 1, 2024
ff152f2
Game State added
Alcatraz714 Aug 2, 2024
6601dac
Added Main Menu and lifecycle
Alcatraz714 Aug 2, 2024
50e219c
Added new control functions
Alcatraz714 Aug 2, 2024
35c51f6
Added EnemyService
Alcatraz714 Aug 4, 2024
f515f61
Added movement
Alcatraz714 Aug 4, 2024
fb6f2c4
fixed move and multiple enemies
Alcatraz714 Aug 4, 2024
c2cf915
Added Gameplay Services
Alcatraz714 Aug 4, 2024
f3b7383
Enemy Config
Alcatraz714 Aug 6, 2024
39fdfbe
Added Zapper and Sub Zero
Alcatraz714 Aug 6, 2024
e448b2c
Added Element folder MVC
Alcatraz714 Aug 6, 2024
446a3a0
MVC and Bunker
Alcatraz714 Aug 7, 2024
9d4ba43
Added Config
Alcatraz714 Aug 7, 2024
b92bb21
Added Sound Playback
Alcatraz714 Aug 7, 2024
56f32a4
Added Bullet folder and interface
Alcatraz714 Aug 8, 2024
37a6b31
FireBullet Added
Alcatraz714 Aug 8, 2024
2d6b1fb
Merge pull request #11 from Alcatraz714/Feature-7-Bullets
Alcatraz714 Aug 9, 2024
547651c
Added ICollectible
Alcatraz714 Aug 9, 2024
d9a3336
Added UFO and other thunder snake
Alcatraz714 Aug 10, 2024
a567828
UI interface added
Alcatraz714 Aug 10, 2024
b284f49
UIService completed and implemented
Alcatraz714 Aug 11, 2024
49e08fa
Merge pull request #12 from Alcatraz714/Feature-9-UI
Alcatraz714 Aug 11, 2024
51b073f
Add files via upload
Alcatraz714 Aug 11, 2024
aae6e42
Delete Header directory
Alcatraz714 Aug 11, 2024
6982a28
added Entity
Alcatraz714 Aug 11, 2024
caa2325
Added Entity types
Alcatraz714 Aug 11, 2024
e71eb4b
Added Collision service
Alcatraz714 Aug 12, 2024
41bd3b1
Collision service added
Alcatraz714 Aug 12, 2024
05d83a2
Added last changes to the bullets
Alcatraz714 Aug 14, 2024
724cf22
Added collision to bullets and bunkers
Alcatraz714 Aug 14, 2024
535222d
Added Animation config
Alcatraz714 Aug 16, 2024
ee2ed05
Added animation service folder mvc
Alcatraz714 Aug 16, 2024
5e3d67a
Header update bug fix
Alcatraz714 Aug 31, 2024
d1e3443
Fixed collision bug
Alcatraz714 Aug 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Space-Invaders/Header/AnimationSystem/AnimationService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once
#include <vector>
#include <SFML/System/Vector2.hpp>
#include "../../header/AnimationSystem/AnimationSystem.h"

namespace Animation
{
enum class AnimationType
{
EXPLOSION,
};

class AnimationService
{
private:
std::vector<AnimationSystem*> animation_system_list;
std::vector<AnimationSystem*> flagged_animation_system_list;

AnimationSystemConfig getAnimationSystemConfig(AnimationType animation_type);
void destroyFlaggedAnimationSystem();
void destroy();

public:
AnimationService();
virtual ~AnimationService();

void initialize();
void update();
void render();

void reset();

void spawnAnimationSystem(sf::Vector2f position, AnimationType animation_type);
void destroyAnimationSystem(AnimationSystem* animation_system);
};
}
33 changes: 33 additions & 0 deletions Space-Invaders/Header/AnimationSystem/AnimationSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once
#include <SFML/Graphics.hpp>
#include "../../header/AnimationSystem/AnimationSystemConfig.h"
#include "../../header/UI/UIElement/ImageView.h"

namespace Animation
{
class AnimationSystem
{
private:
AnimationSystemConfig animation_system_config;

sf::Vector2f animation_position;
UI::UIElement::ImageView* animation_image;

void createUIElements();
void initializeImage();

int current_frame;
sf::Clock clock;
sf::Time frame_time;

public:
AnimationSystem(AnimationSystemConfig config);
~AnimationSystem();

void initialize(sf::Vector2f position);
void update();
void render();

void destroy();
};
}
30 changes: 30 additions & 0 deletions Space-Invaders/Header/AnimationSystem/AnimationSystemConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
namespace Animation
{
struct AnimationSystemConfig
{
sf::String Animation_texture_path;

float sprite_sheet_width;
float sprite_sheet_height;

//one frame of the sprite sheet - W x H
float tile_width;
float tile_height;

int number_of_animation_frames; //total frames
float frame_duration; //duration of a single frame - the amount to wait for next frame in the animation spritesheet

AnimationSystemConfig() = default; // Use default for default constructor

//this will allow us to initialize an animation with it's configuration.
AnimationSystemConfig(sf::String texture_path, float sprite_width, float sprite_height, float t_width, float t_height, int frames, float duration) :
Animation_texture_path(texture_path),
sprite_sheet_width(sprite_width),
sprite_sheet_height(sprite_height),
tile_width(t_width),
tile_height(t_height),
number_of_animation_frames(frames),
frame_duration(duration) {}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
#include "AnimationSystemConfig.h"
#include "../../Header/Global/Config.h"

namespace Animation
{
const AnimationSystemConfig explosion_animation_config(Global::Config::explosion_texture_path, 70.0f, 80.0f, 14.28f, 20.0f, 7, 0.03f);
}
28 changes: 28 additions & 0 deletions Space-Invaders/Header/Bullet/BulletConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include <SFML/Graphics.hpp>

namespace Bullet
{
enum class BulletType
{
LASER_BULLET,
TORPEDO,
FROST_BULLET,
};

enum class MovementDirection
{
UP, //player needs to shoot in upward direction
DOWN, // enemies always shoot in downward direction
};

class BulletConfig
{
public:
static const sf::String laser_bullet_texture_path;
static const sf::String torpedoe_texture_path;
static const sf::String frost_beam_texture_path;

static sf::String getBulletTexturePath(BulletType bullet_type);
};
}
48 changes: 48 additions & 0 deletions Space-Invaders/Header/Bullet/BulletController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once
#include "../../Header/Projectile/IProjectile.h"
#include "../../Header/Entity/EntityConfig.h"
#include "../Collision/ICollider.h"

namespace Bullet
{
class BulletView;
class BulletModel;
enum class BulletType;

class BulletController : public Projectile::IProjectile, public Collision::ICollider
{
protected:

BulletView* bullet_view;
BulletModel* bullet_model;

void updateProjectilePosition() override;

//Collision funcs
void processBulletCollision(ICollider* other_collider);
void processEnemyCollision(ICollider* other_collider);
void processPlayerCollision(ICollider* other_collider);
void processBunkerCollision(ICollider* other_collider);


void moveUp();
void moveDown();
void handleOutOfBounds();

public:

BulletController(BulletType type, Entity::EntityType owner_type);
virtual ~BulletController();

void initialize(sf::Vector2f position, Bullet::MovementDirection direction) override;
void update() override;
void render() override;

sf::Vector2f getProjectilePosition() override;
BulletType getBulletType();
Entity::EntityType getOwnerEntityType();

const sf::Sprite& getColliderSprite() override;
void onCollision(ICollider* other_collider) override;
};
}
40 changes: 40 additions & 0 deletions Space-Invaders/Header/Bullet/BulletModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once
#include <SFML/Graphics.hpp>
#include "../../Header/Entity/EntityConfig.h"

namespace Bullet
{
enum class BulletType;
enum class MovementDirection;

class BulletModel
{
private:
float movement_speed = 300.f;
sf::Vector2f bullet_position;

BulletType bullet_type;
Entity::EntityType owner_type;
MovementDirection movement_direction;

public:

BulletModel(BulletType type, Entity::EntityType owner_type);
~BulletModel();

void initialize(sf::Vector2f position, MovementDirection direction);

sf::Vector2f getBulletPosition();
void setBulletPosition(sf::Vector2f position);

BulletType getBulletType();

Entity::EntityType getOwnerEntityType();

MovementDirection getMovementDirection();
void setMovementDirection(MovementDirection direction);

float getMovementSpeed();
void setMovementSpeed(float speed);
};
}
39 changes: 39 additions & 0 deletions Space-Invaders/Header/Bullet/BulletService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
#include <vector>
#include "SFML/System/Vector2.hpp"
#include "../../Header/Entity/EntityConfig.h"
#include "../../Header/Projectile/IProjectile.h"

namespace Bullet
{
class BulletController;
enum class BulletType;
enum class MovementDirection;

class BulletService
{
private:

std::vector<Projectile::IProjectile*> flagged_bullet_list;
std::vector<Projectile::IProjectile*> bullet_list;

BulletController* createBullet(BulletType type, Entity::EntityType owner_type);

bool isValidBullet(int index_i, std::vector<Projectile::IProjectile*>& bullet_list);
void destroyFlaggedBullets();

void destroy();

public:
BulletService();
virtual ~BulletService();

void initialize();
void update();
void render();
void reset();

BulletController* spawnBullet(BulletType type, sf::Vector2f position, MovementDirection direction, Entity::EntityType owner_type);
void destroyBullet(BulletController* bullet_controller);
};
}
34 changes: 34 additions & 0 deletions Space-Invaders/Header/Bullet/BulletView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include <SFML/Graphics.hpp>
#include "../../Header/UI/UIElement/ImageView.h"

namespace Bullet
{
class BulletController;

class BulletView
{
private:
const float bullet_sprite_width = 18.f;
const float bullet_sprite_height = 18.f;

BulletController* bullet_controller;
UI::UIElement::ImageView* bullet_image;

void createUIElements();
void initializeImage();
sf::String getBulletTexturePath();

void destroy();

public:
BulletView();
~BulletView();

void initialize(BulletController* controller);
void update();
void render();

const sf::Sprite& getBulletSprite();
};
}
20 changes: 20 additions & 0 deletions Space-Invaders/Header/Bullet/Controllers/FrostBulletController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "../../Header/Bullet/BulletController.h"

namespace Bullet
{
namespace Controller
{
class FrostBulletController : public BulletController
{
private:
const float frost_bullet_movement_speed = 500.f;

public:
FrostBulletController(BulletType type, Entity::EntityType owner_type);
~FrostBulletController();

void initialize(sf::Vector2f position, MovementDirection direction) override;
};
}
}
17 changes: 17 additions & 0 deletions Space-Invaders/Header/Bullet/Controllers/LaserBulletController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include "../../Header/Bullet/BulletController.h"

namespace Bullet
{
namespace Controller
{
class LaserBulletController : public BulletController
{
public:
LaserBulletController(BulletType type, Entity::EntityType owner_type);
~LaserBulletController();

void initialize(sf::Vector2f position, MovementDirection direction) override;
};
}
}
20 changes: 20 additions & 0 deletions Space-Invaders/Header/Bullet/Controllers/TorpedoController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "../../Header/Bullet/BulletController.h"

namespace Bullet
{
namespace Controller
{
class TorpedoController : public BulletController
{
private:
const float torpedo_movement_speed = 200.f;

public:
TorpedoController(BulletType type, Entity::EntityType owner_type);
~TorpedoController();

void initialize(sf::Vector2f position, MovementDirection direction) override;
};
}
}
17 changes: 17 additions & 0 deletions Space-Invaders/Header/Collectible/ICollectible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include <SFML/System/Vector2.hpp>

namespace Collectible
{
class ICollectible
{
public:
virtual void onCollected() = 0;
virtual void initialize(sf::Vector2f position) = 0;
virtual void update() = 0;
virtual void render() = 0;
virtual sf::Vector2f getCollectiblePosition() = 0;

virtual ~ICollectible() {};
};
}
Loading