Skip to content

Commit

Permalink
Merge pull request #158 from VictorHarri-Chal/149-solo-mode
Browse files Browse the repository at this point in the history
149 solo mode
  • Loading branch information
VictorHarri-Chal authored Nov 7, 2022
2 parents 77a8fe5 + f948a17 commit 6a8edf9
Show file tree
Hide file tree
Showing 36 changed files with 1,096 additions and 253 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ set(SRC_INTERFACE
set(SRCROOT ${PROJECT_SOURCE_DIR}/src/)
set(SRCCLIENT ${PROJECT_SOURCE_DIR}/src/client/)
set(SRCSERVER ${PROJECT_SOURCE_DIR}/src/server/)
set(ECSROOT ${SRCROOT}/ecs/)
set(UTILSROOT ${SRCROOT}/utils/)
set(EVENTSROOT ${SRCCLIENT}/events/)
set(GAMEROOT ${SRCCLIENT}/game/)
set(SCREENSROOT ${SRCCLIENT}/screens/)
set(GAMEROOT ${SRCCLIENT}/game/)
set(TOOLSROOT ${SRCCLIENT}/tools/)
set(SCRIPTROOT ${SRCCLIENT}/script/)
set(ECSROOT ${SRCROOT}/ecs/)
set(UTILSROOT ${SRCROOT}/utils/)
set(SCRIPTROOT ${SRCROOT}/script/)

set(SRC_ECS
${ECSROOT}Entity/entity.cpp
Expand Down Expand Up @@ -66,6 +66,8 @@ set(SRC_ECS
${ECSROOT}Component/Ship/kamikaze.hpp
${ECSROOT}Component/Ship/turret.cpp
${ECSROOT}Component/Ship/turret.hpp
${ECSROOT}Component/Ship/boss.cpp
${ECSROOT}Component/Ship/boss.hpp
${ECSROOT}Component/Ship/AShip.cpp
${ECSROOT}Component/Ship/AShip.hpp
${ECSROOT}Component/Ship/IShip.hpp
Expand Down Expand Up @@ -96,6 +98,8 @@ set(SRC_SCREENS
${SCREENSROOT}room/RoomScreen.hpp
${SCREENSROOT}core/CoreScreen.cpp
${SCREENSROOT}core/CoreScreen.hpp
${SCREENSROOT}solo/SoloScreen.cpp
${SCREENSROOT}solo/SoloScreen.hpp
)

set(SRC_GAME
Expand Down Expand Up @@ -158,6 +162,7 @@ set(SRC_SERVER
${SRCSERVER}Game.cpp
${SRCSERVER}Game.hpp
${SRC_ECS}
${SRC_SCRIPT}
${SRC_UTILS}
)

Expand Down
19 changes: 9 additions & 10 deletions Docs/how_to_use_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@ Each line is representing an enemy entity with all his caracteristics:

## An exemple

Ex : 5 1 1 0 1 1000 1100 1
Means sf::seconds(5.f) 1 ZIGZAG false true 1000.f 1100.f true
Ex : 5 1 1 1000 1100 1
Means sf::seconds(5.f) 1 ZIGZAG 1000.f 1100.f true


First param -> timestamp : sf::Time elapsed since the start in second
Second param -> current wave number
Third param -> ship type : 1 if ZIGZAG - 2 if RUSHER - 3 if KAMIKAZE - 4 if TURRET
Fourth param -> horizontal direction : 0 if left - 1 if right
Fifth param -> vertical direction : 0 if up - 1 if down
Sixth param -> x position
Seventh param -> y position
Eight param -> is the sprite printed ?
Third param -> ship type : 1 if ZIGZAG - 2 if RUSHER - 3 if KAMIKAZE - 4 if TURRET - 5 if BOSS
Fourth param -> x position
Fifth param -> y position
Sixth param -> is the sprite printed ?


## Your turn

You can add new enemies as you wish, you just need to write a new line with custom caracteristics !
You can place new enemies in the order you want but keep wave amount to 10 if you want it to work

## About ship type

You maybe don't know much about the differents enemies you can create, so i'll explain it
You maybe don't know much about the differents enemies you can create, so i'll explain it:

ZIGZAG : Moves verticaly - Normal health - Normal damage - Slow cadency
RUSHER : Moves horizontaly on you - Low health - Normal damage - Normal cadency
KAMIKAZE : Moves horizontaly on you and then explode - Low health - High damage - Don't shoot
TURRET : Place himself and then stay static - High health - Normal damage - High cadency

BOSS : Move from left to right - Spawn vertical moving mines
Binary file added assets/boss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion script.txt

This file was deleted.

57 changes: 30 additions & 27 deletions src/client/game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ void rtype::Game::init(std::string flag)
// music.play();
boost::thread t(boost::bind(&boost::asio::io_service::run, &_ioService));
_eventClass.initEvents(_event);
// if (flag == "-g") {
// _window.create(sf::VideoMode{1920, 1080, 16}, "R-Type", sf::Style::Close | sf::Style::Fullscreen);
// _actualScreen = Screens::Core;
// _core = new rtype::menu::CoreScreen;
// if (_core == nullptr)
// throw GameExceptions("Game init: Error while creating CoreScreen");
// _lastScene = Screens::Core;
// _core->init();
// } else if (flag == "-gw") {
// _window.create(sf::VideoMode{1920, 1080, 16}, "R-Type", sf::Style::Close);
// _actualScreen = Screens::Core;
// _core = new rtype::menu::CoreScreen();
// if (_core == nullptr)
// throw GameExceptions("Game init: Error while creating CoreScreen");
// _lastScene = Screens::Core;
// _core->init();
if (flag == "-w") {
if (flag == "-g") {
_window.create(sf::VideoMode{1920, 1080, 16}, "R-Type", sf::Style::Close | sf::Style::Fullscreen);
_actualScreen = Screens::Solo;
_solo = new rtype::menu::SoloScreen;
if (_solo == nullptr)
throw GameExceptions("Game init: Error while creating SoloScreen");
_lastScene = Screens::Solo;
_solo->init();
} else if (flag == "-gw") {
_window.create(sf::VideoMode{1920, 1080, 16}, "R-Type", sf::Style::Close);
_actualScreen = Screens::Solo;
_solo = new rtype::menu::SoloScreen;
if (_solo == nullptr)
throw GameExceptions("Game init: Error while creating SoloScreen");
_lastScene = Screens::Solo;
_solo->init();
} else if (flag == "-w") {
_window.create(sf::VideoMode{1920, 1080, 16}, "R-Type", sf::Style::Close);
_actualScreen = Screens::Intro;
_intro = new rtype::menu::IntroScreen;
Expand All @@ -69,16 +69,6 @@ void rtype::Game::init(std::string flag)
}
}

void rtype::Game::initMusic()
{

}

void rtype::Game::initSounds()
{

}

bool rtype::Game::processEvents(rtype::Game *gameEngine)
{
bool ret = true;
Expand All @@ -104,6 +94,7 @@ void rtype::Game::update(rtype::Game *gameEngine)
case Screens::Options: _options->update(gameEngine); break;
case Screens::Room: _room->update(gameEngine); break;
case Screens::Core: _core->update(gameEngine); break;
case Screens::Solo: _solo->update(gameEngine); break;
default: break;
}
}
Expand All @@ -116,6 +107,7 @@ int rtype::Game::handleEvent(rtype::Game *gameEngine)
case Screens::Options: return (_options->handleEvent(_event, gameEngine));
case Screens::Room: return (_room->handleEvent(_event, gameEngine));
case Screens::Core: return (_core->handleEvent(_event, gameEngine));
case Screens::Solo: return (_solo->handleEvent(_event, gameEngine));
default: break;
}
return true;
Expand Down Expand Up @@ -187,6 +179,15 @@ void rtype::Game::handleScreensSwap(int ret)
_core->init();
setActualScreen(Screens::Core);
break;
case 8:
destroyLastScene();
_solo = new rtype::menu::SoloScreen;
if (_solo == nullptr)
throw GameExceptions("Game handleScreensSwap: Error while creating SoloScreen");
_lastScene = Screens::Solo;
_solo->init();
setActualScreen(Screens::Solo);
break;
default:
break;
}
Expand All @@ -211,6 +212,8 @@ void rtype::Game::destroyLastScene()
delete _room;
if (_lastScene == Screens::Core)
delete _core;
if (_lastScene == Screens::Solo)
delete _solo;
}

void rtype::Game::destroy()
Expand Down
37 changes: 4 additions & 33 deletions src/client/game/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "../screens/multiplayer/MultiplayerScreen.hpp"
#include "../screens/room/RoomScreen.hpp"
#include "../screens/core/CoreScreen.hpp"
#include "../screens/solo/SoloScreen.hpp"
#include "../network/Client.hpp"

namespace rtype
Expand All @@ -22,11 +23,7 @@ namespace rtype
class Game {
public:
/// @brief enum containing all navigable screens
enum class Screens { Intro = 1, Menu, Htp, Options, Multiplayer, Room, Core, Count };
/// @brief enum containing all type of sounds
enum Sounds {};
/// @brief enum containing all musics
enum Musics {};
enum class Screens { Intro = 1, Menu, Htp, Options, Multiplayer, Room, Core, Solo, Count };
/// @brief Constructor
/// @param baseFps base fps (60 by default)
Game(size_t baseFps = 60);
Expand All @@ -49,16 +46,6 @@ namespace rtype
/// @param gameEngine Game engine
/// @return int The scene number
int handleEvent(rtype::Game *gameEngine);
/**
* @brief Init all sounds
*
*/
void initSounds();
/**
* @brief Init all musics
*
*/
void initMusic();
/**
* @brief Destroy all
*
Expand All @@ -73,24 +60,6 @@ namespace rtype
/// @brief Set the actual screen
/// @param newScreen The new screen
void setActualScreen(Screens newScreen);
// /**
// * @brief Set the Sound Event
// *
// * @param entititesIndex Index for entity
// */
// void setSoundEvent(int entititesIndex);
// /**
// * @brief Add sound entity
// *
// * @param entity Entity sound to add
// */
// void addSoundEntity(std::unique_ptr<rtype::ecs::entity::Entity> entity);
// /**
// * @brief Add sound system
// *
// * @param system System sound to add
// */
// void addSoundSystem(std::unique_ptr<rtype::ecs::system::ISystem> system);

/// @brief Game client
Client *_client;
Expand All @@ -116,6 +85,8 @@ namespace rtype
rtype::menu::RoomScreen *_room;
/// @brief Core screen
rtype::menu::CoreScreen *_core;
/// @brief Solo screen
rtype::menu::SoloScreen *_solo;
/// @brief Last sfml evecaught
sf::Event _sfmlEvent;
/// @brief Event class
Expand Down
Loading

0 comments on commit 6a8edf9

Please sign in to comment.