-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.pde
56 lines (52 loc) · 973 Bytes
/
Item.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
class Item {
int posX, posY;
PImage img;
int n, kind, time;
boolean touch;
Item(int x, int y, int num, int _kind) {
n=num;
posX=x*16*n;
posY=y*16*n+32*n;
kind = _kind;
time = 0;
touch = true;
switch(kind) {
case 0:
img=loadImage("stone.png");
break;
case 1:
img=loadImage("amethyst.png");
break;
default:
break;
}
kind = _kind;
}
void display() {
image(img, posX, posY, size, size);
}
boolean isItem(int _x, int _y) {
//キャラとのあたり判定用
if (dist(_x, _y, posX+8*n, posY+8*n)<=12*n) {
return true;
}
return false;
}
void move(int floor) {
println("posY "+posY);
println("floor "+floor);
if (posY<floor) {
if (touch) {
time = 0;
touch = false;
}
posY+=n*9.8*time/10;
if (posY>floor) {
posY = floor;
time = 0;
}
} else {
touch = true;
}
}
}