Saturday, December 13, 2014

Another Two Programs

My most recent assignment was one where I had to make a square and have it so that when the user (square) reaches the edge of the window, the user (square) will appear on the other side (left <-> right, top <-> bottom). I created a very interesting square that is constantly changing colors in the middle, but has a very thick yellow stroke weight. I did this just for fun not because it was part of the assignment. In order to do this, I first created two int's. This two int's (squarex & squarey) declare the size of the square which is 400x400. In order to get the square to move, I had to use keyPressed. I made it so that when keyCode UP was pressed the square increased by 60, when keyCode DOWN was pressed the square decreased by 60 and I continued this for the LEFT and RIGHT keys. This allowed my square to move left, right, up and down by 60 when certain keys were pressed. This is what those codes looked like:

void keyPressed(){
if(keyCode == UP){
   squarey -= 60;
 }
 else if(keyCode == DOWN){
   squarey += 60;
 }
 else if(keyCode == LEFT){
   squarex -= 60;
 }
 else if(keyCode == RIGHT){
   squarex += 60;
 }

Then I had to make it so that when the square reached the far left of the screen it appeared on the right, when it reached the far right on the screen it appeared on the left and so on. In order to do this, I used if statements. My if statements basically said if squarex goes beyond the width make squarex equal 0. Meaning make squarex reappear at coordinate (0,?). Also, if squarey goes beyond the height make squarey equal 0. Meaning make squarey reappear at coordinate (?,0). I basically repeated this four times simply changing where the square. So if squarex is less than 0 make squarex=width. This is what those codes look like:

// (Too far right)
  if(squarex > width){
    squarex=0;
   
    
  }
// (Too far left)
  if(squarex < 0){
     squarex=width ;
 
 
}
  //(Too far down)
  if( squarey > height){
    squarey=0;

  }
   //(Too far up)
  if( squarey < 0){
    squarey=height;
  
  }   
}
 

Altogether these codes made it so that when the user reached  the edge of the window, the square will appear on the other side (left <-> right, top <-> bottom).

“Yes, we have a dress code. You have to dress.”
– Scott McNealy, co-founder of Sun Microsystems

Wednesday, December 3, 2014

CSE Moving Lines

A few days ago in Computer Science Engineering we learned how to create lines that follow the mouse and has a background that changes color when the mouse is pressed. The background was the easiest part because all we had to do was create an int, we chose color c then using what we learned previously when doing our assignment called 2 programs. Using that information I created the code below:

 void mousePressed() {
  c = color((int)random(256), (int)random(256), (int)random(256));
}

Then we created two variables to keep track of the vertical lines x position and the horizontal lines y position. We called these two global variables int x and int y. While talking in class we learned about mouseX and mouseY. mouseX and mouseY keep track of the current horizontal  and vertical coordinates of the mouse. This is helpful because  in order for the lines to follow the mouse the computer must know where the mouse is. We all agreed that if statements should be used in this code. Our first if statement was, if the position of mouseX was less than x or to the left the x position of the line should be decreased. We type this into processing and realized it worked. We used this same mindset to finish the rest of the code. So, if mouseY was above, they-position of the line should decrease, and so on. Our finished code is below. 

  if (mouseX < x) {
    x--;
  } // otherwise

  else if (mouseX > x) {
    x++;
  }

  if (mouseY < y) {
    y--;
  } // otherwise

  else if (mouseY > y) {
    y++;
  }

  line(x, 0, x, height);
  line(0, y, width, y);
} // end of draw

Once we pieced these two codes together we were finished the assignment. The entire code is down below. 

// lines  follow the mouse
// we need to keep track of the vertical line's x-position
// we need to keep track of the horizontal line's y-position

// global variables
int x;
int y;
color c;

void setup() {
  size(700, 500);
  c = color((int)random(256), (int)random(256), (int)random(256));
  background(c);

  frameRate(300);
  x = width / 2;
  y = height / 2;
} // end of setup

void draw() {
  background(c);

  // if mouse is to the left, decrease x-position of the line
  if (mouseX < x) {
    x--;
  } // otherwise
  else if (mouseX > x) {
    x++;
  }

  // if mouse is above, decrease y-position of the line
  if (mouseY < y) {
    y--;
  } // otherwise
  else if (mouseY > y) {
    y++;
  }

  line(x, 0, x, height);
  line(0, y, width, y);
} // end of draw

void mousePressed() {
  c = color((int)random(256), (int)random(256), (int)random(256));
}

/*
// single condition if statement
 if(condition){
 ...
 }

 // multi-condition if statement
 if(condition){
 ...
 }
 else if(condition){
 ...
 }
 ...
 else{
 ...
 }

 */

“It’s OK to figure out murder mysteries, but you shouldn’t need to figure out code.  You should be able to read it.”
– Steve McConnell
   

Saturday, November 8, 2014

Boucing Ball


I recently had an assignment where I had to create  a ball that is aware of the sides of the screen and bounces. In order to complete this assignment I used what I learned about int's and  if statements. In order to get he balls to move but not further than the width I used this code:

if(bballx > width){
    bballx=width;
    movex=-movex;
    
  }

This code allowed me to control how far past the width of the screen the ball went. I used this same code except I removed the width and placed it on  either height or 0 and I changed bball x and movex with bbally and movey depending on what part of the screen I was dealing with. The full code is down below.

//Original Position of my variables
 int bballx=400;
 int bbally=300;

//How much the balls should move
 int movex=6;
 int movey=10;


void setup(){
 size(760,760);
 background(#CD00FC);

 strokeWeight(4);
  
}

void draw(){
  background(#CD00FC);
  stroke(#00FCD0);
  strokeWeight(4);
  fill(#3E00FC);
  ellipse(bballx,bbally,100,100);
  bballx = bballx + movex;
  bbally = bbally + movey;
 
  // (Too far right)
  if(bballx > width){
    bballx=width;
    movex=-movex;
    
  }
// (Too far left)
  if(bballx < 0){
    bballx=0 ;
    movex = -movex;
 
}
  //(Too far down)
  if(bbally > height){
    bbally=height;
    movey = -movey;

  }
   //(Too far up)
  if(bbally < 0){
    bbally=0;
    movey = -movey;
  }   
}
 
“Make everything as simple as possible, but not simpler.”
– Albert Einstein








Friday, October 24, 2014

2 Programs

Today in class we learned more about the basics of processing. One of which is frameRate. frameRate is how often draw is called a second. So, if I were to write frameRate(100) draw would be called 100 times in a second. We learned about smooth() which is an attribute that smooths out the lines so that they won't look so pixelated. But the coolest thing  we learned  today is an input called if(mousePressed). The input if(mousePressed) is the input used when you want the computer do so something every time the mouse is pressed. For example, if you want the computer to create a circle where the mouse if every time the mouse is pressed you would use the code:

if(mousePressed){
   ellipse(mouseX, mouseY, 50, 50);
 }

This code basically says when the mouse is pressed create a circle, where the mouse is hovering that, is 50 coordinates down and 50 coordinates across. I really enjoyed learning how to use the input if(mousePressed) and I can't wait to create my own code using this input. The code we created in class is down below.

void setup() {
 size(500, 500); // set size of window
 background(7, 80, 0); // set background color
 frameRate(60); // how often is draw called (60 times per second)
 smooth(); // anti-aliasing, smooths lines
} // end setup

void draw(){
 background(7, 80, 0); // redraw background to remove trace, ghosts
 
 if(mousePressed){ // if the mouse is pressed
   ellipse(mouseX, mouseY, 50, 50); // make a circle follow the mouse
 } // end if
 
  }// end draw

“The computer was born to solve problems that did not exist before.”
– Bill Gates
 



CSE Intro to Processing 2

Today in class we learned more about the basics of processing. One of which is frameRate. frameRate is how often draw is called a second. So, if I were to write frameRate(100) draw would be called 100 times in a second. We learned about smooth() which is an attribute that smooths out the lines so that they won't look so pixelated. But the coolest thing  we learned  today is an input called if(mousePressed). The input if(mousePressed) is the input used when you want the computer do so something every time the mouse is pressed. For example, if you want the computer to create a circle where the mouse if every time the mouse is pressed you would use the code:

if(mousePressed){
   ellipse(mouseX, mouseY, 50, 50);
 }

This code basically says when the mouse is pressed create a circle, where the mouse is hovering that, is 50 coordinates down and 50 coordinates across. I really enjoyed learning how to use the input if(mousePressed) and I can't wait to create my own code using this input. The code we created in class is down below.

void setup() {
 size(500, 500); // set size of window
 background(7, 80, 0); // set background color
 frameRate(60); // how often is draw called (60 times per second)
 smooth(); // anti-aliasing, smooths lines
} // end setup

void draw(){
 background(7, 80, 0); // redraw background to remove trace, ghosts
 
 if(mousePressed){ // if the mouse is pressed
   ellipse(mouseX, mouseY, 50, 50); // make a circle follow the mouse
 } // end if
 
  }// end draw

“The computer was born to solve problems that did not exist before.”
– Bill Gates
 

Wednesday, October 22, 2014

A Portrait

My very first assignment was due a couple of days ago and I must say it was quite fun. The assignment was to create a portrait of someone in our class, I decided to create a portrait based on my best friend Tytianna. All I did was create a  bunch of lines and circles but it took a long time because it was hard to find what coordinates the lines and circles should be at to create a body. I practiced everything we learned previously by not only using lines and circles, but also changing the fills and strokes. The code I created is down below.

                          
size(1000,700);
background(180,18,165);
fill(199,31,222);
stroke(255,255,255);
ellipse(500,400,400,400);
fill(116,63,59);
stroke(2,2,2);
ellipse(500,300,70,85);
stroke(116,63,59);
line(500,500,500,342);
line(500, 500, 450,550);
line(500,500,550,550);
line(500,365,520,410);
line(500,365,480,410);
fill(500,500,500);
ellipse(480,290,15,10);
fill(500,500,500);
ellipse(510,290,15,10);
fill(2,2,2);
ellipse(480,290,3,3);
ellipse(510,290,3,3);
fill(255,255,255);
noStroke();
rect(485,325,30,10,30);
fill(116,63,59);
stroke(2,2,2);
rect(494,305,10,10,30);
fill(110,55,59);
rect(470,200,60,60,180);

“First, solve the problem. Then, write the code.”
-John Johnson

Monday, October 13, 2014

CSE Intro to Processing

A few weeks ago I had my first official class for Computer Science Engineering! Since most the students in this class are beginners most of what we did was learning the very basics of Processing. Like how to set up the size of the window, how to change the background color, how to make basic shapes and how to change the fill and lines of the shapes.  I completely understood what we were being taught and I really enjoyed the class immediately!

                                                           Code taught by Mr.Miles

// set up size of window
size(displayWidth, displayHeight);

// change background color to seafoam
background(127, 255, 127);
       
// rect(30, 20, 100, 55);
rect(600, 30, 400, 400, 0, 5, 10, 20);
rect(420, 120, 200, 200, 100);

rectMode(CORNERS);
rect(30, 20, 100, 500);

rectMode(CENTER);
rect(width / 2, height / 2, 50, 50);

rectMode(CORNER);

fill(255, 0, 0); // change the color of shapes' fill
ellipse(100, 100, 50, 50);
ellipse(width / 3, height / 3, 100, 100);

stroke(0, 0, 255); // change the color of lines
triangle(50, 50, 100, 100, 200, 75);

“Computers are getting smarter all the time.  Scientists tell us that soon they will be able to talk to us.  (And by ‘they’, I mean ‘computers’.  I doubt scientists will ever be able to talk to us.)”
-Dave Barry





Wednesday, October 8, 2014

Welcome to Azaria Burton's Senior Capstone Blog!

My name is Azaria Burton and I currently attend Science Leadership Academy. This year I will be completing my final project called a Capstone. I have recently found a new interest in Computer Science Engineering and decided that it would be fun to do my capstone based on the skills I have learned in my CSE class. My final project will consist of a game created by me and a blog to help me track my progress. I'm very excited to start this new journey of becoming computer literate!




“...if you aren't, at any given time, scandalized by code you wrote five or even three years ago, you're not learning anywhere near enough.”
― Nick Black