-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from treplen/Plugins
Plugins
- Loading branch information
Showing
16 changed files
with
285 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Created by svuatoslav on 5/23/17. | ||
// | ||
|
||
#include "RToRestart.h" | ||
|
||
void RToRestart::start (Model *model, Controller *controller, View *view) | ||
{ | ||
_model = model; | ||
_controller = controller; | ||
} | ||
|
||
void RToRestart::tick () | ||
{ | ||
if (_model && _controller) | ||
if (_controller->isPressed (sf::Keyboard::Key::R)) | ||
_model->getPlayer ().respawn (); | ||
} | ||
|
||
RToRestart::RToRestart () : _model (nullptr), _controller (nullptr) | ||
{ | ||
} | ||
|
||
extern "C" Plugin *create () | ||
{ | ||
return new RToRestart; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Created by svuatoslav on 5/23/17. | ||
// | ||
|
||
#ifndef ATOMGAME_RTORESTART_H | ||
#define ATOMGAME_RTORESTART_H | ||
|
||
#include "plugin/Plugin.h" | ||
|
||
class RToRestart : public Plugin | ||
{ | ||
private: | ||
Model *_model; | ||
Controller *_controller; | ||
public: | ||
RToRestart (); | ||
|
||
virtual void start (Model *model, Controller *controller, View *view); | ||
|
||
virtual void tick (); | ||
}; | ||
|
||
#endif //ATOMGAME_RTORESTART_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Created by svuatoslav on 5/23/17. | ||
// | ||
|
||
#include "Rain.h" | ||
|
||
void Rain::start (Model *model, Controller *controller, View *view) | ||
{ | ||
_model = model; | ||
timer = 0; | ||
srand (time (0)); | ||
} | ||
|
||
void Rain::tick () | ||
{ | ||
if (!_model->isReloading ()) | ||
{ | ||
if (timer == period) | ||
{ | ||
PhysicalObject *drop = new PhysicalObject (rand () % diameter - diameter / 2 + _model->getPlayer ().getX (), | ||
_model->getPlayer ().getY () - height, size, size); | ||
drop->setVelocity (0, 1); | ||
drop->setAcceleration (0, 1); | ||
drops.push_back (drop); | ||
_model->getObjs ().push_back (drop); | ||
timer = 0; | ||
} else | ||
timer++; | ||
for (std::vector<PhysicalObject *>::const_iterator i = drops.cbegin (); i != drops.cend (); i++) | ||
{ | ||
if ((*i)->getVy () <= 0) | ||
{ | ||
for (std::vector<PhysicalObject *>::const_iterator j = _model->getObjs ().cbegin (); | ||
j != _model->getObjs ().cend (); j++) | ||
{ | ||
if (*j == *i) | ||
{ | ||
_model->getObjs ().erase (j); | ||
break; | ||
} | ||
} | ||
delete *i; | ||
i = drops.erase (i); | ||
} | ||
} | ||
} else | ||
drops.clear (); | ||
} | ||
|
||
extern "C" Plugin *create () | ||
{ | ||
return new Rain; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Created by svuatoslav on 5/23/17. | ||
// | ||
|
||
#ifndef ATOMGAME_RAIN_H | ||
#define ATOMGAME_RAIN_H | ||
|
||
|
||
#include "plugin/Plugin.h" | ||
|
||
class Rain : public Plugin | ||
{ | ||
private: | ||
const int period = 10; | ||
const int diameter = 1000; | ||
const int height = 1000; | ||
const int size = 5; | ||
int timer; | ||
Model *_model; | ||
std::vector<PhysicalObject *> drops; | ||
public: | ||
|
||
|
||
virtual void start (Model *model, Controller *controller, View *view); | ||
|
||
virtual void tick (); | ||
}; | ||
|
||
|
||
#endif //ATOMGAME_RAIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
project(AtomGame) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
set(SOURCE_FILES Plugin.h Plugin.cpp) | ||
|
||
add_library(Plugin STATIC ${SOURCE_FILES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// Created by svuatoslav on 5/23/17. | ||
// | ||
|
||
#include "Plugin.h" | ||
|
||
Plugin::~Plugin () | ||
{ | ||
|
||
} |
Oops, something went wrong.