diff --git a/.gitignore b/.gitignore index d213ce4..66fafe0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,37 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Visual Studio -.vs -vcpkg_installed +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Visual Studio +.vs +vcpkg_installed x64 \ No newline at end of file diff --git a/README.md b/README.md index 681b31f..e577a7b 100644 --- a/README.md +++ b/README.md @@ -1 +1,30 @@ -# Space-Invader \ No newline at end of file +# Space Invader + +## Concept et genre + +Space Invader est un jeu d'arcade de type shoot'em up. + +## Scénario de base + +Des aliens envahissent la Terre et le joueur doit les détruire avant qu'ils n'atteignent son vaisseau sur +Terre. + +## Mécaniques de base + +Le vaisseau peut se déplacer horizontalement et tirer des projectiles vers le haut. Les aliens +descendent progressivement vers le vaisseau et tirent des projectiles vers le bas. + +## Style visuel + +Le jeu est en 2D avec une vue de profil. Le vaisseau et les aliens sont représentés par des formes +simple (rectangulaire et triangluraire) et couleurs différentes pour les différencier. + +## Objectifs + +Le joueur doit détruire tous les aliens avant qu'ils n'atteignent le vaisseau. Tout en évitant les +projectiles aliens. + +## Contrôles + +Le joueur peut se déplacer horizontalement avec les touches Q (Gauche) et D (Droite). Il peut tirer +avec la barre d'espace. diff --git a/Space-Invader.sln b/Space-Invader.sln index fca078e..fb89525 100644 --- a/Space-Invader.sln +++ b/Space-Invader.sln @@ -1,31 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34330.188 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Space-Invader", "Space-Invader.vcxproj", "{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x64.ActiveCfg = Debug|x64 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x64.Build.0 = Debug|x64 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x86.ActiveCfg = Debug|Win32 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x86.Build.0 = Debug|Win32 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x64.ActiveCfg = Release|x64 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x64.Build.0 = Release|x64 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.ActiveCfg = Release|Win32 - {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FC394877-8CB5-406D-846E-C6337AFC7323} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Space-Invader", "Space-Invader.vcxproj", "{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x64.ActiveCfg = Debug|x64 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x64.Build.0 = Debug|x64 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x86.ActiveCfg = Debug|Win32 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x86.Build.0 = Debug|Win32 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x64.ActiveCfg = Release|x64 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x64.Build.0 = Release|x64 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.ActiveCfg = Release|Win32 + {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC394877-8CB5-406D-846E-C6337AFC7323} + EndGlobalSection +EndGlobal diff --git a/include/Player.h b/include/Player.h index 1d54e42..e429b22 100644 --- a/include/Player.h +++ b/include/Player.h @@ -1,25 +1,25 @@ -#pragma once - -#define _USE_MATH_DEFINES - -#include -#include -#include - -using namespace std; -using namespace sf; - -class Player -{ -public: - Player(Vector2u screenSize); - - CircleShape& getShape() { return _shape; }; - void move(int direction); - -private: - CircleShape _shape; - - int _screenWidth; -}; - +#pragma once + +#define _USE_MATH_DEFINES + +#include +#include +#include + +using namespace std; +using namespace sf; + +class Player +{ +public: + Player(Vector2u screenSize); + + CircleShape& getShape() { return _shape; }; + void move(int direction); + +private: + CircleShape _shape; + + int _screenWidth; +}; + diff --git a/lib/Laser.cpp b/lib/Laser.cpp index 62703f1..2650ef3 100644 --- a/lib/Laser.cpp +++ b/lib/Laser.cpp @@ -1,11 +1,11 @@ -#include "Laser.h" - -Laser::Laser(Window& _window) -{ - _laser = RectangleShape(Vector2f(_window.getSize().x / 600, _window.getSize().y / 30)); - _laser.setFillColor(Color::White); -} - -void Laser::setInitialPosition(Vector2f position) { - _laser.setPosition(Vector2f(position.x - (_laser.getScale().x / 2), position.y)); +#include "Laser.h" + +Laser::Laser(Window& _window) +{ + _laser = RectangleShape(Vector2f(_window.getSize().x / 600, _window.getSize().y / 30)); + _laser.setFillColor(Color::White); +} + +void Laser::setInitialPosition(Vector2f position) { + _laser.setPosition(Vector2f(position.x - (_laser.getScale().x / 2), position.y)); } \ No newline at end of file diff --git a/lib/Player.cpp b/lib/Player.cpp index 6fe7ac0..0904499 100644 --- a/lib/Player.cpp +++ b/lib/Player.cpp @@ -1,22 +1,22 @@ -#include "Player.h"; - -Player::Player(Vector2u screenSize): _screenWidth(screenSize.x) { - _shape = CircleShape(screenSize.x / 70, 3); - _shape.setFillColor(Color(52, 252, 5)); - - float shapeHeight = _shape.getRadius() * 1.5; - - _shape.setPosition(_screenWidth / 2.f, screenSize.y - shapeHeight); -} - -void Player::move(int direction) { - float max = _screenWidth - (_shape.getRadius() * 2); - float result = (_screenWidth / 724.0)*direction; - - // Prevent leaving the window - if (_shape.getPosition().x + result < 0 || _shape.getPosition().x + result > max) { - result = 0; - } - - _shape.move(result, 0); +#include "Player.h"; + +Player::Player(Vector2u screenSize): _screenWidth(screenSize.x) { + _shape = CircleShape(screenSize.x / 70, 3); + _shape.setFillColor(Color(52, 252, 5)); + + float shapeHeight = _shape.getRadius() * 1.5; + + _shape.setPosition(_screenWidth / 2.f, screenSize.y - shapeHeight); +} + +void Player::move(int direction) { + float max = _screenWidth - (_shape.getRadius() * 2); + float result = (_screenWidth / 724.0)*direction; + + // Prevent leaving the window + if (_shape.getPosition().x + result < 0 || _shape.getPosition().x + result > max) { + result = 0; + } + + _shape.move(result, 0); } \ No newline at end of file diff --git a/lib/Shield.cpp b/lib/Shield.cpp index a877c88..51bec26 100644 --- a/lib/Shield.cpp +++ b/lib/Shield.cpp @@ -1,13 +1,13 @@ -#include "Shield.h" - -Shield::Shield(Window& window) { - int shapeWidth = window.getSize().x / 10; - int shapeHeight = window.getSize().y / 35; - - _shape = RectangleShape(Vector2f(shapeWidth, shapeHeight)); - _shape.setFillColor(Color(Color(52, 252, 5))); -} - -void Shield::setPosition(Vector2f position) { - _shape.setPosition(position.x + _shape.getSize().x, position.y - _shape.getScale().y); +#include "Shield.h" + +Shield::Shield(Window& window) { + int shapeWidth = window.getSize().x / 10; + int shapeHeight = window.getSize().y / 35; + + _shape = RectangleShape(Vector2f(shapeWidth, shapeHeight)); + _shape.setFillColor(Color(Color(52, 252, 5))); +} + +void Shield::setPosition(Vector2f position) { + _shape.setPosition(position.x + _shape.getSize().x, position.y - _shape.getScale().y); } \ No newline at end of file diff --git a/main.cpp b/main.cpp index 9376abc..683b529 100644 --- a/main.cpp +++ b/main.cpp @@ -1,16 +1,16 @@ -using namespace std; - -#include - -#include "GameManager.h" - -int main() -{ - cout << "Starting game..." << endl; - GameManager gameManager; - - cout << "Game started." << endl; - gameManager.run(); - - return 0; +using namespace std; + +#include + +#include "GameManager.h" + +int main() +{ + cout << "Starting game..." << endl; + GameManager gameManager; + + cout << "Game started." << endl; + gameManager.run(); + + return 0; } \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 041cb26..1665743 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,10 +1,10 @@ -{ - "name": "space-invader", - "version": "0.0.0", - "description": "Space Invader Copy", - "dependencies": [ - { - "name": "sfml" - } - ] +{ + "name": "space-invader", + "version": "0.0.0", + "description": "Space Invader Copy", + "dependencies": [ + { + "name": "sfml" + } + ] } \ No newline at end of file