Making Video Game (Pro Streaker) need help!
in
Programming Questions
•
2 years ago
Hello!
This is my first post on these forums. I am trying to make a very simple videogame called "Pro Sreaker".
Here is my code so far:
import processing.opengl.*;
float x;
float y;
void setup() {
size(300, 300, OPENGL);
fill(227, 168, 109);
}
void draw() {
lights();
background(50);
x = map(mouseX, 0, 300, -300, 300);
y = map(mouseY, 0, 300, -300, 300);
// Change height of the camera with mouseY
camera(x, y, 220.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ
noStroke();
pushMatrix();
translate(-0, -50, 0);
box(30);
translate(0, 30, 0);
box(20,35,20);
popMatrix();
pushMatrix();
translate(-15,-30,0);
rotateZ (radians(30));
box(30,5,5);
popMatrix();
pushMatrix();
translate(15,-30,0);
rotateZ (radians(-30));
box(30,5,5);
popMatrix();
pushMatrix();
translate(-7,5,0);
rotateX(radians(30));
box(5,30,5);
popMatrix();
pushMatrix();
translate(7,5,0);
rotateX(radians(-30));
box(5,30,5);
popMatrix();
pushMatrix();
translate(0,0,10);
rotateX(radians(-20));
box(3,3,5);
popMatrix();
stroke(255);
}
I am trying to figure out how to control his movements with a WSAD keyboard configuration. I've tried making a variable for the Z position to make him advance in space, but the model doesn't move correctly that way. It will advance in space as long as the W key is pressed, but when the key is released the model returns to the origin point.
Any help or advice on this would be REALLY appreciated.
Jason Belmonti
dumpybitch.com
This is my first post on these forums. I am trying to make a very simple videogame called "Pro Sreaker".
Here is my code so far:
import processing.opengl.*;
float x;
float y;
void setup() {
size(300, 300, OPENGL);
fill(227, 168, 109);
}
void draw() {
lights();
background(50);
x = map(mouseX, 0, 300, -300, 300);
y = map(mouseY, 0, 300, -300, 300);
// Change height of the camera with mouseY
camera(x, y, 220.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ
noStroke();
pushMatrix();
translate(-0, -50, 0);
box(30);
translate(0, 30, 0);
box(20,35,20);
popMatrix();
pushMatrix();
translate(-15,-30,0);
rotateZ (radians(30));
box(30,5,5);
popMatrix();
pushMatrix();
translate(15,-30,0);
rotateZ (radians(-30));
box(30,5,5);
popMatrix();
pushMatrix();
translate(-7,5,0);
rotateX(radians(30));
box(5,30,5);
popMatrix();
pushMatrix();
translate(7,5,0);
rotateX(radians(-30));
box(5,30,5);
popMatrix();
pushMatrix();
translate(0,0,10);
rotateX(radians(-20));
box(3,3,5);
popMatrix();
stroke(255);
}
I am trying to figure out how to control his movements with a WSAD keyboard configuration. I've tried making a variable for the Z position to make him advance in space, but the model doesn't move correctly that way. It will advance in space as long as the W key is pressed, but when the key is released the model returns to the origin point.
Any help or advice on this would be REALLY appreciated.
Jason Belmonti
dumpybitch.com
1