-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPosition.cpp
75 lines (63 loc) · 1.02 KB
/
Position.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* untitled.cpp
* TractionEdge
*
* Created by Steven Hamilton on 24/09/09.
* Copyright 2009 scorch.org. All rights reserved.
*
*/
#include "Position.h"
#include "Utility.h"
Position::Position()
{
x=-1;
y=-1;
pathWeight=0;
}
Position::~Position()
{
}
Position::Position(int x1, int y1)
{
x=x1;
y=y1;
}
bool operator<(const Position &a, const Position &b)
{
if (a.pathWeight < b.pathWeight) return true;
return false;
}
bool operator==(const Position &a, const Position &b)
{
if (a.x == b.x && a.y == b.y) return true;
return false;
}
void Position::setXY(int x1, int y1)
{
x=x1;
y=y1;
}
void Position::modXY(int x1, int y1)
{
x+=x1;
y+=y1;
}
void Position::setPathWeight(int weight)
{
pathWeight=weight;
}
int Position::getPathWeight()
{
return pathWeight;
}
std::string Position::string()
{
Utility tool;
std::string str=tool.stringFromInt(x)+":"+tool.stringFromInt(y);
return str;
}
bool Position::validatePosition()
{
if (x>=0 && x<=MAPWIDTH && y>=0 && y<MAPHEIGHT) return true;
else return false;
}