We are about to switch to a new forum software. Until then we have removed the registration on this forum.
first let me say, sorry for english, i'am french and beguiner in programation. So here , I have a problem with my program . It is a "color memory" game . It only remains for me one thing to do is to display the colors one by one to remember . Except that I do this with a "for" loop , and the loop "for" refreshed the screen only after having finished . So I wanted to know if there was a way to force the refresh ? ( If you want to see all my code called me ) , thank you in advance.
Answers
no, the screen is only refreshed once at the end of draw()
to animate something use the fact that draw() in itself loops all the time
so put the for-loop var in an extra var and just increment it at the end of draw (unteil it reached the upper bound)
I thinks i understand the idea , i try to make this now ! Merci beaucoup !!!
Your advice works very well , but now I have a new problem .... when I have two same color in a row , I can not seem to make the" blinking effect" ... if you had an other idea , I listen carefully :)
http://forum.processing.org/two/discussion/10674/counting-keypressed-and-using-this#latest
Thank you for the info, but I 'm trying , but it still does not working .... like I said I'm not very good in programing ... I can show you what I have do now? ( if yes , please tell me how to put my code to make it as more readable for you )
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
i can't show all my code in one time...
You need to simplify your code just for demonstrating what's wrong.
int m, i, c, p, click, level, n, boule, s, w, temps, a, k; int[] y = new int[20]; int[] x = new int[20]; int[] etat= {0, 0, 0, 0}; void setup() { frameRate(60) ; size(700, 700); p=-1; click=0; level=1; n=-1; boule=0; w=10; temps=0; a=1; k=5; background(25, 25, 25); fill(150, 0, 0); rect(140, 140, 200, 200); fill(0, 150, 0); rect(140, 360, 200, 200); fill(138, 150, 0); rect(360, 140, 200, 200); fill(0, 0, 150); rect(360, 360, 200, 200); choixdescouleurs(); } void draw() { if (etat[0] == 0) { fill(155, 0, 0); rect(140, 140, 200, 200); } else { fill(255, 0, 0); rect(140, 140, 200, 200); } if (etat[1] == 0) { fill(138, 150, 0); rect(360, 140, 200, 200); } else { fill(235, 255, 0); rect(360, 140, 200, 200); } if (etat[2] == 0) { fill(0, 150, 0); rect(140, 360, 200, 200); } else { fill(0, 255, 0); rect(140, 360, 200, 200); } if (etat[3] == 0) { fill(0, 0, 155); rect(360, 360, 200, 200); } else { fill(0, 0, 255); rect(360, 360, 200, 200); } if ((level==a )&&(i<=k+1)) { etat[0]=0; etat[1]=0; etat[2]=0; etat[3]=0; switch(x[i]) { case 1: etat[0]=1; break; case 2 : etat[1]=1; break; case 3: etat[2]=1; break; case 4 : etat[3]=1; break; } i++; delay(700); } } void delay(int delay) { int time = millis(); while (millis () - time <= delay); } void choixdescouleurs() { // fonction permettant de choisir des couleurs aléatoire pour chaque niveau delay(100); if (level==1 ) { for (int i = 0; i<5; i++) { x[i] = 1 + int( random(4)); print (x[i]); } } }
sorry i can't make better ...
Placing the code between `` isn't the right way to post formatted code. :-\"
In order to make your code logic easier, you should consider implementing a class for your colored rect().
sorry , like i say i'am a beguiner in programming , i make this program for the final exam of shcool ( le BAC ) , so if i make class , i should be able to present it ^^
and sorry for my code posting ^^
i think you need to use background(0); at the beginning of draw()
also when you set a rect as ON / show its color say stroke (255); when it's not on, say noStroke(); directly before the code line with rect
not tested
;-)
Sorry I forgot to notify you that it was good, I make what I wanted :) . Thank you all for your help, is very friendly. and hello from France : p
I was doing a sample, but haven't finished yet.
Since you say you've made it, just wanna post it the way it is now: :D
Bonjour Thom_Geek, je parle français et l'anglais très bien, et si vous voulez que je traduis des choses je peux. Aussi je peut t'aider avec ton project! Je regarde ton code maintenant et je ne comprend pas vraiment ce que tu veux faire. Est-ce que le program fait un pattern des coulours et le utilisateur doit se souvenir? Si tu veut me contacter personnellement : ryan@rywestech.com. Je veut te aider.
haha thank you anyway GoTooLoop ;)
Ben je n'ai plus de problème , j'ai réussi à le résoudre. Alors en effet le joueur doit mémoriser des couleurs dans un certain ordre. Mais merci pour la proposition de traduction :).
Now I have another problem . I can not put it under a form of aplication since I adding the sound , someone have an idea?
what do you mean? In a website?