Mario-Code-Day7

//NAME

int imageIndex=10;
int xPosition, c=0, move=900;
boolean faceLeft=true;
int i=0, size=900;

//Declare two arrays of PImage respectively
PImage [] imageA = new PImage[imageIndex];
int [] Ax = new int[imageIndex];
int Ay = 200;

PImage [] imageB = new PImage[imageIndex];
int [] Bx = new int[imageIndex];
int [] By = new int[imageIndex];

 

//Face Right
//INSERT CODE

void setup()
{
size(1000,500);

//Use for loop to load/initialize array of Images
for(i=0; i<10; i++)
{
imageA[i]=loadImage(i+”.png”);
imageB[i]=loadImage(“f”+i+”.png”);
}
Ax[0]=900;
}

void draw()
{

//DRAWS RECTANGLE
background(255);
imageMode(CENTER);

//ADJUSTS SIZE OF IMAGE
//float size = map(0, 0, height, 0.5, 1.5);
//scale(size);
size=200;
//i=0;

println(move);

//if(c==0)
for(i=1; i<10; i++)
{
Ax[i]=Ax[i-1]-30;
Bx[i]=Bx[i-1]+30;
}

////Check running direction and load different array of images
if(faceLeft==true)
{
if(c<10 && c>0)
move=move-30;
else
{
c=0;
Ax[0]=move;
}

image(imageA[c],Ax[c],Ay,size,size+20);
c++;

if(move<0)
faceLeft=false;
}
else if(faceLeft==false)
{
if(c<10 && c>0)
move=move+30;
else
{
c=0;
Bx[0]=move+30;
}

image(imageB[c],Bx[c],Ay,size,size+20);
c++;

if(move>width)
faceLeft=true;
}

delay(100);

}

//Keyboard control
void keyPressed() {
if (key == CODED) {
if (keyCode == LEFT) {
faceLeft=true;
xPosition = xPosition – 30;
}else if(keyCode == RIGHT){
faceLeft=false;
xPosition = xPosition + 30;
}
//println(faceLeft);
}
}

 

Code: Original Pattern

Concept

 

 

 

 

 

 

 

 

 

Processing

Code

PShape s; // The PShape starting pattern
PVector pos;
PVector vel, grav;
float theta = 0;
float angle;

void setup() {
size(800, 800);
background(255,221,200);

//movement and behavior
pos = new PVector(0,0);
vel = new PVector(0,1.5);
grav = new PVector(0,1);
frameRate(100);
// Creating a custom via vertices
s = createShape();
s.beginShape();
s.fill(0, 1);
s.noStroke();
scale(0.01);
s.vertex(170, 284);
s.vertex(335, 278);
s.vertex(328, 260);
s.vertex(453, 163);
s.vertex(453, 324);
s.vertex(475, 314);
s.vertex(574, 440);
s.vertex(410, 440);
s.vertex(420, 455);
s.vertex(287, 550);
s.vertex(291, 391);
s.vertex(270, 403);
s.endShape(CLOSE);
}

void draw() {
//pos.x = scale(
// for(int i=0, i<10, i++){
// i* cos(theta)
// }
// );

//pos.x = 1 * cos(theta);
//pos.y = 2 * sin(theta);

pushMatrix();
translate(width/2, height/2);
scale(0.5);
rotate(radians(angle));
shape(s, pos.x, pos.y);
angle++;
popMatrix();

//pushMatrix();
////translate(width/2, pos.y);
//rotate(radians(angle));
////scale(0);
////shape(s, 0, 0);
//popMatrix();

//theta += .1;
//scale() += 0.1;
}

Day 5 code.MidtermGame: Dance Oracle 手神

 

— processing code —

//variables

PImage image;
float x;
float y;
int w;
int h;

void setup(){
x = 500;
y = 300;
size(1300,800);
w = width/2;
h = height/2;
image = loadImage(“game-01.jpg”);
}

void draw() {
image(image, 0, 0, 1300,800);

if(keyPressed){
if(key == CODED){

if(keyCode == UP){
fill(1,168, 158, 160);
noStroke();
rect(w/8, y/0.6, x, y);
}
} if(keyCode == LEFT){
fill(1,168, 158, 160);
noStroke();
rect(w/8, y/1.5, x, y);

} if(keyCode == RIGHT){
fill(1,168, 158, 160);
rect(w/1.01, y/1.5, x, y);

} if(keyCode == DOWN){
fill(1,168, 158,160);
rect(w/1.01, y/0.6, x, y);

} if(keyCode == CONTROL){
fill(1,168, 158,160);
rect(w/1.01, y/0.6, x, y);

} if(keyCode == CONTROL){
fill(1,168, 158,160);
rect(w/5.5, y/0.6, x, y);

} if(keyCode == SHIFT){
fill(1,168, 158,160);
rect(w/5.5, y/1.5, x*2, y*2);
}
}
}

 

—end processing code —

for separate file on determining stages: GitHub Game Stages Code

Mario-Code-Day3

 

//Day_3_Homework_Program_1
//Mario_Dcunha

 

//int r=243, g=237, b=177;
//int radius=50, x=250, y=250;

//Define Center Points
int x=0, y=0, r=0, g=0, b=0, rLimit, lLimit, tLimit, bLimit, diameter=50, dir=1, xSpeed=5, ySpeed=4, xc=100, yc=250, a=0, d=0, c=0;

void setup()
{
size(1000,400);
smooth();
background(243,237,177);
}

void draw()
{

noStroke();
//Taking a center for concentric circles
pick_center(150,150);

//Drawing the white concentric circles
circle(255,255,255, 160);

//Insert the white cirlce behind
stroke(0); strokeWeight(2);
pick_center(100,230);
circle(255,255,255,60);

noStroke();
pick_center(150,150);

circle(r,g,b, 150);
circle(32,157,29, 90);

if(mousePressed)
{
circle(r++,g++,b–, 90);
}

circle(0,0,0,75);
circle(59,131,119,60);
circle(0,0,0,50);

if(mousePressed && r>200 && b<200)
{
r–; g–; b++;
circle(r,g,b,60);
}
//Draw the final black loop
//pick_center(150,150);
noFill(); stroke(0); strokeWeight(5);
ellipse(150, 150, 165, 165);

x=width/2;
y=height/2;

noStroke();

pick_center(xc,yc);

circle(0,0,0,60);
circle(235,208,118,50);
circle(255,255,255,40);

rLimit = width-(diameter/2);
lLimit = 0+(diameter/2);
tLimit = 0;
bLimit = height;

if(xc>rLimit)
xSpeed = -dir * xSpeed;

xc = xc + xSpeed;

if(xc<lLimit)
xSpeed = -dir * xSpeed;

if(yc>bLimit)
ySpeed = -dir * ySpeed;

yc = yc + ySpeed;

if(yc<tLimit)
ySpeed = -dir * ySpeed;

//Rectangle Thing

pushMatrix(); // Store the current transformation settings.
translate(800,150);
rotate(-PI/4.0);

a=197; d=70; c=42;

if(mousePressed)
{
a=d; d=c; a++; c=a;

}

fill(a,d,c);
rect(0,0,80,80);
fill(c++,d,a);
rect(40,0,40,40);
rect(0,40,40,40);
fill(a,c,d);
rect(40,40,40,40);

strokeWeight(2);
line(0, 0, -80, 40);
line(0, 20, -80, 40);
line(0, 40, -80, 40);
line(0, 60, -80, 40);
line(0, 80, -80, 40);

noStroke();
fill(197,70,42);
triangle(-80, 40, -20, 200, -65, 120);
popMatrix(); // Restore the previous transformation settings.

}

void circle(int r, int g, int b, int diameter)
{
fill(r, g, b);
ellipse(x, y, diameter, diameter);
}

void pick_center(int center_x, int center_y)
{
x = center_x;
y = center_y;
}