We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › A bit stuck on PONG tutorial
Page Index Toggle Pages: 1
A bit stuck on PONG tutorial (Read 1143 times)
A bit stuck on PONG tutorial
Nov 29th, 2006, 5:57pm
 
I'm currently following the French tutorial translated into english @

http://translate.google.com/translate?u=http%3A%2F%2Fwww.ecole-art-aix.fr%2Frubrique.php%3Fid_rubrique%3D81&langpair=fr%7Cen&hl=en&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools

Im halfway through the tutorial and stuck on something. When I  hit 'play' Processing highlights the words "to clean" then the rest of the words under "void draw". It says "expecting SEMI found 'clean'.

The program as follows:

int deplacementX;
int X;

void setup () {
size (400,400);      // mock face
X = 0;              // position horizontal
deplacementX = 1;   // displacement
noStroke ();         // not of feature
fill (0,0,0,255);    // filling black
}


void Draw () {

to clean ();
to move ();
to rebound ();
to draw ();

}


void to clean () {  
background (255);
}


void to rebound () {

yew (X > width) {
  deplacementX = -1;
}

yew (X < 0) {
  deplacementX = 1;
}

}


void to move () {
X = X + deplacementX;
}


void to draw () {
rect (X, 195,10,10);
}

Can anyone help me out. Im still a beginner! Thanks in advance!
Re: A bit stuck on PONG tutorial
Reply #1 - Nov 29th, 2006, 6:42pm
 
The reason why it's not working is because the translation from french turned to be different.

the french verb "nettoyer"  means " to clean" in english.

You just have to remove "spaces" added by the translation.

or just copy/paste the whole "original" source and you'll see the difference.

Because the translation is expecting french language, it tries to translate everything, even programming language, which is english.

The solution is simple :

You should not use translation software to translate source code.

Quote:
int displacementX;
int X;

void setup () {
size(400,400); // mock face
X = 0;    // position horizontal
displacementX = 1;   // displacement
noStroke();    // not of feature
fill(0,0,0,255);    // filling black
}


void draw() {

toclean();
tomove();
torebound();
todraw();

}


void toclean() {  
background (255);
}


void torebound() {
 
if (X > width) {
  displacementX = -1;
}
 
if (X < 0) {
  displacementX = 1;
}

}


void tomove() {
X = X + displacementX;
}


void todraw() {
rect (X, 195,10,10);
}

Wink
Re: A bit stuck on PONG tutorial
Reply #2 - Nov 29th, 2006, 11:22pm
 
Thanks a lot. I know while cross referencing the original french version and english version there were a few discrepancies. Its just not knowing which and what to translate! Thanks again... I can now continue my tutorial!

Jai
Re: A bit stuck on PONG tutorial
Reply #3 - Nov 30th, 2006, 12:49am
 
Hot damn not working again... int displacementX;  
int X;  

void setup () {  
size(400,400); // mock face  
X = 0;    // position horizontal  
displacementX = 1;   // displacement  
noStroke();    // not of feature  
fill(0,0,0,255);    // filling black  
}  


void draw() {  

toclean();  
tomove();  
torebound();  
todraw();  

}  


void toclean() {    
background (255);  
}  

void tomove() {
X = X + displacementX;
y = y + displacementY;   //to move on the vertical axis
}  

void torebound() {  
 
if (X > width) {  
  displacementX = -1;  
}  
 
if (X < 0) {  
  displacementX = 1;  
}  

if (y > width) { //bounce from bottom
displacementY = -1;
}  

if (y < 0) { //bounce from the top
deplacementY = 1;
}

void todraw() {
rect(X,Y,10,10);  // to draw the position according to the X and Y
}  

Where it has 'void todraw'it Processing comes with 'unexpected token:void"

Anyone?
Re: A bit stuck on PONG tutorial
Reply #4 - Nov 30th, 2006, 11:59am
 
Processing is case sensitive and need a clean syntax.

Just compare this corrected code with the code you posted just before.

Quote:
int displacementX, displacementY;  
int x,y;  
 
void setup () {  
size(400,400); // mock face  
x = 0;    // position horizontal  
displacementX = 1;   // displacement  
noStroke();    // not of feature  
fill(0,0,0,255);    // filling black  
}  
 
 
void draw() {  
 
toclean();  
tomove();  
torebound();  
todraw();
 
}  
 
 
void toclean() {    
background (255);  
}  
 
void tomove() {
x = x + displacementX;
y = y + displacementY;   //to move on the vertical axis
}  
 
void torebound() {  
 
if (x > width) {  
  displacementX = -1;  
}  

if (x < 0) {  
  displacementX = 1;  
}  

if (y > width) { //bounce from bottom
displacementY = -1;
}  
 
if (y < 0) { //bounce from the top
displacementY = 1;
}
}  
void todraw() {
rect(x,y,10,10);  // to draw the position according to the X and Y
}
Re: A bit stuck on PONG tutorial
Reply #5 - Nov 30th, 2006, 1:11pm
 
jaylfk wrote on Nov 30th, 2006, 11:59am:
Processing is case sensitive and need a clean syntax.

Just compare this corrected code with the code you posted just before.



Ah I see where I went wrong I forgot the close the "void torebound" implementation. Thanks again.

What a learning curve!
Re: A bit stuck on PONG tutorial
Reply #6 - Nov 30th, 2006, 5:18pm
 
This now works...

int x,y, displacementX, displacementY;

void setup () {  
size(400,400); // mock face  
x = 200;    // position horizontal  
y = 200;    // vertical position
displacementX = 5;   // displacement  
displacementY = -3;   // vertical displacement
noStroke();    // not of feature  
fill(0,0,0,255);    // filling black  
}  

void draw() {  

toclean();  
tomove();  
torebound();  
todraw();  

}  

void toclean() {    
background (255);  
}  

void torebound() {  

//if one is (too on the right AND positive) OR one is (too on the left and negative)
if ( (x > width && displacementX > 0) || (x < 0 && displacementX < 0) ) {
 displacementX = - displacementX;
}

//if one is (too low and positive) or one is (too high AND negative)
if ( (y > width && displacementY > 0) || (y < 0 && displacementY < 0) ) {
 displacementY = - displacementY;
 }
}

void tomove() {
x = x + displacementX;
y = y + displacementY;   //to move on the vertical axis
}  

void todraw() { // draw the ball
ellipse(x,y,10,10);  // to draw the position according to the X and Y
}  

But now I was wondering how I add traces of movement behind the ball. Would I have to place some coding at the beginning at 'void setup' or is something I should place at 'void todraw'?

Is there a good tutorial for floating objects. As I have no clue how to even comprehend how it even works =S
Page Index Toggle Pages: 1