Monthly Archives: July 2015

Topical

http://www.buzzfeed.com/perpetua/that-does-sound-yummy-as-a-chip#.acwKLxrEk

Images

Download this folder

  • loadPixels()
  • updatePixels()
  • pixels[]
  •  PImage
    • loadImage()
    • can be local or remote
    • image()
  • tint()
    • opacity, etc.
  • Video
    • Capture class

  • Movie class


  •  

Sam’s Game

So I had some issues implementing the “changeSpeed” aspect, as it wouldn’t changeSpeed continuously for some reason. Other than that, it was fairly simple to make this game. To make the game more fun, I’d like to add some obstacles that pop up every now and then. But, that’ll take me a bit more time to figure out…

 

Bubble Art

For this assignment, I tried to make an art piece in which the bubbles float behind a for-loop grid of black circles but are only visible in the first and third quadrant of the image.  At first I had written the for-loops that created the circle grid under the update function in the class Bubble, which left one errant bubble floating on its own over top of the grid. I named him Spunky (pictured below).

Jul29HW

However, after some help from Scott, I was able to domesticate Spunky and get him back behind the grid by writing the for loops just after void draw.

Update

 

 

Bubble Catcher from Echo

Hi all,

My Bubble Catcher game is based on the example from the book “Learning Processing,” Chapter 10, written by Daniel Shiffman.

BubbleCatcher

Here is the code:

Catcher catcher; // a catcher object
Timer timer; // a timer
Bubble[] bubbles; // an array of bubbles

int totalBubbles = 0;

void setup(){
size(600,600);
smooth();

catcher = new Catcher(40); // catcher’s width 40;
timer = new Timer(500); // a timer that goes off every 0.5 second
bubbles = new Bubble[1000];

timer.start();
}

void draw(){
background(0);
noStroke();
fill(255);
catcher.position(mouseX, mouseY);
catcher.display();

if ( timer.isFinished()){
bubbles[totalBubbles] = new Bubble();
totalBubbles++;
if(totalBubbles >= bubbles.length){
totalBubbles = 0;
}
timer.start();
}

for (int i = 0; i < totalBubbles; i++){
bubbles[i].move();
bubbles[i].display();
if (catcher.intersect(bubbles[i])){
bubbles[i].caught();
}
}
}

class Bubble{

float x,y;
float speed;
float r;
color c;

Bubble(){
r= 8;
x= random(width);
y= -r*2;
speed=random(1,5);
c = color(random(255),random(255),random(255));
}

void move() {
y += speed;
}

boolean reachedBottom() {
if (y > height + r*2){
return true;
}else{
return false;
}
}

void display() {
fill(c);
noStroke();
for (int i =2; i < r; i++){
ellipse (x, y, i*2, i*2);
}
}

void caught(){
speed = 0;
y = -700; // set the location off the screen
}
}

class Catcher{
float h;
float x,y;
color c;

Catcher(float tempH){
h=tempH;
x=0;
y=0;
c=color(255);
}

void position(float tempX, float tempY) {
x = tempX;
y = tempY;
}

void display(){
noStroke();
fill(c);
rect(x, y, h, h);
}

boolean intersect (Bubble d){
float distance = dist (x, y, d.x, d.y);
if (distance < h + d.r){
return true;
} else {
return false;
}
}
}

class Timer{

int savedTime;
int totalTime;

Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}

void start(){
savedTime = millis();
}

boolean isFinished() {
int passedTime = millis()-savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}
}

}

Right now, it is an endless bubble catching game. I tried to code that when the catcher misses the bubble and the bubble hit the ground, the screen will show the game is over, but I haven’t worked out yet:(

Pong

I started with Pong that I got from a site: http://www.123mylist.com/2013/12/basic-pong-game-using-processing.html

I t was pretty great so I practiced for a while. Below is the code for the basic. Once I had my fill, I started changing the different parameters. First I had to understand what the deal was so I added comments and then changed things.

FYI – this is the most addicting thing ever!

int base=40;
int x,y,gameScore=0;
int changeX=-5;
int changeY=-5;
int gameOver=0;
void setup()
{
size(760, 640);
x=(int)random(width);
y=height-base;
}
void draw()
{
if(gameOver==0)
{
background(0);
text(“SCORE:”+gameScore+”00”,width/2,height/2);
rect(mouseX,height-base,200,base);
ellipse(x,y,10,10);
x=x+changeX;
y=y+changeY;
if(x<0 | x>width)
{
changeX=-changeX;
}
if(y<0)
{
changeY=-changeY;
}
if(y>height-base)
{
//check whether it is falling inside the rectangle or not
if(x>mouseX && x<mouseX+200)
{
changeY=-changeY; //bounce back
gameScore++;

}
else
{
gameOverSplash();
}
}
}
else
{
background(100,100,200);
text(“Game Over!”,width/2,height/2);
text(“CLICK TO RESTART”,width/2,height/2+20);
}
}
void gameOverSplash()
{
gameOver=1;
}
void mouseClicked()
{
changeY=-changeY;
gameScore=0;
gameOver=0;

}

lonely pong

Hi all,

I got super frustrated trying to make two player pong, so this is my lonely one player pong :(.

I really struggled with the collision detection (and also trying to make it two player) so I didnt invest enough time into the cool features it should have like score, reset/start (boolean?), and phrases that pop up like ‘you lose!’

I think I need a bit more practice, but here is my lazy lonely pong!

Pong_1Player_2

code:

class

 

 

Digital Stained Glass

Hi All,

I was going for some simple color block art.  I decided on rectangles that took up the entire width of the window. I also want the the blocks to be constantly changing colors and a black flash when any key is pressed. I also brought the frame rate down to make it less seizure inducing.

Here’s a lovely video:

Rectangle Art

Here’s my main code:

Here’s the rectangle class:

moving on up

  • objects
    • class
    • constructor
    • (new tabs!)
  • arrays
    • arrays plus for loops

 

 

code from class

 

 

James Bond Intro in Processing