Added a graph class for representing and manipulating the game data
This commit is contained in:
48
graph.h
Normal file
48
graph.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* Represents an undirected graph.
|
||||
* Also contains the vertex and edge classes
|
||||
* vertexes know their center point on the SDL Surface -
|
||||
* bad decoupling maybe, but not too bad, all things considered
|
||||
*/
|
||||
|
||||
#ifndef _GRAPH_H_
|
||||
#define _GRAPH_H_
|
||||
|
||||
#include <list>
|
||||
|
||||
using std::list;
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int min_x;
|
||||
int min_y;
|
||||
int max_x;
|
||||
int max_y;
|
||||
};
|
||||
|
||||
struct Edge
|
||||
{
|
||||
Vertex a;
|
||||
Vertex b;
|
||||
};
|
||||
|
||||
class Graph
|
||||
{
|
||||
public:
|
||||
Graph() {}
|
||||
|
||||
bool vertex_present(int x, int y, int size);
|
||||
|
||||
list<Vertex> get_vertices() { return vertices; }
|
||||
list<Edge> get_edges() { return edges; }
|
||||
|
||||
void add_vertex(Vertex v);
|
||||
|
||||
private:
|
||||
Vertex last_vertex;
|
||||
list<Vertex> vertices;
|
||||
list<Edge> edges;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user