More Frogger fun... Now I need to reset the character after they get to the end.
in
Programming Questions
•
10 months ago
Hello all. I'm moving along, but I hit another bug. I'm trying to make it so when Santa gets to a house, a present is dropped in its place, and Santa resets to the first position. The gift is fine, and Santa resets, but he won't move after resetting. I know it's still taking the input, because the score is rising, but Santa himself won't move. Any thoughts? Here's the code I have. Thank you, and sorry for the annoyance.
PImage Santa;
PImage Sled;
PImage Reindeer;
PImage Dirt;
PImage Ice;
PImage Water;
PImage Logs;
PImage bg;
PImage House;
PImage Gift;
PFont FontA;
int santaX = 185, santaY = 442;
int house1X= 30, house1Y = 0;
int Score= 0;
boolean left, right, up, down;
boolean runOnce=true;
//boolean intersect=false;
//boolean deerintersect=false;
boolean rightblock=false;
boolean leftblock=false;
boolean downblock=false;
boolean upblock=false;
boolean scoreblockdown=false;
boolean scoreblockup=false;
boolean house1gift=false;
boolean house1collision=false;
boolean alwaysmove=true;
void setup() {
size (450, 510);
FontA = loadFont ("ArcadeNormal-48.vlw");
Santa = loadImage ("santasmall.png");
Sled = loadImage ("sled.png");
Reindeer = loadImage ("reindeer.png");
bg = loadImage ("black.jpg");
Dirt = loadImage ("8-bit_dirt.png");
Ice = loadImage ("8-bit_ice.png");
Water = loadImage ("8-bit_water.png");
Logs = loadImage ("8-bit_log.png");
House = loadImage ("house.png");
Gift = loadImage ("gift.png");
}
void draw ()
{
background(bg);
image(Ice, 0, 45, Ice.width, Ice.height/1.52);
image(Dirt, 0, 287, Dirt.width, Dirt.height/3);
image(Logs, -5, 251, Logs.width/.8, Logs.height/.8);
image(Logs, 145, 251, Logs.width/.8, Logs.height/.8);
image(Logs, 295, 251, Logs.width/.8, Logs.height/.8);
image(Logs, -5, 441, Logs.width/.8, Logs.height/.8);
image(Logs, 145, 441, Logs.width/.8, Logs.height/.8);
image(Logs, 295, 441, Logs.width/.8, Logs.height/.8);
image(House, house1X, house1Y);
image(House, 123, 0);
image(House, 216, 0);
image(House, 309, 0);
image(House, 402, 0);
image(Santa, santaX, santaY);
textFont(FontA);
fill(255);
textSize(28);
text("Score", 3, 505);
text(Score, 160, 505);
if (alwaysmove)
{
if (runOnce)
if (up) {
if (upblock==false)
santaY -=31;
runOnce = false;
//intersect = false;
if (scoreblockup==false)
Score= Score +10;
}
else
if (down) {
if (downblock==false)
santaY +=31;
runOnce = false;
//intersect = false;
if (scoreblockdown==false)
Score = Score -10;
}
if (runOnce)
if (left) {
if (leftblock==false)
santaX -= 31;
runOnce = false;
//intersect = false;
}
else if (right) {
if (rightblock==false)
santaX +=31;
runOnce = false;
//intersect = false;
}
//if (intersect==false) {
//image (Sled, 175, 200 );
//image (Reindeer, 200, 350);
//image (Santa, santaX, santaY);
// }
//else
//{
//fill (255, 2, 2);
//image (Sled, santaX, santaY);
//image (Santa, santaX, santaY-10);
// image (Reindeer, 200, 350);
// }
//if (deerintersect==false) {
// image (Sled, 175, 200 );
// image (Reindeer, 200, 350);
// image (Santa, santaX, santaY);
// }
// else
{
// fill (255, 2, 2);
// image (Santa, 185, 460);
// image (Reindeer, 200, 350);
}
}
//------------------------------------
{
if (santaX==house1X && santaY<=30)
house1collision=true;
}
{
if (house1collision==true)
{
image(Gift, 85, 10);
set(santaX=185, santaY=442, Santa);
}
}
{
{
if (santaX >= width-65)
rightblock=true;
if (santaX <= width-65)
rightblock=false;
}
{
if (santaX <= width-440)
leftblock=true;
if (santaX >= width-440)
leftblock=false;
}
{
if (santaY <= height-490)
upblock=true;
if (santaY >= height-490)
upblock=false;
}
if (santaY >= height-80)
downblock=true;
if (santaY <= height-80)
downblock=false;
}
{
if (santaY >= height-80)
scoreblockdown=true;
if (santaY <= height-80)
scoreblockdown=false;
if (santaY <= height-490)
scoreblockup=true;
if (santaY >= height-490)
scoreblockup=false;
{
//if (abs(santaX-175)< 30 && abs(santaY-200)< 30) {
//intersect=true;
}
}
{
//if (abs(santaX-200)< 30 && abs(santaY-350)< 30) {
//deerintersect=true;
}
}
1