Select Git revision
Forked from an inaccessible project.
player.pde 1.72 KiB
class Player {
String name;
boolean goal_keeper;
color _color;
float pos_x;
float pos_y;
float vel;
float angle;
Player(boolean goal_keeper) {
this.name = "";
this.goal_keeper = goal_keeper;
this._color = color(0);
this.angle = 0;
}
void set_direction(float angle) {
this.angle = angle;
}
void set_velocity(float vel) {
this.vel = vel;
}
void set_color(color _color) {
this._color = _color;
}
int set_name(String name) {
this.name = name;
return 1;
}
void set_position(float pos_x, float pos_y) {
this.pos_x = pos_x;
this.pos_y = pos_y;
}
void set_angle(float angle) {
this.angle = angle;
}
float get_pos_x() {
return this.pos_x;
}
float get_pos_y() {
return this.pos_y;
}
float get_angle() {
return this.angle;
}
float opening_x() {
return this.get_pos_x()+6*cos(this.angle);
}
float opening_y() {
return this.get_pos_y()+6*sin(this.angle);
}
void verify_borders() {
if (this.pos_x < -93) {
this.pos_x = -93;
}
if (this.pos_x > 93) {
this.pos_x = 93;
}
if (this.pos_y < -43) {
this.pos_y = -43;
}
if (this.pos_y > 43) {
this.pos_y = 43;
}
}
void run(float delta_t) {
this.pos_x += this.vel*cos(angle)*delta_t;
this.pos_y += this.vel*sin(angle)*delta_t;
this.verify_borders();
}
void showPos() {
textSize(2);
fill(255, 0, 0);
text(str(this.pos_x)+","+str(this.pos_y), 0, 0);
}
void show() {
noStroke();
fill(this._color);
pushMatrix();
translate(this.pos_x, this.pos_y);
arc(0, 0, 12, 12, this.angle+PI/16, this.angle+2*PI-PI/16);
fill(0);
ellipse(0, 0, 10, 10);
//this.showPos();
popMatrix();
}
}