Not Pong

Today I put all of my coding knowledge together and coded this emulation of pong. It’s not finished but the difficult parts are done. The bats move and collision detection is sorted. I need to add scoring and to fancy it up with bell and whistles.

I’m on to learning about Object-Oriented Programming (OOP). This is the bit I have been looking forward to. From here I can programme a lot of things. My first goal is to rte code the not_Pong using OOP.

Below behold the game.

This is my emulation of pong in processing


A little colour

A more colourful sketch than I have been doing of late.

This uses FOR loops to draw the squares along the x axis; and another to draw the squares on the y axis.

The colour is controlled by the mouse movement. Long details below.

The colour in processing is by default set up as (red, green,blue). It's basically colour mixing with light.

The red component in the sketch is defined by the distance of the x co -ordinate of the mouse minus the x value of the square on the grid it is over , expressed as an absolute. ( which means its a positive number at all times. ).

The green component is defined by the y coordinate of the mouse minus the y value of the square it is over expressed as an absolute.

The blue component is defined by the mouse's x coordinate minus the width divided by two expressed as an absolute.

Yeah I know. My brain did that many many many times. But now I know what it all means and how it works. So I can actually write this stuff. Yay elastic brain learning.

boolean functions mainly

I’m making good progress with my learning in processing. Much to the irritation of my children. I like to advise them in great detail of how and why I have made such and such a coding decision and what happened and how I overcame the dreadful situation. They are 10 and 7 and really just want to play minecraft.


Today I was covering the use of loops. WHILE and FOR loops. I have done this before,but I actually know what I’m doing as opposed to knowing how to do it. Below is my work from today. (I’m still trying to work out how to embed the entire digital work in a smaller window. I’ll figure it out eventually and put these all in a gallery.)



Coding and the feel of satisfaction

I’m trying to learn Processing . Again. Properly this time honest. I am coding a bit every day to get better. Covering old things I know nad things I thought I knew. As part of this learning I am also trying to communicate the code in pseudo -code. Hopefully this will make my methodology clear to everyone and help me to think in a sequential fashion to solve my coding problems.
I’m currently using boolean TRUE/FALSE functions. Below is the pseudo-code and the link to the processing Sketch.


https://www.openprocessing.org/sketch/901734

I found this very logical to code. The feeling I get from watching the sketch in action is oddly satisfying. It was the same for coding it.

It uses a truth table. There are main variables the X co-ordinate position and the Y co-ordinate position.

The square has to move in 4 directions. :

1 Left to Right;

2 Top to Bottom:

3 Right to Left;

4 Bottom to Top;

Let’s say the width is 200 and the height is 200. In the code the TOP RIGHT corner is (0,0) so X = 0 and Y = 0.

1.(X,Y) is at (0,0) to move LEFT to RIGHT

X is 0. Y is 0. X needs to increase from 0 to 200.

While the Y co-ordinate (height) remains at 0.

2. (X,Y) = (200,0) to move TOP to BOTTOM

X is now 200. Y is 0. Y needs to increase from 0 to 200.

While X remains at 200.

3. (X,Y) = (200,200) to move RIGHT to LEFT

X is 200. Y is 200. X needs to decrease from 200 to 0.

While Y remains at 200.

4.(X,Y) = (0,200) to move BOTTOM to TO.

X is 0. Y is 200. Y needs to decrease from 200 to 0.

While X remains at 0.

5. Go To 1.

.

I find this oddly satisfying . The rectangle simply goes around the border of the sketch window