aux commit

This commit is contained in:
serk 2017-01-21 02:32:26 +01:00
parent 98506b1121
commit 226a7b7657
9 changed files with 155 additions and 2 deletions

View file

@ -11,7 +11,11 @@ SOURCES += main.cpp \
character.cpp \
compas.cpp \
scene.cpp \
menu.cpp
menu.cpp \
combat.cpp \
player.cpp \
enemy.cpp \
iaenemy.cpp
HEADERS += \
game.hpp \
@ -21,4 +25,8 @@ HEADERS += \
character.hpp \
compas.hpp \
scene.hpp \
menu.hpp
menu.hpp \
combat.hpp \
player.hpp \
enemy.hpp \
iaenemy.hpp

23
VaporWaveWars/combat.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "combat.hpp"
Combat::Combat() {
ia = playerOneTurn = true;
enemy = new IaEnemy();
}
void Combat::update(float deltaTime, sf::RenderWindow *window) {
if (playerOneTurn) player.update(deltaTime, window);
else if (ia) playerOneTurn = enemy->update(deltaTime, window);
}
void Combat::draw(sf::RenderWindow *window) {
player.draw(window);
enemy->draw(window);
//draw background
}
void Combat::updateButtons(sf::Event e) {
if (playerOneTurn) playerOneTurn = player.event(e);
else if (!ia) playerOneTurn = !enemy->event(e);
}

28
VaporWaveWars/combat.hpp Normal file
View file

@ -0,0 +1,28 @@
#ifndef COMBAT_H
#define COMBAT_H
#include "commons.hpp"
#include "compas.hpp"
#include "scene.hpp"
#include "player.hpp"
#include "iaenemy.hpp"
#include "enemy.hpp"
class Combat : public Scene {
public:
Combat();
Combat(const Combat& m) = delete;
Combat(const Combat&& m) = delete;
Combat& operator=(Combat& m) = delete;
Combat& operator=(Combat&& m) = delete;
void update(float deltaTime, sf::RenderWindow *window) final override;
void draw(sf::RenderWindow *window) final override;
void updateButtons(sf::Event e) final override;
private:
Compas compas;
bool playerOneTurn, ia;
Player player;
Enemy *enemy;
};
#endif // COMBAT_H

7
VaporWaveWars/enemy.cpp Normal file
View file

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

17
VaporWaveWars/enemy.hpp Normal file
View file

@ -0,0 +1,17 @@
#ifndef ENEMY_H
#define ENEMY_H
#include "commons.hpp"
class Enemy
{
public:
Enemy();
virtual bool update(float deltaTime, sf::RenderWindow *window) = 0;
void draw(sf::RenderWindow *window) ;
virtual bool event(sf::Event e) = 0;
protected:
bool animate;
};
#endif // ENEMY_H

10
VaporWaveWars/iaenemy.cpp Normal file
View file

@ -0,0 +1,10 @@
#include "iaenemy.hpp"
IaEnemy::IaEnemy() {}
bool IaEnemy::update(float deltaTime, sf::RenderWindow *window) {
//some playe return true
return true;
}
bool IaEnemy::event(sf::Event e) {return false;}

13
VaporWaveWars/iaenemy.hpp Normal file
View file

@ -0,0 +1,13 @@
#ifndef IAENEMY_H
#define IAENEMY_H
#include "enemy.hpp"
class IaEnemy : public Enemy {
public:
IaEnemy();
bool update(float deltaTime, sf::RenderWindow *window) final override;
bool event(sf::Event e) final override;
};
#endif // IAENEMY_H

31
VaporWaveWars/player.cpp Normal file
View file

@ -0,0 +1,31 @@
#include "player.hpp"
Player::Player() {
animate = false;
}
bool Player::update(float deltaTime, sf::RenderWindow *window) {
if (deltaTime > BLACKVALUE) compas.incraeseTime();
return false;
}
bool Player::event(sf::Event e) {
switch(e.type) {
case (sf::Event::KeyPressed):
if(e.key.code == sf::Keyboard::C) compas.start();
if(e.key.code == sf::Keyboard::Space) {
compas.add();
animate = true;
}
break;
case (sf::Event::KeyReleased):
if (e.key.code == sf::Keyboard::C) {
compas.end();
return false;
}
break;
default:
break;
}
return true;
}

16
VaporWaveWars/player.hpp Normal file
View file

@ -0,0 +1,16 @@
#ifndef PLAYER_H
#define PLAYER_H
#include "commons.hpp"
#include "compas.hpp"
#include "enemy.hpp"
class Player : public Enemy {
public:
Player();
bool update(float deltaTime, sf::RenderWindow *window) final override;
bool event(sf::Event e) final override;
private:
Compas compas;
};
#endif // PLAYER_H