Ariel’s 7th Lab

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

7.1

 

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

7.2

Mario tends to approach the pumpkin.

 

7.3

 

 

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

7.4

 

Here is the code:

Pumpkin pumpkin;
Nangua nangua;

PImage castle;

void setup() {
size(750, 500);
pumpkin= new Pumpkin();
nangua= new Nangua();
castle=loadImage(“http://ww1.sinaimg.cn/large/44359b6cjw1elud9hnvmmj21kw0zkte1.jpg”);
}

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() {
NP=loadImage(“3.png”);
}
void make() {
velocity.add(-0.2, 0.25, 0);
if (J) {
position.sub(velocity);
if (position.y<=200) {
J=false;
F=true;
}
} else if (F) {
position.add(velocity);
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”);
Pppumpkin = loadImage(“1.png”);
}

void make() {
velocity.add(0, 1, 0);
if ( J == true) {
position.sub(velocity);
if (position.y<= 200) {
J= false;
F= true;
}
} else if (F ==true) {
position.add(velocity);
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);
}
}

 

sun    This is the Monkey King.

bg3 Monk Tang and Ba Jie

sky The sky background.

Screen Shot 2014-10-31 at 5.58.12 PM How it looks like!

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();
bg = loadImage(“pariobg.png”);
}

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() {
location.add(velocity);
}

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”);
sprite = loadImage(“pario.png”);
}
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) {
position.add(velocity);
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!!!

屏幕快照 2014-10-31 下午4.01.49

屏幕快照 2014-10-31 下午4.02.09

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();
bg = loadImage(“bg.jpg”);

}
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”);
sprite=loadImage(“gost.jpg”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
velocity.add(0.5, 0.5, 0);
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~

Pororo-1 pororo Pororo pororo2 pororobgHere 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();
bg = loadImage(“disney.jpg”);

}

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”);
sprite = loadImage(“pororo.jpg”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
velocity.add(0.5, 0.5, 0);
if (isJumping) {
position.sub(velocity);
if (position.y <= height-300) {
isJumping = false;
isFalling = true;
}
} else if (isFalling) {
position.add(velocity);
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();
bg = loadImage(“PIKAPIKA.JPG”);

}

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”);
sprite = loadImage(“PIKAKA.JPG”);
}
void make() {
println(isJumping+” “+isFalling);
println(position.y+” “+height/2);
velocity.add(0.5, 0.5, 0);
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!PIKAKA

PIKAPIKA

Lab 8: An Army of Zoogs Kate and Lilly

Screen Shot 2014-10-31 at 12.07.06 PM

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++) {
ballList.add(new Zoog());
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() {
println(“Take me to your leader!”);
}

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.add(myAcceleration);
myVelocity.limit(mySpeed);
myLocation.add(myVelocity);

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);
}
}