Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MacroAhi

Pages: [1]
1
Graphics / Help with unordered set using vertex
« on: June 01, 2021, 12:55:36 am »
hello,
I'm trying to implement a version of Achtung die Kurve,
i'd like to store every line in std::unordered set
so if there's a collision i could tell a player its lost
every player is a line that add each point to the end.
its not working because i couldn't succeeded doing hash and equal function of vertices.
latest sfml, visual studio 2017

Code: [Select]
#pragma once
#include <SFML/Graphics.hpp>
#include <unordered_set>
#include <functional>

size_t hash(const sf::Vertex& vertex) {
std::size_t seed = 0;

seed ^= std::hash<unsigned int>()((unsigned int)vertex.position.x) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= std::hash<unsigned int>()((unsigned int)vertex.position.y) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
};

bool equal(sf::Vertex const& lhs, sf::Vertex const& rhs)
{
return lhs.position.x == rhs.position.y && lhs.position.y == rhs.position.y;
};

class VertexSet : public sf::Drawable
{
public:
VertexSet();
private:
using equal_type = bool (*)(const sf::Vertex&, const sf::Vertex&);
using hash_type = std::size_t(*)(const sf::Vertex&);
std::unordered_set<sf::Vertex, hash_type, equal_type> m_vertices = std::unordered_set<sf::Vertex, hash_type, equal_type>(0, hash, equal);
sf::PrimitiveType m_primitiveType;
};
its not working actually,
error represents:
Code: [Select]
Severity Code Description Project File Line Suppression State
Error LNK2005 "bool __cdecl equal(class sf::Vertex const &,class sf::Vertex const &)" (?equal@@YA_NAEBVVertex@sf@@0@Z)
I want to have a set of points that i can draw the things,
fast insertion and find
please advice,
thank you

Pages: [1]
anything