Implemented many things. Refactored parsers. Added some behaviors and items. Added weapons.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <model/Background.h>
|
||||
#include <utils/Assert.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace farmlands {
|
||||
namespace model {
|
||||
|
||||
@@ -27,6 +29,15 @@ Background::~Background()
|
||||
delete[] m_textures;
|
||||
}
|
||||
|
||||
base::Component* Background::clone()
|
||||
{
|
||||
Background* clone = new Background(m_layers, m_rows, m_columns);
|
||||
memcpy(clone->m_cells, m_cells, sizeof(Cell) * m_layers * m_rows * m_columns);
|
||||
memcpy(clone->m_textures, m_textures, sizeof(resources::ResourceId) * m_layers);
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
Cell Background::cell(size_t layer, size_t row, size_t col) const
|
||||
{
|
||||
Assert(layer < m_layers, "Layer out of bounds.");
|
||||
@@ -57,5 +68,13 @@ void Background::setTexture(size_t layer, resources::ResourceId textureId) const
|
||||
m_textures[layer] = textureId;
|
||||
}
|
||||
|
||||
void Background::dump(unsigned level)
|
||||
{
|
||||
for (unsigned i = 0; i < level; i++)
|
||||
std::cout<<" ";
|
||||
|
||||
std::cout << " .Component: Background\n";
|
||||
}
|
||||
|
||||
} /* namespace model */
|
||||
} /* namespace farmlands */
|
||||
|
@@ -22,6 +22,9 @@ namespace model {
|
||||
Background(size_t layerCount, size_t rowCount, size_t columnCount);
|
||||
virtual ~Background();
|
||||
|
||||
virtual base::Component* clone() override;
|
||||
virtual void dump(unsigned level) override;
|
||||
|
||||
inline size_t layerCount() const { return m_layers; }
|
||||
inline size_t rowCount() const { return m_rows; }
|
||||
inline size_t columnCount() const { return m_columns; }
|
||||
|
65
src/model/Item.h
Normal file
65
src/model/Item.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Item.h
|
||||
*
|
||||
* Created on: Dec 2, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#ifndef MODEL_ITEM_H_
|
||||
#define MODEL_ITEM_H_
|
||||
|
||||
#include <base/Component.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace farmlands {
|
||||
namespace model {
|
||||
|
||||
class Item: public base::Component
|
||||
{
|
||||
public:
|
||||
Item();
|
||||
virtual ~Item();
|
||||
|
||||
virtual base::Component* clone() override;
|
||||
virtual void dump(unsigned level) override;
|
||||
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint8_t level;
|
||||
};
|
||||
|
||||
|
||||
/****** Implementation ******/
|
||||
|
||||
inline Item::Item()
|
||||
: name(), description(),
|
||||
level(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline Item::~Item()
|
||||
{
|
||||
}
|
||||
|
||||
inline base::Component* Item::clone()
|
||||
{
|
||||
Item* clone = new Item();
|
||||
clone->name = name;
|
||||
clone->description = description;
|
||||
clone->level = level;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
inline void Item::dump(unsigned level)
|
||||
{
|
||||
for (unsigned i = 0; i < level; i++)
|
||||
std::cout<<" ";
|
||||
|
||||
std::cout << " .Component: Item\n";
|
||||
}
|
||||
|
||||
} /* namespace model */
|
||||
} /* namespace farmlands */
|
||||
|
||||
#endif /* MODEL_ITEM_H_ */
|
27
src/model/Scene.h
Normal file
27
src/model/Scene.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Scene.h
|
||||
*
|
||||
* Created on: Dec 1, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#ifndef MODEL_SCENE_H_
|
||||
#define MODEL_SCENE_H_
|
||||
|
||||
#include <base/GameObject.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace farmlands {
|
||||
namespace model {
|
||||
|
||||
struct Scene
|
||||
{
|
||||
uint32_t cellWidth = 1, cellHeight = 1;
|
||||
base::GameObject root;
|
||||
};
|
||||
|
||||
} /* namespace model */
|
||||
} /* namespace farmlands */
|
||||
|
||||
#endif /* MODEL_SCENE_H_ */
|
Reference in New Issue
Block a user