indianyar101
YaBB Newbies
Offline
Posts: 5
Displaying Text Problem
Apr 7th , 2010, 7:14pm
Hello. I am new to programming in processing. I recently made a small game, but I cannot make the score display using the text() command. In the game, the user controls a small ellipse with the arrow keys and tries to catch and evading box. Here is the code: //created by indianyar PFont font; int Time=(minute()*60+second()); int Boxes=0; int A=100; int X=100; int R = int(random(1,199)); int S = int(random(1,199)); int Present=0; void setup() { size(200, 200, P2D); background(0,100,170); rect(R,S,10,10); font = loadFont("TimesNewRomanPSMT-16.vlw"); textFont(font); fill(240); } void draw() { background(0,100,170); Present= minute()*60+second(); if(int(abs(Time-Present))>=60) { println("it came here"); delay(250); println("it came here"); delay(600); text("You caught this many boxes:", 30, 40); text(Boxes, 30, 60); save("evidence.tiff"); println("it came here"); delay(250); background(0,100,170); print(Boxes); exit(); } keyPressed(); } void keyPressed() { background(0,100,170); rect(R,S,10,10); int J = int(random(-10,10)); int K = int(random(-10,10)); if((R+J)>=200) { J=0; } if((R+J)<=0) { J=0; } if((S+K)>=200) { K=0; } if((S+K)<=0) { K=0; } if (key == CODED) { if (keyCode == UP) { R=R+J; S=S+K; X=X-1; if(X==0) { X=X+1; } ellipse(A,X,5,5); rect(R,S,10,10); } else if (keyCode == DOWN) { R=R+J; S=S+K; X=X+1; if(X==200) { X=X-1; } ellipse(A,X,5,5); rect(R,S,10,10); } else if (keyCode == LEFT) { R=R+J; S=S+K; A=A-1; if(A==0) { A=A+1; } ellipse(A,X,5,5); rect(R,S,10,10); } else if (keyCode == RIGHT) { R=R+J; S=S+K; if(A==200) { A=A-1; } A=A+1; ellipse(A,X,5,5); rect(R,S,10,10); } } if ((((R+5)>=(A+2.5))&&((R-5)<=(A-2.5))&&((S+5)>=(X+2.5))&&((S-5)<=(X-2.5))) == true) { R = int(random(1,199)); S = int(random(1,199)); rect(R,S,10,10); Boxes=Boxes+1; } } I tested the code by adding print statements, and the program reached all the print statements. I also tested it by using the save function. The saved image shows a screen with the text, but when the user plays the game the user cannot view the score. I am really confused now. I added delay statements, but they did not help. - Indianyar