implement pheromone map

This commit is contained in:
churl
2021-04-08 03:17:53 +02:00
parent f81fbda652
commit 7c5eabaa6d
2 changed files with 43 additions and 0 deletions

22
src/pheromones.cpp Normal file
View 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
View 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