xxxxxxxxxx
void setup() {
size(1000, 700, P3D);
player = new controller();
background(245, 83, 83);
}
int tick;
float xVel;
float yVel;
float zVel; // controller
void draw() {
background(245, 83, 83);
player.render();
pushMatrix();
translate(width / 2, height - 200, 350);
rotateX(0);
fill(246, 245, 77);
box(width, 200, 1000);
popMatrix();
tick++;
if (keyPressed) {
if (key == 'a' || key == 'A') {
xVel -= 0.5;
}
if (key == 'd' || key == 'D') {
xVel += 0.5;
}
if (key == 'w' || key == 'W') {
zVel -= 0.5;
}
if (key == 's' || key == 'S') {
zVel += 0.5;
}
}
if (xVel > 5)
xVel = 5;
if (xVel < -5)
xVel = -5;
xVel *= 0.95;
if (zVel > 5)
zVel = 5;
if (zVel < -5)
zVel = -5;
zVel *= 0.95;
if (yVel > 5)
yVel = 5;
if (yVel < -5)
yVel = -5;
yVel *= 0.95;
}