i'm new using mysql in processing and i have to rank values of my table mysql. So i need to get the score, the login and the rank of each player and to show it in the console until 10.
i did that but it doesn't work, it just shows me :
0 null 0 points (10 times) and i don't know what's wrong with it.
void resumeclassement() {
msql = new MySQL( this, serveur, database, userdb, mdpdb );
efface(0,0,800,600);
if ( msql.connect() ) {
text("CLASSEMENT DES 10 PREMIERS JOUEURS", 350, 30);
int p = 45;
int i = 0;
for (int j = 0; j < 11; j = j + 1) {
msql.query("SET @i:=0");
msql.query("SELECT rank, score, login FROM (SELECT @i:=@i+1 AS rank FROM "+table+" ORDER BY score DESC, LIMIT 1,10");
msql.query("SELECT score FROM "+table+" WHERE rank='"+i+"'");
scoreactuel=msql.getInt(1);
msql.query("SELECT login FROM "+table+" WHERE rank='"+i+"'");
msql.next();
login = msql.getString(1);
text(str(i)+" "+login+" "+str(scoreactuel)+" points",380,p);
p = p+15;}
} else {
text("Problème de connexion a la base de données !!!",400,450);}
}
a friend and I we want to create a game. You start the programm, you enter a login and a password, and you select you level of difficulty, then you can play (and image is divided into 16 parts, and each part is discovered one by one and you have to guess what represents the image) and after you can leave the game and compare your score with other players.
Well, the problem is : we divided the work in 2 part.
She did the division of the image, and i did all the rest (ahah). So we juste have to put our work together now.
Her work runs with something which looks like " size(x,y,P2D) ", and mine runs with " size(x,y) "
apparently, the two types don't work together, so i changed mine and put " size (x,y,P2D) ".
I created vairous buttons to click on, to select the level of difficulty or to quit the game. And all these keybord events don't work no more with using " size (x,y,P2D) ".
So.. could you help me ?
What do have to change to make it work ?
(i'm new in using processing, and i absolutely don't know what i can do !)
i'm hopeless at using processing, but i've to realise a programme.
To make it short : it is a game, and i need the user to choose the level of difficulty he wants. There are 3 levels : 1,2 and 3. And I have severals options to make him choose one :
- he clicks,
- he writes 1, 2 or 3
But, in all situations, if he doesn't click in the right place, or if he doesn't write the good number, the loop if with the conditions needs to keep looping. So I tried to insert a While just before but i don't manage to make it work. So, i was wondering if a function like Go To could exist in Processing to make the programme go to the first loop For i created if his action isn't a case i defined in the If.
For the moment i did that :
void setup() {
size(800,600);
}
void draw() {
text("Quel niveau de difficulté ?",10,30);
text("1, 2 ou 3 ?",10,50);
pushStyle();
fill(255,204,40);
rect(30,70,20,20);
rect(60,70,20,20);
rect(90,70,20,20);
popStyle();
text("1",40,90);
text("2",70,90);
text("3",100,90);
int dif=0;
int i = 0;
if (mousePressed==true) {
while(i != 1){
if (mouseX >29 && mouseX<51 && mouseY>69 && mouseY<91) {dif=1; i=1; }
else if (mouseX >59 && mouseX<71 && mouseY>69 && mouseY<91) {dif=2; i=1;}
else if (mouseX >89 && mouseX<101 && mouseY>69 && mouseY<91) {dif=3; i=1;}
else {i=0;}
}}
if (dif!=0) {
float x = random(1,4);
int newx = int(x);
PImage im;
im = loadImage("
http://******************+str(dif)+"/"+str(newx)+".jpg");
image(im,150,150,384,216);
}
}
Or if you have other ideas... I am desperate, i need to finish it in a short while!