#pragma once
enum class Nation{USA,RUS};
enum class Unittype{INFANTRY,LIGHT,TANK,HELICOPTER};
class Unit
{
public:
Unit(int at, int pe, int ar, int du, Nation na, Unittype ty);
//~Unit();
int PENATK(int &pen);
bool takeDMG(int pen, int atk);
private:
int attack;
int penetration;
int armor;
int durability;
Nation nationality;
Unittype type;
};
Unit.h
Unit.cpp
#include "Unit.h"
Unit::Unit(int at, int pe, int ar, int du, Nation na, Unittype ty) {
attack = at;
penetration = pe;
armor = ar;
durability = du;
nationality = na;
type = ty;
}
int Unit::PENATK(int& pen) {
pen = penetration;
return attack;
}
bool Unit::takeDMG(int pen, int atk) {
if (pen > armor)
durability = durability - atk;
if (durability <= 0)
return 1;
else
return 0;
}
EDIT:
main.cpp will be useful too i believe:
#include <SFML/Graphics.hpp>
#include <iostream>
#include "Infantry.h"
#include "Unit.h"
int main() {
sf::RenderWindow _window(sf::VideoMode(1024,768), "sfml", sf::Style::Close | sf::Style::Titlebar);
_window.setVerticalSyncEnabled(true);
sf::Event evnt;
Riflemans rf(10,10,10,10);
while (_window.isOpen()) {
while (_window.pollEvent(evnt)) {
switch (evnt.type)
{
case sf::Event::Closed:
_window.close();
break;
default:
break;
}//switch
}//while
_window.clear(sf::Color::Blue);
_window.draw(rf);
_window.display();
}//petlagry
return 0;
}