Need help with mousePressed
in
Programming Questions
•
9 months ago
Hi,
I´m working on a programm/game the first time in my life and I need help with one function.
I have no idea how to change this:
Thanks a lot!
I´m working on a programm/game the first time in my life and I need help with one function.
I have no idea how to change this:
- float xleft=100, yleft=50, rwidth=77, rheight = 77;
- PImage depp;
- PImage karteverdeckt;
- PImage hintergrund;
- PImage k1;
- boolean clickedCard;
- void setup() {
- size(800, 500);
- depp=loadImage("depp.jpg");
- karteverdeckt=loadImage ("karteverdeckt.jpg");
- hintergrund=loadImage ("hintergrund.jpg");
- k1=loadImage ("k1.jpg");
- }
- void draw(){
- background(hintergrund);
- if (clickedCard) {
- image(depp, 100, 50, 77,77);
- }
- else {
- image (karteverdeckt, 100,50,77,77);
- }
- if (clickedCard) {
- image(k1, 100, 150, 77,77);
- }
- else {
- image (karteverdeckt, 100,150,77,77);
- }
- }
- void mousePressed() {
- if (mouseX > xleft && mouseX < xleft + rwidth && mouseY > yleft && mouseY < yleft + rheight) {
- clickedCard=true;
- }
- else { //ausserhalb geklickt
- clickedCard=false;
- }
- }
Thanks a lot!
1