Moving a cube and the camera.
in
Programming Questions
•
1 year ago
Hi guys. I'm new to processing, and I'm trying to program a third-person cube game. There are three problems I've come up with so far:
1. The cube only moves in one direction, i'm trying to make it so it moves whatever way the cube is facing.
2. I want the camera to follow the cube when it turns, and I can't seem to program that.
3. The rectangle I made at the very bottom of draw is not showing up, that is supposed to be my ground.
Here's my code:
int playerX=750;
int playerY=500;
int playerZ=0;
void setup()
{
mouseX = 750;
mouseY = 500;
size(1500, 1000, P3D);
}
void draw()
{
if (keyPressed)
{
if (key == 'w')
{
playerX=playerX+1;
}
}
if (keyPressed)
{
if (key=='s')
{
playerX=playerX+ -1;
}
}
background(0);
fill(255, 255, 255);
translate(playerX, playerY, playerZ);
rotateY(mouseX/200);
box(100);
camera(0.0, 0.0, 0.0, 750, 500, 0.0, 1.0, 1.0, 0.0);
rect(750,500,1000,1000);
}
int playerY=500;
int playerZ=0;
void setup()
{
mouseX = 750;
mouseY = 500;
size(1500, 1000, P3D);
}
void draw()
{
if (keyPressed)
{
if (key == 'w')
{
playerX=playerX+1;
}
}
if (keyPressed)
{
if (key=='s')
{
playerX=playerX+ -1;
}
}
background(0);
fill(255, 255, 255);
translate(playerX, playerY, playerZ);
rotateY(mouseX/200);
box(100);
camera(0.0, 0.0, 0.0, 750, 500, 0.0, 1.0, 1.0, 0.0);
rect(750,500,1000,1000);
}
1