LaGuardia TechHire -- Open Code

Day Ten: The Finale!

Since the beginning of the TechHire—Open Code vestibule, I have been learning the basics of Java applied in the Processing IDE. For our second coding assignment, with the help of Zein, I decided to create a screen that shows rain pouring. As I’ve documented in previous blog posts, creating this image was no simple feat. I spent days trying to get objects to move on the screen and improve my coding. Just in the context of this one sketch, I learned something new each hour. Even when I was away from the processing IDE, I had my pen and paper to trying to figure out improvements.

For our final project we were given a ‘prompt’ that really just gave us free range to create what we wanted. I was lucky for fluidity of this assignment, because I knew I wanted to continue working on this ‘RainPouring’ project. I mapped out my ideas on paper and tried to bring them to life.

The first task I wanted to accomplish was finding a way to have an umbrella on the screen without having to write so many shapes, which took up many lines of code. Again I find myself giving credit to Daniel Shiffman, because he taught me how to add images to my canvas. The first image I placed on the canvas was of an umbrella against a white background. This royally messed up my vision because it was an ugly box in the center of my background. I soon learned that there is more than one version of an image file. I needed to ditch jPEGs and find myself a PNG. PNGs preserve the transparency behind an image; I didn’t have to worry about a background. Lines 7 through 16 show where I declared and initialized the images I wanted for my project. Now that I had the image on the screen, I wanted to be able to do something with the umbrella. I learned that images work a lot like the familiar primitive rectangle. Lines 35 and 36 show where I call and use the image() function. By setting the image coordinated to the x coordinate to the mouse’s location (mouseX) I could make the umbrella move side to side. I didn’t want the umbrella to move up and down so I kept the y-coordinate at a constant.

</pre>
Droptop[] rDrop = new Droptop[400]; /*instead of two sepearate objects,
i can use on line of coding with an array. An array is a list. '[2]' represents the
number of spaces in the index. in coding, counting starts from the number zero to account for the index.*/

Star[] twink = new Star[300];

int screen = 0; //creates global variable for screen
PImage umpic; //here is where I declared the umbrella image
PImage tweetpic; //here is where I declared a bird image

&nbsp;

void setup() {
size (800, 600);
umpic = loadImage("yellow0.png"); //I loaded the image in setup as oppesed to draw
//used a png. file to preserve transparency
tweetpic = loadImage("tweet.png");

for (int i = 0; i < rDrop.length; i++) { //i can use rDrop.length because it will represent the length of the strong (or how many spots are listed in the array"
rDrop[i] = new Droptop();
}

for (int i = 0; i < twink.length; i++) { //i can use rDrop.length because it will represent the length of the strong (or how many spots are listed in the array"
twink[i] = new Star();
}
}

void draw () {

//=======gloomy sunday=====

if(screen == 0){ //The following code is for a the starting rain screen
//lines 19-21 are where we initialize the array within a loop
background(48, 88, 155);
imageMode(CENTER);
image(umpic, mouseX, 400, 291/2, 300/2 ); //picture of umbrella; follows the mouse along the x-axis, width and heighe/2

for (int i = 0; i < rDrop.length; i++) {
rDrop[i].display();
rDrop[i].move();
}
//clouds
fill(187, 189, 191);
noStroke();
ellipse(25, 0, 150, 150);
ellipse(75, 50, 100, 100);
ellipse(150, 0, 125, 125);
ellipse(775, 0, 150, 150);
ellipse(725, 50, 100, 100);
ellipse(675, 0, 125, 125);
/*order is still very crucial in the function of my code*/
}//close screen 0

&nbsp;

//=======sunny side no eggs =========

if(screen==1){ //this opens the second screen
background(139,223,255);
fill(250,243,28);
ellipse(400,75,300,300);
imageMode(CENTER);
image(tweetpic, mouseX, mouseY, 400/2, 400/2); //picture of bird; follows the mouse along the x-axis, width and heighe/2
}

&nbsp;

if(screen==2){ //this opens the second screen
background(71,61,95);
fill(209,207,204);

for (int i = 0; i < twink.length; i++) {
twink[i].display();
}
ellipse(400,75,300,300);
}
}//close draw

&nbsp;

void mouseClicked(){
background(255); //background flashes white to represent thunder
if ((mouseX >= 0 && mouseX<= 225 && mouseY>= 0 && mouseY<= 150))
screen= 1; //if the clouds are pressed it goes to sun screen
else if((mouseX>=600 && mouseX<=800 && mouseY>= 0 && mouseY<=150))
screen= 2;//if clouds are pressed it goes to sun screen
}
<pre>

The second change I wanted to give my project was to be able to change the weather from rainy to sunny. To do this I added a mousePressed() function. I wanted to be able to press a place on the screen and have the weather change. I chose to say that if I clicked the clouds something would happen. Lines 81-87 show the additions I had to make. In order to do this, I had to find the area that clouds covered on my canvas. I set parameters in the clouds that said if the mouse were pressed there something would happen. I knew I wanted it to be sunny, but the almighty question was ‘how’! After watching coding tutorials by professional coders on how to make complicated games, I began to get a grasp of the basics. It to me well over three hours to grasp these basics, but it did! I had to set up another screen. I created an int named ‘screen’ and assigned it the value 0. This can be seen in line 7. I had to then add this scene change to my if conditional statements. After each parameter of the where the mouse has to be pressed, I put ‘scene==1’ or ‘scene==2’. After learning how to do this, I got excited and decided to make two scenes! (Mind you, it’s now 9am)

Now that I had a new scene, I needed to decorate it. This wasn’t particularly difficult because I know how to create backgrounds and shapes. When it came down to actually writing the code, I had A LOT of difficulty. How to say this information is for one scene and this information is for another scene? If statements to the rescue! Lines 30-54 show my answer to this problem. I could place the information of a particular statement inside of an if statement that was specific to a certain scene. ‘If in scene 0, perform this. If in scene 2, perform that’. My first scene had the rain pouring and a moving umbrella. With the second scene I was able to make it turn into night where I had a moon and stars.

Screen Shot 2017-10-27 at 1.00.31 PM.pngScreen Shot 2017-10-27 at 1.01.03 PM.png

Below you can see the two classes I made, each has its own tab on Processing.

RainDrops:


class Droptop{
color c;
float xpos;
float ypos;
float diam1;
float diam2;
float yspeed;

Droptop() {
c = color(99,196,240,85);
xpos = random(width);
ypos = 0;
diam1 = 20;
diam2 = 30;
yspeed = random(1,4);/*i did not want to make this speed uniform
depending on the amount of blank() used*/
}

void display(){
noStroke();
fill(99,196,240,85);
ellipse (xpos, ypos, diam1, diam2); /*This shows the format for the circles
so I dont have to type it continuously*/
}

void move(){
ypos = ypos + yspeed;
if (ypos > height){
ypos = 0;
}
}
}

Stars:


class Star{
float xpos;
float ypos;
float diam1;
float diam2;

Star() {
xpos = random(width);
ypos = random(height);
diam1 = 10;
diam2 = 10;
}

void display(){
noStroke();
fill(255);
ellipse (xpos, ypos, diam1, diam2); /*This shows the format for the circles
so I dont have to type it continuously*/
}
}

Today’s presentation of our final projects marked the end of the TechHire—OpenCode vestibule. Each Participant was allotted seven minutes to present there project. These seven minutes included setting our laptops to the projector, talking through our code, running our code, and lastly a Q&A session. I am generally a great public speaker, but Friday had my nerves rattled. I felt the pressure. My presentation could make or break a possible invitation to the full TechHire—OpenCode program. I felt the pressure. After setting up my laptop, my anxiety steadily receded. I was able to talk through my code in a manner that showed my understanding and dedication to the project. I was surprised to hear subtle gasps when I showed the interactivity portion of my sketch. There was less than a minute left for Q&A and I was able to still answer two questions without gabbling. My supportive classmates gave me a round of applause, which erased all doubt about the quality of my project.

These past two weeks have taught me so much in the world of web development. I learned about job placement and techniques in coding. The most important lesson I learned during my time with TechHire—Open Code is that there is no limit to what I can accomplish if I put my mind to it.

LaGuardia TechHire -- Open Code

Day Eight: I need ‘Array’ to get through this!

Humor is everywhere in that there’s irony in just about anything a human does. -Bill Nye

giphy (3).gif

After spending my weekend in a constant flux between sleeping and feeling guilty for sleeping, it was very difficult to keep from laughing during today’s career training portion of TechHire–Open Code. We focused on the imposter syndrome, productivity and being able to work on your own, as a portion of the program will be remote. I spent the whole weekend in a personal crash course on accountability and productivity. How’s that for irony!

The imposter syndrome is prevalent within the web development community.  The feeling of fraudulence often comes from a person believing that they do not deserve praise or title. People who experience this often attribute their success to circumstances distant from themselves. By doing this, ‘imposters’ do not have to internalize compliments. High achievers are a main demographic of imposter syndrome sufferers. Web development is a difficult field that only has room for high achieving individuals. In the past couple decades technology has progressed at an exponential rate. New technologies are being invented and implemented everyday while web developers are required to have a firm grasp on this ever changing technology. Entering the web development profession by means of a bootcamp might intensify the imposter syndrome because it is not a ‘traditional’ education. Feelings of doubt can easily seep into the psyche when a person feels amateur despite their actual work and knowledge. A video by Meg Duffy, dean of students at Grace Hopper Program, provides tips to combat the imposter syndrome for bootcamp students and aspiring web developers.

One cliche phrase that describes me well is ‘Jack of all Trades’. When I am faced with a concept that I cannot easily grasp my the world seems to tilt one degree about its axis. This shift is usually due to frustration and only takes a moment to recalibrate. Never the less, the shift is there and I sometimes feel like an ‘imposter’ myself. When beginning this program I was shocked at how difficult it was for me to grasp certain concepts. There are times where I have gone home without fully understanding of topic. Today was one of those days. During the web immersive portion of the day, I ‘learned’ about objects, classes, and arrays. As my luck would have it, our class was given an assignment to include these new topics in our code. My day stuck to the theme of irony, as we reviewed arrays at the tech event I went to after class. (Read about that experience here) By the time I got home (10:30 PM) my mental tank was approaching E for empty. The main point of objects, classes, and arrays is to condense and better organize your code. Naturally (high achieving as I am), I decided to work with my most cumbersome code. My newly titled, ‘RainPouring’ project needed a serious renovation. After reviewing my notes and staring at my code for a solid hour, I was still at a lost for how to transform my code. Once again, the internet proved to be a saving grace with my coding pot holes. I won’t discuss my serious religious beliefs, but Daniel Shiffman may be a deity in the web development world, or at least my web development world. As one of the lead contributors to Processing, I didn’t doubt his knowledge. When I saw The Coding Train on YouTube, I quickly bought my ticket and hopped aboard. I found tutorials that answered my questions, gave effective guidance, and kept me engaged.

While watching Daniel’s videos I took notes and drew pictures to make sure I understood the information I was absorbing.

img_4247.jpg
Notes

 

The original code I was working with can be seen on my previous post; Day Three: Magic in the Number Three! The edits and comments to the my code today can be seen below. A new concept of a constructor tab was introduced to me today. Objects can be written in the original sketch page of a program, but it becomes a lot of work when you want to use more than one object. If you want to use 50 objects, a constructor tab is the way. Lines 12-13 show the code I would need to write if I did not have a constructor tab for only two rain drops. Two drops doesn’t count a rain. The constructor tab is necessary for what I am trying to accomplish.


Droptop[] rDrop = new Droptop[200]; /*instead of two sepearate objects,
i can use on line of coding with an array. An array is a list. '[2]' represents the
number of spaces in the index. in coding, counting starts from the number zero to account for the index.*/

void setup() {
size (800, 600);
for (int i = 0; i < rDrop.length; i++){ //i can use rDrop.length because it will represent the length of the strong (or how many spots are listed in the array"
rDrop[i] = new Droptop();
}
}
/* this shows how to call object in setup
rDrop[0] = new Droptop(40,4);
rDrop[1] = new Droptop();*/

void draw (){
background(48,88,155);

//umbrella
fill(234,242,12);
ellipse(400,300,300,200);

/*shapes to create umbrella and hide yellow, this code has to be
placed below the umbrella ellipse, so it is place 'over' the yellow*/
fill(48,88,155);
noStroke();
ellipse(290,325,75,75);
ellipse(515,325,75,75);
ellipse(440,325,75,75);
ellipse(365,325,75,75);
rect(252.5,325,300,75);

//umbrella holder
strokeWeight(4);
stroke(0);
line(402,315,400,400);

//lines 19-21 are where we initialize the array within a loop
for (int i = 0; i < rDrop.length; i++){
rDrop[i].display();
rDrop[i].move();
}

//lines 49-56 show just a fraction of the cumbersome coding from my original sketch

//clouds
fill(187,189,191);
noStroke();
ellipse(25,0,150,150);
ellipse(75,50,100,100);
ellipse(150,0,125,125);
ellipse(775,0,150,150);
ellipse(725,50,100,100);
ellipse(675,0,125,125);
/*order is still very crucial in the function of my code*/
}

Below is the code for the Constructor tab.


class Droptop{ //Here I am creating a class and making float values
color c;
float xpos;
float ypos;
float diam1;
float diam2;
float yspeed;

Droptop(float tempX, float tempYs){ /*float tempX and float tempYs are placed here
so I can alter the x position and speed easily in the parameters of my object. */
c = color(99,196,240,85);
xpos = tempX; //Here I assigned xpos as tempX so the value I plave in () will come from here.
ypos = 0; //I want all the rain to start from 0
diam1 = 20; //I want both of my diameters to stay the same, so they are not 'temp'
diam2 = 30;
yspeed = tempYs; //Here I assigned yspeed as tempYs so the value i put in () will be taken from here
}

Droptop() { /*Here I made a second version of the same function,
so it isnt necessary to fill (). This is called 'overloading'*/
c = color(99,196,240,85);
xpos = random(width);
ypos = 0;
diam1 = 20;
diam2 = 30;
yspeed = random(1,3);/*i did not want to make this speed uniform
depending on the amount of blank() used*/
}

void display(){
noStroke();
fill(99,196,240,85);
ellipse (xpos, ypos, diam1, diam2); /*This shows the format for the raindrops
so I dont have to type it continuously*/
}

void move(){
ypos = ypos + yspeed;
if (ypos > height){//this loop stays in effect as long as the raindrops are below the height
ypos = 0;
}
}
}

Below shows how my code runs.

Oct-26-2017 05-02-19.gif

LaGuardia TechHire -- Open Code

Day Eight: Intro to Java… Script?

TechHire has a requirement of attending one technology related event. I contemplated going to a hackathon but I was not confident with my skill level in coding. I am a person who enjoys going to events and mingling, so I wasn’t nervous about finding an event that wasn’t too focused on a person’s coding skill. Besides the world wide web, I had a few other resources to find an event that satisfied TechHire’s requirement. When it comes to events New York City is in abundance. After scrolling through just my Eventbrite, I had over 6 events I could attend in the allotted time frame provided by my instructor.

I chose to attend ‘Learn to Code NYC: Into to JavaScript’. Though we are learning Java on Processing, I thought the two languages couldn’t be so different because of their name. Seriously speaking, I have played with JavaScript very lightly and know the general syntax of the language. That being said it was an Introductory course, no pressure right? Well, half right… After spending hours discussing how to evade the imposter syndrome, I still found myself in well within it’s reach. One phrase that sticks in my head from my elders when I’m feeling ill prepared is “don’t embarrass me”. I care for embarrassment even less than green eggs and ham, Sam I am! I managed to concoct reasons of why I wasn’t qualified enough to attend an introductory course! For some, these thoughts would make a person feel stuck, unable to decide one way or the other, but not I. I told myself that I would learn as much Java script as I could in two hours. My binge learning began with me downloading an iOS application called ‘Learn JS’. The application made my 2 hour commute feel like 30 minutes. I didn’t fully notice the delays that seemed to strongly affect that the commuter next to me.

Screen Shot 2017-10-26 at 11.06.47 AM.png

Galvanize is the company that sponsored and ran the class. Their building space had an open floor plan that made everyone inside feel like family. The open floor layout encouraged me to talk to other attendees even though i wasn’t confident in my knowledge of JavaScript. As the class began, I took a seat next to my TechHire classmate, Danny. The JavaScript class wrote code on an online IDE on repl.it. I was relieved that TechHire had us make a Github account, because I was able to easily login and save the code I wrote in the class. In the class we learned about how to make functions and I learned about arrays. The syntax of for statements is similar to Java. Learning about arrays and functions here was very helpful to the assignment I had to tackle after the event.


//how to create a function
function pigLatin (str){
var firstChar = str[0];
var restOf = str.substr(1);
return restOf + firstChar +'ay';
}

function makePigLatin(sentence){
var words = sentence.split(' ');
var translated = [];
for(var index = 0; index < words.length; index = index +1){
var val = words[index];
var pig = pigLatin(val);
translated[index] = pig;
}
return translated.join(' ');
}

After the class I talked to the instructor, Donnie D’Amato. He calmed my worries about being a newbie and encouraged me to pursue my dreams, especially if they are difficult. Donnie gave me a great confidence boost when he took the time to show me his Codepen.io page. He showed me his current projects as if he was trying to network with me! Though he was teaching JavaScript, only a couple of his projects had any JavaScript in it. About 90% of his projects were solely CSS and HTML. This comforted me because, as an amateur, I didn’t feel like I had to learn a million languages at once. I can  possible create anything with any language. Dawn’s most frequently used phrase in class is “There is more than one way to skin a cat”. Don’t I believe that now!