-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPakuman.pde
executable file
·124 lines (93 loc) · 1.66 KB
/
Pakuman.pde
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
class Pakuman
{
double x,y;
color pcolor;
double psize;
int direction;
double px;
double py;
Pakuman(double x, double y)
{
this.x = x;
this.y = y;
psize = 33/2;
pcolor = color(255, 204, 0);
px = 0;
py = 0;
}
void draw()
{
fill(pcolor);
if(direction==0)//origin
ellipse((float)x,(float)y,(float)psize,(float)psize);
if(direction==1)//up
arc((float)x,(float)y,(float)psize,(float)psize,TWO_PI-PI/2,TWO_PI+PI+0.8);
if(direction==2)//down
arc((float)x,(float)y,(float)psize,(float)psize,TWO_PI-3*(PI/2),TWO_PI+0.8);
if(direction==3)//left
arc((float)x,(float)y,(float)psize,(float)psize,TWO_PI-PI,TWO_PI+PI/2+0.8);
if(direction==4)//right
arc((float)x,(float)y,(float)psize,(float)psize,TWO_PI+0.8,TWO_PI+TWO_PI);
}
boolean validmove(Board a, double x, double y)
{
x = this.convert(this.x+x);
y = this.convert(this.y+y);
if(a.board[(int)y][(int)x]== 1)
return false;
return true;
}
void setcoords(Board a, double x, double y)
{
if (this.validmove(a,x,y))
{
if(this.x+x < 495-33 && this.y+y < 495-33 && this.x+x > 33 && this.y+y > 33)
{
this.x = this.x+x;
this.y = this.y+y;
}
}
}
double convert(double x) //big grid to small grid
{
double a = (x-16.5)/33;
return a;
}
double revert(double x) //small grid to big grid
{
double a = x*33 + 16.5;
return a;
}
void setdirection(int a)
{
this.direction = a;
}
double gety()
{
return this.y;
}
double getx()
{
return this.x;
}
int getdirection()
{
return this.direction;
}
void setpx(double a)
{
px = a;
}
double getpx()
{
return px;
}
void setpy(double a)
{
py = a;
}
double getpy()
{
return py;
}
}