Advance Programming

What is Java?

Java is one of the programming languages in the computer world. It was developed by James Gosling, Mike Sheridan, and Patrick Naughton in 1991. It was originally designed for television but was too advanced. As of 2015, Java is one of the most used programming languages.

JavaScript

JavaScript, also known as ECMAScript is another programming language. It is mostly used for web browsers. JavaScript was developed by Brendan Eich in 1995. It is classified as a prototype-based scripting language with dynamic typing and first-class functions.

Processing

Processing is an open source programming language and integrated development environment. It was designed by Casey Reas and Benjamin Fry. Processing was built for the electronic arts, new media art, and visual design.

Smiley Face

Here is the code to make a smiley face.

Here is the outcome of the code:

The Bouncing Ball, Part 1

We made a ball bounce around the screen using variables,loops,and conditionals.

Variables

After smiley faces, we made a ball bounce around the screen using variables,loops,and conditionals. In Java, we have to tell Java the variable named "xpos" is an integer. We have to name all the variables for Java to understand. Here is how to write variables in Java:

Loops

To write loops in Java we have to declare integer i and set it to 0. This is our code for looping with the bouncing balls.

Conditionals

To write conditionals in Java, everything has to be in parentheses. With the parentheses, the code will then work using the curly brackets.

Functions

To save a procedure as a function, we need to tell Java how to save it as a function. To do this, we need to tell the program what the function will return. If it doesn't return anything then the function is called "void." Here is the ball function:

Ladybugs

We started drawing ladybugs on Tuesday.

Here is the ladybug function.

Rotation

We saw someone make the ladybugs rotate on Sketchpad.cc. So we decided to try it.

Instead of rotating the ladybug, the screen itself rotated. So it looked like this. The bug was closer to the corners.

pushMatrix() and popMatrix()

In Processing, the rotation center is (0,0). By using pushMatrix,translate, and popMatrix we are able to change the location of the entire grid. We are also able to rotate it and change it back.

Now, we could create a lot of ladybugs using a loop and rotating them at different angles.

The Bouncing Ball, Part 2

After all those things above, we came back to the bouncing ball because we loved it so much.

Classes

In different languages,you can group things together that have certain things in common. They also can be very independent even though they're in the same group. Here is how we did classes in Java:

All the balls in the class will have the properties listed. So they will have velocity,location,size,and color. After that, we declare what the balls do. We just have to update their positions. Here's how we did it.

All we had to do after that was to define a "balls" list. Then we put a bunch of balls in a loop with the setup.

Lastly, the update function was put into the draw loop.

Javascript

As you already read about Javascript, we started using it on Wednesday. It was a total advantage because it works right into the browser. We didn't need to download anything and it would work. All we had to was create a javascript file and we could start creating other files using the original javascript file. We were able to use it in Notepad ++ where we do our HTML. We would start off like this:

Hearts

We saw a website that held a bunch of mother's day cards that people made. We saw some that had hearts and others had flowers. I decided to make a heart. It was pretty easy to make. All we needed was ellipses and triangles. Here is the code:

The result:

Mother's Day Card

After knowing how to create the hearts we made a card. The card was interactive so wherever you moved your mouse, hearts would pop up.

Bezier Curves

Bezier Curves are the curves we need when we are making shapes. Without bezier curves, out hearts would look to pointy and straight. With the bezier curves, we were able to make our hearts curve at the sides. Check out the reference of bezier curves here.

P5.JS Documentation

On Thursday, we put the p5 javascript file in our folders. There were some differences between Processing and p5.js. For example, in processing we would use "size" to determine how big our board would be. In p5.js, we would use "createCanvas()." Also in p5.js, we called our functions "function draw." Instead of saying "void draw" like Processing, we would use "function draw."

The website is p5js.org We can use that website as a reference or to just learn more. Check it out!

Semicolons(;)

In Javascript, we have to use semicolons at the end of each line. While for Python, we don't need semicolons. This is a crazy world.