# Ariel’s 7th Lab

Happy Halloween!
Today, Mario is going to a castle for his Halloween. Press “e” to make Mario move.

Click the mouse, and here goes a pumpkin. It can jump as well.

Mario tends to approach the pumpkin.

But once Mario reaches the castle he will go back to the beginning so he will NEVER get the pumpking~

Here is the code:

Pumpkin pumpkin;
Nangua nangua;

PImage castle;

void setup() {
size(750, 500);
pumpkin= new Pumpkin();
nangua= new Nangua();
}

void draw() {
background(255);
updatecastle();
pumpkin.make();
nangua.make();
}
void mousePressed() {
if (mousePressed) {
pumpkin.jump();
}
}
void keyPressed() {
if (key== ‘e’) {
nangua.jump();
}
}

void updatecastle() {
image(castle, 0, 0,750,550);
}

class Nangua {
PImage NP;
int base=100;
PVector position = new PVector(-100, 350);
PVector velocity=velocity=new PVector(0,2);
boolean J=false;
boolean F=false;

Nangua() {
}
void make() {
if (J) {
position.sub(velocity);
if (position.y<=200) {
J=false;
F=true;
}
} else if (F) {
if (position.y>=200);
{
position.y=400;
F=false;
}
}

if(position.x >350){
position.x = -100;
}

image(NP, position.x, position.y-200, 200, 200);
}

void jump() {
J=true;
velocity=new PVector(0, 2);
}
}

Pumpkin() {
println(“Pumpkin”);
}

void make() {
if ( J == true) {
position.sub(velocity);
if (position.y<= 200) {
J= false;
F= true;
}
} else if (F ==true) {
if (position.y>=height-150) {
position.y=height-150;
F = false;
}
}

image(Pppumpkin, position.x, position.y-100, 200, 200);
}

void jump() {
J=true;
velocity=new PVector(0, 2);
}
}

# Jiayu’s Lab 8 (class; processing)

I borrowed the figures in the Chinese famous novel or cartoon “Monkey King“. The Monkey King can fly with his amazing cloud and Monk Tang and Ba Jie(the pig) are watching on the ground. LOL.

I changed from the code that we see in lab class. I make the figure to move horizontally instead of vertically. However, the coordinates have some problems but luckily it seems alright.

The following is the processing code.

Tab sunwukong

```size(800,800); monkey = new Monkey(); bg = loadImage("sky.png"); bg2 = loadImage("bg3.png");```

``` } void draw() { background(255); updateBG(); monkey.make(); } void keyPressed() { if (key == ' ') { monkey.move(); } } ```

```void updateBG() { image(bg, 0, -200); image(bg2,300,400); } ```
Tab Monkey

```class Monkey { PImage sun; int base = 100;```

``` PVector position = new PVector(base, height-700); PVector velocity = velocity = new PVector(3,0); boolean isLefting = false; boolean isRighting = false; float mag = 0; Monkey() { println("Monkey"); sun = loadImage("sun.png"); } void make() { println(isRighting+" "+isLefting); println(position.x+" "+ width/2); if (isRighting) { position.add(velocity); if (position.x>= 500) { isLefting = true; isRighting = false; } } else if (isLefting) { position.sub(velocity); if (position.x<=100) { position.x = 100; isLefting = false; } } image(sun, position.x, position.y); } void move() { isRighting = true; velocity = new PVector(3,0); } } ```

This is the Monkey King.

Monk Tang and Ba Jie

The sky background.

How it looks like!

# Max + Kevin | The Return of the Arduino

Kept it very simple on this one. Using a potentiometer, we connected the analog pin 14 to our cycle~ patch and we changed the frequency. The scale was there because we need to dictate the parameters of our frequency.

# Saphya and Kiki’s Simple Maxuino HW Assignment

We set up a potentiometer on the breadboard and connected it back to the Arduino through Analog #14. We used GUI and Analog Input to set the potentiometer, then created a simple patch that generates a 1000 frequency cycle whose amplitude/volume can be controlled through the potentiometer.

# Lab 7 James(wt474)

Now our hero can move and call a ball to hit !

Mover mover;
Pario pario;
PImage bg;
int k=1;
void setup() {
size(600, 600);
mover = new Mover();
pario = new Pario();
}

void draw() {
background(255);
updateBG();
if (keyPressed){
if (key == ‘w’) {
pario.jump();
}
if (key == ‘ ‘) {
k=k+1;
}
}
pario.make();
pario.present();
if (k%2==0){
mover.update();
mover.checkEdges();
mover.display();
}
}
void keyPressed(){
}

void updateBG() {
image(bg, 0, 0);
}

class Mover {

PVector location;
PVector velocity;

Mover() {
location = new PVector(0, 0);
velocity = new PVector(5, 5);
}

void update() {
}

void display() {
stroke(0);
strokeWeight(2);
fill(127);
ellipse(location.x, location.y, 48, 48);
}

void checkEdges() {

if (location.x > width) {
location.x = 0;
}
else if (location.x < 0) {
location.x = width;
}

if (location.y > height) {
location.y = 0;
}
else if (location.y < 0) {
location.y = height;
}
}
}

class Pario {
float a=150;
PImage sprite;
int base = 190;
PVector position = new PVector((width/2)-150, height-base);
PVector velocity = velocity = new PVector(0, 2);
boolean isJumping = false;
boolean isFalling = false;
float mag = 0;
Pario() {
println(“Pario”);
}
void make() {

println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
if (isJumping) {
position.sub(velocity);
if (position.y <= height-300) {
isJumping = false;
isFalling = true;
}
} else if (isFalling) {
if (position.y >= height-base) {
position.y = height-base;
isFalling = false;
}
}

if (keyPressed ) {
if (key == ‘d’) {
position.x = position.x+ 5;
if (position.x >605){
position.x = -40;
}
}
else if (key == ‘a’) {
position.x = position.x – 5;
}
}
//rect(position.x, position.y, 20, 20);

}
void jump() {
isJumping = true;
velocity = new PVector(0, 2);
}
void moveright(){
position.x = position.x+ 5;
}
void moveleft(){
position.x = position.x – 5;
}
void present(){
image(sprite, position.x, position.y);
}
void shoot(){
ellipse(position.x+a, position.y+60, 50,50);

}
}

# Happy Halloween!!!

As the halloween is coming, in today’s lab, I made a little game called “happy halloween!!!”. Actually, it is a very simple game. Just by pressing the space button, you can make the ghost jump forward. When it reaches the edge, it will go to the other side automatically. An interesting thing is that when you first start the game, you can not see the ghost. The moment you press the space key, it will show up.

Here is the main function:

Pario pario;
PImage bg;
void setup(){
size(650,650);
pario=new Pario();

}
void draw(){
background(255);
updateBG();
pario.make();
}

void keyPressed(){
if(key== ‘ ‘){
pario.jump();
}
}
void updateBG(){
image(bg,0,0, 650, 650);
}

Here is a class:

class Pario {
PImage sprite;
int base=190;
PVector position = new PVector(650, 650);
PVector velocity=velocity=new PVector(0, 2);
boolean isJumping=false;
boolean isFalling=false;
float mag=0;
boolean faceRight=true;
float rotation=0;
Pario() {
println(“Pario”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
if (isJumping) {
position.sub(velocity);
if (position.y=height-base);
{
position.y=height-base;
isFalling = false;
}
}

if(position.x < 0){
position.x = 600;
}

image(sprite, position.x, position.y-100, 200, 200);
}

void walk(boolean f) {
faceRight=f;
}

void jump() {
isJumping=true;
velocity=new PVector(0, 2);
}
}

Let’s see a small video~
halloween

# Pororo Piece~

Here comes Pororo! The cutest Korean Cartoon character for young babies~ I don’t have authorized Photoshop software installed on my computer,so the transparency is really bad. It has white square with it everywhere it goes, which could be fixed in the long term when I approach PS. And the background comes from Frozen, as you guys could see, pororo is a penguin? hahaha Keyboard pressed, it could jump and finally back.
I found it hard to find a suitable size background for it. Because the character is relatively small compared to the background.

finally it is the code, I just made minimum change to the original one Matt emailed me. Thank you Matt!

Pario pario;
PImage bg;

void setup() {
size(1280, 960);
pario = new Pario();

}

void draw() {
background(255);
updateBG();
pario.make();
}

void keyPressed() {
if(key == ‘ ‘) {
pario.jump();
}
}

void updateBG() {
image(bg, 0, 0);
}

class Pario {
PImage sprite;
int base = 190;
PVector position = new PVector(540, 500);
PVector velocity = velocity = new PVector(0, 2);
boolean isJumping = false;
boolean isFalling = false;
float mag = 0;
boolean faceRight = true;
float rotation = 0;
Pario() {
println(“Pario”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
if (isJumping) {
position.sub(velocity);
if (position.y <= height-300) {
isJumping = false;
isFalling = true;
}
} else if (isFalling) {
if (position.y >= height-base);
{
position.y = height-base;
isFalling = false;
}
}
//rect(position.x, position.y, 20, 20)

if(position.x < 0) {
position.x = 0;
} else if(position.x >600) {
position.x = 600;
}
image(sprite, position.x, position.y, 100, 150);
}

void walk(boolean f) {
faceRight = f;
}

void jump() {
isJumping = true;
velocity = new PVector(0, 2);
}
}

# Friday Lab :^)

Pario pario;
PImage bg;

void setup() {
size(640, 600);
pario = new Pario();

}

void draw() {
background(255);
updateBG();
pario.make();
}

void keyPressed() {
if(key == ‘ ‘) {
pario.jump();
}
}

void updateBG() {
image(bg, 0, 0);
}

class Pario {
PImage sprite;
int base = 190;
PVector position = new PVector((width/2), height-base);
PVector velocity = velocity = new PVector(0, 2);
boolean isJumping = false;
boolean isFalling = false;
float mag = 0;
boolean faceRight = true;
float rotation = 0;
Pario() {
println(“Pario”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
if (isJumping) {
position.sub(velocity);
if (position.y = height-base);
{
position.y = height-base;
isFalling = false;
}
}
//rect(position.x, position.y, 20, 20)

if(position.x 600) {
position.x = 600;
}
image(sprite, position.x, position.y, 100, 150);
}

void walk(boolean f) {
faceRight = f;
}

void jump() {
isJumping = true;
velocity = new PVector(0, 2);
}
}

I really love this PIKA. Especially when it jumps!

# Lab 8: An Army of Zoogs Kate and Lilly

Main Code:

Zoog zoog;
Ball planet;
ArrayList ballList;

void setup (){
size(800, 800, P3D);
smooth();
frameRate(30);
ballList= new ArrayList();
for (int i= 0; i <100; i++) {
planet = new Ball();
}

//zoog = new Zoog();
}

void draw() {
//draw a white background
background (255);

//Set CENTER mode
ellipseMode (CENTER);
rectMode (CENTER);

ambientLight(150, 150, 150);
directionalLight(255, 0, 0, 0, -1, 0);
spotLight(0, 255, 0, 35, 40, 1200, 0, 0, -1, PI/10, 0);
pointLight(0, 0, 255, 35, 40, 36);

for (int i = 0; i < ballList.size (); i++) {
Zoog b = ballList.get(i);
b.drawZoog();
}

//zoog.drawZoog();
}

void mousePressed() {
}

Class (Ball):

class Ball {
PVector myLocation = new PVector (width/2, height/2);
PVector myVelocity = new PVector (0, 0);
PVector myAcceleration;

color myColor =color(floor(random(0,255)));
float mySize =random(10, 50);
float mySpeed = random (10,100);
Ball() {
println(“Ball”);
}
void follow() {
PVector mouse = new PVector(mouseX, mouseY);
PVector myDirection = PVector.sub(mouse, myLocation);
myDirection.normalize();
myDirection.mult(0.5);
myAcceleration = myDirection;
myVelocity.limit(mySpeed);

pushMatrix();
translate(myLocation.x, myLocation.y, 0);
fill(myColor);
sphereDetail(mouseX/ 80);
sphere(mySize);
popMatrix();
}
}

Class (Zoog)

class Zoog {
PVector myLocation = new PVector (random(0, width), random(0, height));

Zoog() {

}

void drawZoog() {
//Draw Zoog’s body
stroke(0);
fill(175);
rect(myLocation.x, myLocation.y, 20, 100);

// Draw Zoog’s Head
stroke(0);
fill(255);
ellipse(myLocation.x, myLocation.y-30, 60, 60);

//Draw Zoog’s eyes
fill(myLocation.x,0,myLocation.y);
ellipse(myLocation.x-19, myLocation.y-30, 16, 32);
ellipse(myLocation.x+19, myLocation.y-30, 16, 32);

// Draw Zoog’s legs
stroke(0);
line(90,150,80,160);
line(110,150,120,160);
}
}