Hi there!
I just started understanding processing a lil bit and im trying to write a minigame.
The minigame will be pretty simple. Its a character wich can be moved by keys. The player has to collect objects under timepressure.
Well my mainproblem is how to collect the objects and add the points at the counter. How can I define where the character is placed with keyPressed (is there a definition like mouseX, mouseY?!)
thats what i got at the moment..
float bg_ypos = -1800;
float characterx = 300;
float charactery = 450;
float character_geschwindigkeit=3;
float bg_geschwindigkeit=2;
float coiny001=-800;
float coiny002=-900;
float coiny003=-1000;
PImage bg_001_clouds;
PImage intro_lvl_001;
PImage plane001;
PImage coin002_bild;
PFont myriad;
void setup () {
frameRate (0.25);
size (800, 600);
bg_001_clouds= loadImage ("bg_001_clouds.png");
intro_lvl_001= loadImage ("intro_lvl_001.png");
plane001= loadImage ("plane001.png");
coin002_bild= loadImage ("coin002.png");
myriad=loadFont ("MyriadPro-BoldIt-48.vlw");
image(intro_lvl_001,0,0);
}
void draw () {
smooth();
frameRate (200);
bg_ypos = bg_ypos + bg_geschwindigkeit;
if (bg_ypos > 0) {
bg_ypos = -1800;
}
coiny001 = coiny001 + bg_geschwindigkeit;
coiny002 = coiny002 + bg_geschwindigkeit;
coiny003 = coiny003 + bg_geschwindigkeit;
image(bg_001_clouds,0,bg_ypos);
image(plane001,characterx, charactery);
image(coin002_bild,300,coiny001);
image(coin002_bild,350,coiny002);
image(coin002_bild,400,coiny003);
if(keyPressed){
if(key=='a'){
characterx=characterx-character_geschwindigkeit;
}
if (key=='d'){
characterx=characterx+character_geschwindigkeit;
}
if(key=='s'){
charactery=charactery+character_geschwindigkeit;
}
if (key=='w'){
charactery=charactery-character_geschwindigkeit;
}
}
}
thx a lot!
RaG