From 7c5eabaa6d03626a90abe30df1687025979346bf Mon Sep 17 00:00:00 2001 From: churl Date: Thu, 8 Apr 2021 03:17:53 +0200 Subject: [PATCH] implement pheromone map --- src/pheromones.cpp | 22 ++++++++++++++++++++++ src/pheromones.hpp | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/pheromones.cpp create mode 100644 src/pheromones.hpp diff --git a/src/pheromones.cpp b/src/pheromones.cpp new file mode 100644 index 0000000..d36f97d --- /dev/null +++ b/src/pheromones.cpp @@ -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); + // } + } +} diff --git a/src/pheromones.hpp b/src/pheromones.hpp new file mode 100644 index 0000000..4216572 --- /dev/null +++ b/src/pheromones.hpp @@ -0,0 +1,21 @@ +#ifndef __PHEROMONES_H_ +#define __PHEROMONES_H_ + +#include + +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