-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.pde
More file actions
executable file
·65 lines (52 loc) · 1.2 KB
/
Player.pde
File metadata and controls
executable file
·65 lines (52 loc) · 1.2 KB
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
/*
キーボードで動かせる赤ボール
*/
class Player extends Ball{
PImage player;
float dvx;
float dvy;
int vxMax;
boolean jumpFlag;
Player(int x, int y, int r, int elas, int type, int num){
super(x, y, r, elas, type, num);
dvx = 0.2;
dvy = 13;
vxMax = 3;
player = loadImage("player.png");
}
void keyMove(Key[] keys, Square[] square){
int onFlagCount = 0;
for(int i=0; i< square.length ; i++){
if( square[i].getOnFlag() )
onFlagCount ++;
}
jumpFlag = false;
if( keys[3].getIsPressed() && v.x < vxMax)
v.x += dvx;
if( keys[2].getIsPressed() && v.x > -vxMax)
v.x -= dvx;
if( keys[0].getIsPressed() && onFlagCount > 0 )
jumpFlag = true;
if(jumpFlag)
v.y = -dvy;
}
void show(){
image(player, p.x -r, p.y -r, r*2,r*2);
if(num != 0){
fill(0,100);
textSize(30);
textAlign(CENTER, CENTER);
text(num, p.x, p.y);
}
/*
fill(0);
textSize(20);
textAlign(LEFT);
text("x :"+p.x, 0,20);
text("y :"+p.y, 0,40);
text("vx:"+v.x, 0,60);
text("vy:"+v.y, 0,80);
text("m :"+m , 0,100);
*/
}
}