Tennis/Pong in Processing

As the final part of the week 4 KKB210: Computational Arts 1 tutorial, we were provided with a copy of the source code for a sketch/program/challenge that was originally written by Casey Reas. It is based on Pong, though it only partially works, as the challenge is to make it work completely.

We did not work on the challenge in class, instead we looked at bringing in a picture to use as the background and creating tints.

I won’t put up the full source code here, you will have to have a look at the Java applet for all of it, but I will have a look at how to do tints.

Tints are really quite easy to implement. They work the same way as fill works for a rect object, except that it tints the colour of the photo to whatever you specify.

So, the syntax is the same as fill(), it is tint(red,green,blue,alpha).

When using it, it looks like this:

tint(0,153,204,100);
image(laptop,0,0,width,height);

From what I learned earlier in the other parts of the tutorial, it was pretty easy to figure out how to put in the image as the background.

As you would have noticed with fill, by using the alpha channel, you can modify the opacity, so if you were to change the fourth tint() parameter to say 10, it gives the ball and paddles trails. This can of course be adjusted to a suitable length simply by changing the level of opacity.

Have a look at the Java applet.

Note, only one paddle works.

Tags: , , , ,

One Response to “Tennis/Pong in Processing”

Leave a Reply