Episode 1 of James Learns Programming!
Who knows if this will lead to a whole blog series or my laziness will render this to be an embarrassing standalone post but oh well... I deleted my games so I may as well post about it with all the free time I have (not much actually). I don’t know why I mentioned that or why I am still narrating my thought process but ANYWAYS!
Tonight, I have decided to finally tackle Assignment 2 for my programming class which requires me to simulate a certain number of balls (hopefully three) bouncing around a canvas. And so that when they collide with each other, they stick together and continue to bounce around in unison.
The epitome of contentment or perhaps postception...
I began by setting up the canvas, setting the ellipse mode to center cause why not and before I do anything else, I’m gonna teach myself how to do OOP (Object Oriented Programming I think??) and to use PVectors.
Here is the video I am currently watching to accomplish the latter:
https://www.youtube.com/watch?v=7nTLzLf7jUg
Let’s see where this goes...
__________________________________________
location = new PVector (100, 50);
___________________________________________
Oh... wow. So here’s what I learnt:
PVector is a class that stores two variables (three but we shall not tread into the 3D realm yet): x and y
It’s used so you don’t have to keep on typing x and y all the time and also so that you know what the x and y are for (eg. the x and y components of velocity, location, etc)
The video contains code that does everything except collision detection... but I won’t abuse it cause learning is gud
Now that’s done, I shall attempt to replicate the code from scratch... right after I figure out how to make a class (hahaha siiiiigh I’m so far behind).
Important Stuff to Keep Note of While I Read That I’ll Forget After Reading:
Class: a description of the structure of an object
Instance: a specific example from a class
After you define a class, you can use it as a new variable type
Okay reading sucks here’s a video(s) on Classes in Processing:
https://www.youtube.com/watch?v=lmgcMPRa1qw (defining a class part I)
https://www.youtube.com/watch?v=XwfOVFelLoo (defining a class part II)
A lot of the info about defining a class has gone way over my head especially the constructor part of it so I’m going to play around with it in processing now.
HEY! So I kinda got it, I managed to create a class for balls and had their locations and radii successfully randomized upon generation.
And now I have managed to get them bouncing around the screen.
It is now time for me to go to bed as I have some random class at 9 am tomorrow to go to.
Tonight was a lot of fun :).