I'm very new and need help making a Frogger-inspired project. Need help with detection, among other things.
in
Programming Questions
•
10 months ago
Hi there. I have to use Processing for a project at school, and my group decided to do a Christmas-themed Frogger game. We split up the responsibilities. My first task was to make Santa (Frogger) move, which went fine. Now, I need to figure out a way to make objects interact. We're using sleds instead of logs on the water, and I need to figure out (in the future) how to make Santa move with the sled when he steps on it. But I searched for two hours last night and found NOTHING about intersection, collision, whatever.
I have to be honest, I'm already really ticked off at this. I hate it already, but I need to move on. Can anyone offer any ideas? I have extremely minimal experience with programming at all. I'll post what I have that works so far:
Main:
I have to be honest, I'm already really ticked off at this. I hate it already, but I need to move on. Can anyone offer any ideas? I have extremely minimal experience with programming at all. I'll post what I have that works so far:
Main:
PImage Santa;
PImage Sled;
boolean left, right, up, down;
boolean runOnce = true;
int santaX = 185, santaY = 460;
boolean intersect=false;
void setup() {
size (450, 510);
Santa = loadImage ("santasmall.png");
Sled = loadImage ("sled.png");
}
void draw ()
{
background(0);
{
if (runOnce)
if (up) {
santaY -=30;
runOnce = false;
}
else
if (down) {
santaY +=30;
runOnce = false;
}
if (runOnce)
if (left) {
santaX -= 30;
runOnce = false;
}
else if (right) {
santaX +=30;
runOnce = false;
}
image (Sled, 175, 200, Sled.width/2, Sled.height/2);
image (Santa, santaX, santaY);
}
}
//----------------------
Santa's Movement:
void keyPressed() {
if (key == CODED)
{
if (keyCode == UP) {
up = true;
}
else if (keyCode == DOWN) {
down = true;
}
else if (keyCode == LEFT) {
left = true;
}
else if (keyCode == RIGHT) {
right= true;
}
}
}
void keyReleased() {
if (key == CODED)
{
if (keyCode == UP) {
up = false;
runOnce = true;
}
else if (keyCode == DOWN) {
down = false;
runOnce = true;
}
else if (keyCode == LEFT) {
left = false;
runOnce = true;
}
else if (keyCode == RIGHT) {
right= false;
runOnce = true;
}
}
}
Thank you very much.
1