We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code: My attempt is under //---CONTROLS PLAYER---//
//---BOOLEAN(SET VARIABLE (TRUE/FALSE)) FOR CURSOR HIDE---//
boolean Lpressed = false;
int FPS = 120;
int Wait = 150;
int IW = 95;
int IH = IW + 10;
//---IMAGES---//
PImage bg;
//---THE PLAYER---//
Player Erstad;
class Player {
void setup() {
Erstad = loadImage("Erstad.png");
}
PImage Erstad;
float posX;
int y;
Player() {
bg = loadImage("City.jpg");
Erstad = loadImage("Erstad.png");
y=height-105;
posX = (width/2) - 60;
}
void draw() {
image(bg, 0, 0, width, height);
image(Erstad, posX, y, IW, IH);
imageMode(CORNER);
}
//---CONTROLS PLAYER---//
void keyPressed() {
if (keyCode == RIGHT)
posX++;
if (keyCode == LEFT)
posX--;
}
}
void setup() {
//---SCREEN SETTINGS---//
fullScreen(P2D, 1);
frameRate(FPS);
//---CURSOR DESIGN---//
cursor(HAND);
noCursor();
Erstad = new Player();
//---NAME OF THE GAME TEXT TOP LEFT CORNER---//
String s = "The Legend of Erstad ©Josh Lisk";
fill(230);
text(s, (width/2)-680, (height/2)-380, 140, 90);
}
//---MAIN LOOP---//
void draw() {
//---CLOSE PROGRAM - WHEN ESC PRESSED---//
if (keyPressed) {
if (keyCode == ESC ) {
exit();
}
}
//---HIDE/SHOW CURSOR---//
if (Lpressed == false) {
if (keyPressed) {
if (key == 'l' || key == 'L') {
Lpressed = true ;
noCursor();
//---DELAY BETWEEN THE END AND THE START OF THE LOOP---//
delay(Wait);
}
}
} else if (Lpressed == true) {
if (keyPressed) {
if (key == 'l' || key == 'L') {
Lpressed = false;
cursor();
//---DELAY BETWEEN THE END AND THE START OF THE LOOP---//
delay(Wait);
}
}
}
//---DRAW THE PLAYER---//
Erstad.draw();
}
Answers
WAH! @-)
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text#latest
At some point you must draw your image:
You draw it at some position, (x,y). If x and y are variables:
You can just change their values and thus the image will change positions:
I can't still get the sketch to work?
Now that I can see your code, I see that you are using delay()!
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO. ^#(^
Unless you are doing weird black magic with multiple threads, you should not be using delay. Whatever you think it does is not what it does. It is not doing what you think it is doing. You don't need to use it. Don't use. NO. NO. DO NOT USE DELAY().
Just remove all calls to delay and post your code again without any calls to delay in it. Just don't have it in there at all. I don't care it it ruins the feel of what you are trying to do. Just take it out.
NO. CALLS. TO. DELAY().
Then we'll try again.
Ok, now I have deleted that part