This commit is contained in:
2024-01-30 16:22:53 +01:00
9 changed files with 189 additions and 160 deletions
+36 -36
View File
@@ -1,37 +1,37 @@
# Prerequisites # Prerequisites
*.d *.d
# Compiled Object files # Compiled Object files
*.slo *.slo
*.lo *.lo
*.o *.o
*.obj *.obj
# Precompiled Headers # Precompiled Headers
*.gch *.gch
*.pch *.pch
# Compiled Dynamic libraries # Compiled Dynamic libraries
*.so *.so
*.dylib *.dylib
*.dll *.dll
# Fortran module files # Fortran module files
*.mod *.mod
*.smod *.smod
# Compiled Static libraries # Compiled Static libraries
*.lai *.lai
*.la *.la
*.a *.a
*.lib *.lib
# Executables # Executables
*.exe *.exe
*.out *.out
*.app *.app
# Visual Studio # Visual Studio
.vs .vs
vcpkg_installed vcpkg_installed
x64 x64
+30 -1
View File
@@ -1 +1,30 @@
# Space-Invader # 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.
+31 -31
View File
@@ -1,31 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188 VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Space-Invader", "Space-Invader.vcxproj", "{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Space-Invader", "Space-Invader.vcxproj", "{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x64.ActiveCfg = Debug|x64 {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|x64.Build.0 = Debug|x64
{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Debug|x86.ActiveCfg = Debug|Win32 {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}.Debug|x86.Build.0 = Debug|Win32
{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x64.ActiveCfg = Release|x64 {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|x64.Build.0 = Release|x64
{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.ActiveCfg = Release|Win32 {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.ActiveCfg = Release|Win32
{77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.Build.0 = Release|Win32 {77E81A7A-9E66-4C14-8C8C-2D046FEB7DE8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC394877-8CB5-406D-846E-C6337AFC7323} SolutionGuid = {FC394877-8CB5-406D-846E-C6337AFC7323}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
+25 -25
View File
@@ -1,25 +1,25 @@
#pragma once #pragma once
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
using namespace sf; using namespace sf;
class Player class Player
{ {
public: public:
Player(Vector2u screenSize); Player(Vector2u screenSize);
CircleShape& getShape() { return _shape; }; CircleShape& getShape() { return _shape; };
void move(int direction); void move(int direction);
private: private:
CircleShape _shape; CircleShape _shape;
int _screenWidth; int _screenWidth;
}; };
+10 -10
View File
@@ -1,11 +1,11 @@
#include "Laser.h" #include "Laser.h"
Laser::Laser(Window& _window) Laser::Laser(Window& _window)
{ {
_laser = RectangleShape(Vector2f(_window.getSize().x / 600, _window.getSize().y / 30)); _laser = RectangleShape(Vector2f(_window.getSize().x / 600, _window.getSize().y / 30));
_laser.setFillColor(Color::White); _laser.setFillColor(Color::White);
} }
void Laser::setInitialPosition(Vector2f position) { void Laser::setInitialPosition(Vector2f position) {
_laser.setPosition(Vector2f(position.x - (_laser.getScale().x / 2), position.y)); _laser.setPosition(Vector2f(position.x - (_laser.getScale().x / 2), position.y));
} }
+21 -21
View File
@@ -1,22 +1,22 @@
#include "Player.h"; #include "Player.h";
Player::Player(Vector2u screenSize): _screenWidth(screenSize.x) { Player::Player(Vector2u screenSize): _screenWidth(screenSize.x) {
_shape = CircleShape(screenSize.x / 70, 3); _shape = CircleShape(screenSize.x / 70, 3);
_shape.setFillColor(Color(52, 252, 5)); _shape.setFillColor(Color(52, 252, 5));
float shapeHeight = _shape.getRadius() * 1.5; float shapeHeight = _shape.getRadius() * 1.5;
_shape.setPosition(_screenWidth / 2.f, screenSize.y - shapeHeight); _shape.setPosition(_screenWidth / 2.f, screenSize.y - shapeHeight);
} }
void Player::move(int direction) { void Player::move(int direction) {
float max = _screenWidth - (_shape.getRadius() * 2); float max = _screenWidth - (_shape.getRadius() * 2);
float result = (_screenWidth / 724.0)*direction; float result = (_screenWidth / 724.0)*direction;
// Prevent leaving the window // Prevent leaving the window
if (_shape.getPosition().x + result < 0 || _shape.getPosition().x + result > max) { if (_shape.getPosition().x + result < 0 || _shape.getPosition().x + result > max) {
result = 0; result = 0;
} }
_shape.move(result, 0); _shape.move(result, 0);
} }
+12 -12
View File
@@ -1,13 +1,13 @@
#include "Shield.h" #include "Shield.h"
Shield::Shield(Window& window) { Shield::Shield(Window& window) {
int shapeWidth = window.getSize().x / 10; int shapeWidth = window.getSize().x / 10;
int shapeHeight = window.getSize().y / 35; int shapeHeight = window.getSize().y / 35;
_shape = RectangleShape(Vector2f(shapeWidth, shapeHeight)); _shape = RectangleShape(Vector2f(shapeWidth, shapeHeight));
_shape.setFillColor(Color(Color(52, 252, 5))); _shape.setFillColor(Color(Color(52, 252, 5)));
} }
void Shield::setPosition(Vector2f position) { void Shield::setPosition(Vector2f position) {
_shape.setPosition(position.x + _shape.getSize().x, position.y - _shape.getScale().y); _shape.setPosition(position.x + _shape.getSize().x, position.y - _shape.getScale().y);
} }
+15 -15
View File
@@ -1,16 +1,16 @@
using namespace std; using namespace std;
#include <iostream> #include <iostream>
#include "GameManager.h" #include "GameManager.h"
int main() int main()
{ {
cout << "Starting game..." << endl; cout << "Starting game..." << endl;
GameManager gameManager; GameManager gameManager;
cout << "Game started." << endl; cout << "Game started." << endl;
gameManager.run(); gameManager.run();
return 0; return 0;
} }
+9 -9
View File
@@ -1,10 +1,10 @@
{ {
"name": "space-invader", "name": "space-invader",
"version": "0.0.0", "version": "0.0.0",
"description": "Space Invader Copy", "description": "Space Invader Copy",
"dependencies": [ "dependencies": [
{ {
"name": "sfml" "name": "sfml"
} }
] ]
} }