integrados players. creo.

This commit is contained in:
Ralusama19 2017-01-21 03:42:50 +01:00
parent 704bbb068c
commit 45f1051b8c
14 changed files with 86 additions and 27 deletions

View file

@ -14,8 +14,8 @@ SOURCES += main.cpp \
menu.cpp \ menu.cpp \
combat.cpp \ combat.cpp \
player.cpp \ player.cpp \
enemy.cpp \ iaenemy.cpp \
iaenemy.cpp actor.cpp
HEADERS += \ HEADERS += \
game.hpp \ game.hpp \
@ -28,5 +28,5 @@ HEADERS += \
menu.hpp \ menu.hpp \
combat.hpp \ combat.hpp \
player.hpp \ player.hpp \
enemy.hpp \ iaenemy.hpp \
iaenemy.hpp actor.hpp

7
VaporWaveWars/actor.cpp Normal file
View file

@ -0,0 +1,7 @@
#include "actor.hpp"
Actor::Actor() {}
void Actor::draw(sf::RenderWindow *window) {
}

View file

@ -3,10 +3,10 @@
#include "commons.hpp" #include "commons.hpp"
class Enemy class Actor
{ {
public: public:
Enemy(); Actor();
virtual bool update(float deltaTime, sf::RenderWindow *window) = 0; virtual bool update(float deltaTime, sf::RenderWindow *window) = 0;
void draw(sf::RenderWindow *window) ; void draw(sf::RenderWindow *window) ;
virtual bool event(sf::Event e) = 0; virtual bool event(sf::Event e) = 0;

View file

@ -71,7 +71,7 @@ void Button::handleMouseEvent(sf::Event& event){
void Button::initTexture(std::string path){ void Button::initTexture(std::string path){
_clicks = 0; _clicks = 0;
_state = ButtonState::off; _state = ButtonState::off;
if(!_texture.loadFromFile(path)) std::cout << "failed to load button texture!!" << std::endl; ASSERT(_texture.loadFromFile(path));
setTexture(_texture); setTexture(_texture);
_xSize = _texture.getSize().x; _xSize = _texture.getSize().x;
_ySize = _texture.getSize().y/4; _ySize = _texture.getSize().y/4;

View file

@ -6,7 +6,7 @@
#include "scene.hpp" #include "scene.hpp"
#include "player.hpp" #include "player.hpp"
#include "iaenemy.hpp" #include "iaenemy.hpp"
#include "enemy.hpp" #include "actor.hpp"
class Combat : public Scene { class Combat : public Scene {
public: public:
@ -20,10 +20,9 @@ public:
void draw(sf::RenderWindow *window) final override; void draw(sf::RenderWindow *window) final override;
void updateEvents(sf::Event e) final override; void updateEvents(sf::Event e) final override;
private: private:
Compas compas;
bool playerOneTurn, ia; bool playerOneTurn, ia;
Player player; Player player;
Enemy *enemy; Actor *enemy;
}; };
#endif // COMBAT_H #endif // COMBAT_H

View file

@ -1,7 +0,0 @@
#include "enemy.hpp"
Enemy::Enemy() {}
void Enemy::draw(sf::RenderWindow *window) {
}

View file

@ -26,6 +26,7 @@ void Game::run() {
float time = c.getElapsedTime().asSeconds(); float time = c.getElapsedTime().asSeconds();
float deltaTime = time-oldTime; float deltaTime = time-oldTime;
oldTime = time; oldTime = time;
//std::cout << deltaTime << std::endl;
update(deltaTime, &window); update(deltaTime, &window);
draw( &window); draw( &window);
} }

View file

@ -1,9 +1,9 @@
#ifndef IAENEMY_H #ifndef IAENEMY_H
#define IAENEMY_H #define IAENEMY_H
#include "enemy.hpp" #include "actor.hpp"
class IaEnemy : public Enemy { class IaEnemy : public Actor {
public: public:
IaEnemy(); IaEnemy();
bool update(float deltaTime, sf::RenderWindow *window) final override; bool update(float deltaTime, sf::RenderWindow *window) final override;

View file

@ -32,7 +32,7 @@ void Menu::updateEvents(sf::Event e){
} }
MyGame* g = static_cast<MyGame*>(Game::i()); MyGame* g = static_cast<MyGame*>(Game::i());
if (_start.getClicks() > 0){ if (_start.getClicks() > 0){
// g->changeScene(GameScene::inGame); g->changeScene(GameScene::inGame);
std::cout << "Game not ready to be played. Please Wait." << std::endl; std::cout << "Game not ready to be played. Please Wait." << std::endl;
} }
else if(_exit.getClicks() > 0) g->isRunning = false; else if(_exit.getClicks() > 0) g->isRunning = false;

View file

@ -4,6 +4,9 @@ MyGame::MyGame() {
_scene = GameScene::menu; _scene = GameScene::menu;
_scenes = std::vector<Scene*>(SCENE_NUM); _scenes = std::vector<Scene*>(SCENE_NUM);
_scenes[GameScene::menu] = &_menu; _scenes[GameScene::menu] = &_menu;
_scenes[GameScene::inGame] = &_combat;
_scenes[GameScene::help] = &_menu;
_scenes[GameScene::credits] = &_menu;
std::cout << "in menu" << std::endl; std::cout << "in menu" << std::endl;
} }
@ -11,7 +14,6 @@ MyGame::~MyGame() {
} }
MyGame* i(){ MyGame* i(){
return static_cast<MyGame*>(Game::i());
} }
void MyGame::changeScene(GameScene::gameScene n){ void MyGame::changeScene(GameScene::gameScene n){

View file

@ -3,7 +3,7 @@
#include "game.hpp" #include "game.hpp"
#include "menu.hpp" #include "menu.hpp"
#include "combat.hpp"
class MyGame : public Game{ class MyGame : public Game{
public: public:
MyGame(); MyGame();
@ -14,6 +14,7 @@ private:
GameScene::gameScene _scene; GameScene::gameScene _scene;
std::vector<Scene*> _scenes; std::vector<Scene*> _scenes;
Menu _menu; Menu _menu;
Combat _combat;
virtual void update(float deltaTime, sf::RenderWindow *window) final override; virtual void update(float deltaTime, sf::RenderWindow *window) final override;
virtual void draw(sf::RenderWindow *window) final override; virtual void draw(sf::RenderWindow *window) final override;
}; };

View file

@ -3,8 +3,8 @@
#include "commons.hpp" #include "commons.hpp"
#include "compas.hpp" #include "compas.hpp"
#include "enemy.hpp" #include "actor.hpp"
class Player : public Enemy { class Player : public Actor {
public: public:
Player(); Player();
bool update(float deltaTime, sf::RenderWindow *window) final override; bool update(float deltaTime, sf::RenderWindow *window) final override;

View file

@ -0,0 +1,34 @@
#include "playscene.hpp"
PlayScene::PlayScene(){
}
void PlayScene::update(float deltaTime, sf::RenderWindow*window){
//float dx = InputManager::action(InputAction::moveX0);
//_buttons[0]->move(dx,0);
//std::cout << dx << std::endl;
for(unsigned int i = 0; i < _buttons.size(); ++i){
_buttons[i]->update(window->mapPixelToCoords(sf::Vector2i(sf::Mouse::getPosition(*window))));
}
}
void PlayScene::draw(sf::RenderWindow* window){
for(unsigned int i = 0; i < _buttons.size(); ++i){
window->draw(*_buttons[i]);
}
}
void PlayScene::updateEvents(sf::Event e){
// std::cout << "update menu buttons" << std::endl;
for(unsigned int i = 0; i < _buttons.size(); ++i){
_buttons[i]->handleMouseEvent(e);
}
MyGame* g = static_cast<MyGame*>(Game::i());
if (_start.getClicks() > 0){
// g->changeScene(GameScene::inGame);
std::cout << "Game not ready to be played. Please Wait." << std::endl;
}
else if(_exit.getClicks() > 0) g->isRunning = false;
}

View file

@ -0,0 +1,22 @@
#ifndef PLAYSCENE_HPP
#define PLAYSCENE_HPP
#include "scene.hpp"
class PlayScene : public Scene{
public:
PlayScene();
PlayScene(const Menu& m) = delete;
PlayScene(const Menu&& m) = delete;
PlayScene& operator=(Menu& m) = delete;
PlayScene& operator=(Menu&& m) = delete;
void update(float deltaTime, sf::RenderWindow *window) final override;
void draw(sf::RenderWindow *window) final override;
void updateEvents(sf::Event e) final override;
private:
sf::Texture _backgroundTexture;
sf::Sprite background;
};
#endif // PLAYSCENE_HPP