implement pheromone map
This commit is contained in:
22
src/pheromones.cpp
Normal file
22
src/pheromones.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "pheromones.hpp"
|
||||||
|
|
||||||
|
extern const unsigned short WIDTH;
|
||||||
|
extern const unsigned short HEIGHT;
|
||||||
|
|
||||||
|
Pheromones::Pheromones() {
|
||||||
|
for (unsigned short y = 0; y < HEIGHT; ++y) {
|
||||||
|
for (unsigned short x = 0; x < WIDTH; ++x) {
|
||||||
|
map[y * WIDTH + x].position.x = x;
|
||||||
|
map[y * WIDTH + x].position.y = y;
|
||||||
|
map[y * WIDTH + x].color = sf::Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pheromones::update() {
|
||||||
|
for (int i = 0; i < WIDTH * HEIGHT; ++i) {
|
||||||
|
// if (map[i].color != sf::Color::White) {
|
||||||
|
map[i].color -= sf::Color(decay, decay, decay, decay);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
21
src/pheromones.hpp
Normal file
21
src/pheromones.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __PHEROMONES_H_
|
||||||
|
#define __PHEROMONES_H_
|
||||||
|
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
extern const unsigned short WIDTH;
|
||||||
|
extern const unsigned short HEIGHT;
|
||||||
|
|
||||||
|
const unsigned short decay = 1;
|
||||||
|
|
||||||
|
class Pheromones {
|
||||||
|
public:
|
||||||
|
sf::VertexArray map = sf::VertexArray(sf::PrimitiveType::Points, WIDTH * HEIGHT);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Pheromones();
|
||||||
|
|
||||||
|
void update();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user