Chris Pro final

for some reason I cant figure out how to upload my code to openprocessing on the updated version of processing so ill just post my code after this. the only thing that will not work is the pictures but you can just place any picture into them to see that it works.

the biggest problem I ran into was the fact that my “random” feature would repeat pictures so there would be a random number of doubles or triples. one more thing I would have liked to figure out was to get my code to reset after it found the first match. for some reason once it found one match it would only look for that exact picture with the same ID. if I was able to fix these two problems I believe that this project would be perfect. it was a lot of difficulty to get right but in the end I think it was a great project that tested my learning in this program

heres my code

int mouseClicks;

//arrays of pictures

PImage [] pics = new PImage[6];

PImage [] pics1 = new PImage[6];

//Place my arrays using my class

Button [] buttons = new Button [6];

Button [] buttons1 = new Button [6];

//add my timer

Timer timer;

void setup() {

for (int i = 0; i < pics.length; i = i +1) {

pics[i] = loadImage(“photo” + i + “.jpg”);

}

for (int i = 0; i < pics1.length; i = i +1) {

pics1[i] = loadImage(“photos” + i + “.jpg”);

}

//window size

size (900, 300);

background (255);

//set up my arrays

for (int i = 0; i < buttons.length; i = i +1) {

int id = int(random(pics.length));

buttons[i] = new Button(pics[id], i*125+25, 25, 100, 100, id);

}

for (int i = 0; i < buttons1.length; i = i +1) {

int id = int(random(pics.length));

buttons1[i] = new Button(pics1[id], i*125+25, 150, 100, 100, id);

}

 

//bring in my timer

timer = new Timer(5000); //5 seconds to find a match

timer.start();

}

void draw() {

if (timer.isFinished()){

background(0);

}

 

for (int i = 0; i < buttons.length; i = i +1) {

buttons[i].display();

}

for (int i = 0; i < buttons1.length; i = i +1) {

buttons1[i].display();

}

}

void mousePressed() {

 

for (int i = 0; i < buttons.length; i++) {

buttons[i].click();

}

for (int i = 0; i < buttons1.length; i++) {

buttons1[i].click();

}

for (int i = 0; i < buttons.length; i++) {

if (buttons[i].on == true) {

for (int j = 0; j < buttons1.length; j++) {

if (buttons1[j].on) {

buttons[i].check(buttons1[j]);

}

}

}

}

}

 

class Button {

// Data Variables

PImage picture;

int x;

int y;

int w;

int h;

boolean on;

int id;

boolean match;

//Initianalize data variables

Button(PImage tempPicture, int tempX, int tempY, int tempW, int tempH, int tempid) {

picture = tempPicture;

x = tempX;

y = tempY;

w = tempW;

h = tempH;

id = tempid;

}

//create functions to use in this class

void display() {

if (on) {

image(picture, x, y, w, h);

}

else {

fill(0);

rect(x, y, w, h);

}

}

void click() {

if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {

on =!on;

println(on);

}

}

void check(Button b) {

if (id == b.id) {

match = true;

println(“match”);

println(“id1: ” + id);

println(“id2: ” + b.id);

}

else{

on = false;

b.on = false;

println (“no match”);

println(“id1: ” + id);

println(“id2: ” + b.id);

}

}

}

 

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;

}

}

}

 

Posted in Uncategorized | Leave a comment

Final project

Line thatLine;
Line2 thatLine2;
Line3 thatLine3;b
Line4 thatLine4;
void setup() {
  background(0);
  size(400, 400);
  smooth();
  thatLine = new Line();
  thatLine2 = new Line2();
  thatLine3 = new Line3();
  thatLine4 = new Line4();
}
void draw() {
  thatLine.display();
  thatLine2.display();
  thatLine3.display();
  thatLine4.display();
  line(150, 180, 180, 180);
  line(200, 180, 230, 180);
  line(100, 210, 130, 210);
  line(150, 210, 180, 210);
  line(200, 210, 230, 210);
  line(250, 210, 280, 210);
  line(150, 240, 180, 240);
  line(200, 240, 230, 240);
}
void keyPressed() {
  if ((key == ‘b’) || (key==’i’) ||(key==’r’) || (key == ‘v’)) {
    fill(0, 225, 0);
    ellipse(50, 50, 80, 80);
    line(50, 50, 80, 80);
  }
  else if ((key == ‘c’) || (key==’j’) || (key==’t’) ||(key==’w’)) {
    stroke(0, 225, 0);
    line(50, 95, 50, 200);
  }
  else if ((key == ‘d’)||(key==’k’)||(key==’u’) || (key==’x’)) {
    stroke(0, 225, 0);
    line(50, 150, 80, 50);
  }
  else if ((key == ‘f’)|| (key==’n’) ||(key==’y’)) {
    stroke(0, 225, 0);
    line(50, 150, 20, 50);
  }
  else if ((key==’g’)|| (key==’o’)) {
    stroke(0, 225, 0);
    line(50, 200, 20, 250);
  }
  else if ((key==’h’)|| (key==’q’)) {
    stroke(0, 225, 0);
    line(50, 200, 80, 250);
  }
  else if (key == ‘p’) {
    textSize(26);
    text(‘p’, 110, 150);
    text(‘p’, 105, 210);
  }
  else if (key == ‘a’) {
    textSize(26);
    text(‘a’, 155, 150);
  }
  else if (key == ‘s’) {
    textSize(26);
    text(‘s’, 210, 150);
    text(‘s’, 260, 150);
  }
  else if (key == ‘m’) {
    textSize(26);
    text(‘m’, 155, 180);
  }
  else if (key==’e’) {
    textSize(26);
    text(‘e’, 205, 180);
  }
  else if (key == ‘l’) {
    textSize(26);
    text(‘l’, 159, 210);
  }
  else if (key==’z’) {
    textSize(26);
    text(‘z’, 205, 210);
    text(‘z’, 255, 210);
  }
  else if (key == ‘:’) {
    textSize(26);
    text(‘:’, 160, 240);
  }
  else if (key== ‘(‘) {
    textSize(26);
    text(‘(‘, 210, 240);
  }
}
class Line {
  color c;
  int xpos;
  int ypos;
  Line() {
    c = color(0, 225, 0);
    xpos = 100;
    ypos = 150;
  }
  void display() {
    stroke(c);
    //smooth();
    line(100, 150, 130, 150);
  }
}
class Line2 {
  color c;
  int xpos;
  int ypos;
  Line2() {
    c = color(0, 225, 0);
    xpos = 150;
    ypos = 150;
  }
  void display() {
    stroke(c);
    line(150, 150, 180, 150);
  }
}
class Line3 {
  color c;
  int xpos;
  int ypos;
  Line3() {
    c = color(0, 225, 0);
    xpos = 200;
    ypos = 150;
  }
  void display() {
    stroke(c);
    line(200, 150, 230, 150);
  }
}
class Line4 {
  color c;
  int xpos;
  int ypos;
  Line4() {
    c = color(0, 225, 0);
    xpos = 250;
    ypos = 150;
  }
  void display() {
    stroke(c);
    line(250, 150, 280, 150);
  }
}
Posted in Uncategorized | Leave a comment

Final

Spot [] spots = new Spot [columns];
Spot [] spots2 = new Spot [columns];
Spot [] spots3 = new Spot [columns];

//———————————–SETUP——————————-

void setup() {
size(505, 288);

images[0]= loadImage (“pic1.jpg”);
images[1]= loadImage (“pic2.jpg”);
images[2]= loadImage (“pic3.jpg”);
images[3]= loadImage (“pic4.jpg”);
images[4]= loadImage (“pic5.jpg”);
images[5]= loadImage (“pic6.jpg”);
images[6]= loadImage (“pic7.jpg”);
images[7]= loadImage (“pic8.jpg”);
images[8]= loadImage (“pic9.jpg”);
images[9]= loadImage (“pic10.jpg”);
images[10]= loadImage (“pic11.jpg”);
images[11]= loadImage (“pic12.jpg”);
images[12]= loadImage (“pic13.jpg”);
images[13]= loadImage (“pic14.jpg”);
images[14]= loadImage (“pic15.jpg”);
images[15]= loadImage (“pic16.jpg”);
images[16]= loadImage (“pic17.jpg”);
images[17]= loadImage (“pic18.jpg”);
images[18]= loadImage (“pic19.jpg”);
images[19]= loadImage (“pic20.jpg”);
images[20]= loadImage (“pic21.jpg”);

for (int i = 0; i < pics.length; i++) {
//randomSeed();
pics [i] = new Picture (images[int(random(images.length/3))], i*width/pics.length, 0);
}
for (int i = 0; i < pics2.length; i++) {
pics2 [i] = new Picture (images[int(random(images.length/3, + (images.length/3*2 )))], i*width/pics.length, 100);
}
for (int i = 0; i < pics3.length; i++) {
pics3 [i] = new Picture (images[int(random(images.length/3*2, images.length))], i*width/pics.length, 200);
}

for(int j = 0; j <spots.length; j++){
spots[j] = new Spot(j*width/spots.length, 0);
}
for(int j = 0; j <spots2.length; j++){
spots2[j] = new Spot(j*width/spots.length, 100);
}
for(int j = 0; j <spots3.length; j++){
spots3[j] = new Spot(j*width/spots.length, 200);
}

}

//———————————-DRAW—————————————

void draw() {
background(255);
/* for(int j = 0; j<spots.length; j++){
spots[j].show();
}
for(int j = 0; j<spots2.length; j++){
spots2[j].show();
}
for(int j = 0; j<spots3.length; j++){
spots3[j].show();
}*/

for (int i = 0; i < pics.length; i++) {
pics[i].display();
pics[i].drag(mouseX, mouseY);
}
for (int i = 0; i < pics2.length; i++) {
pics2[i].display();
pics2[i].drag(mouseX, mouseY);
}
for (int i = 0; i < pics3.length; i++) {
pics3[i].display();
pics3[i].drag(mouseX, mouseY);
}
}

//———————————MOUSE-PRESSED—————————————-

void mousePressed() {
for (int i = 0; i < pics3.length; i++) {
pics3[i].clickedOn();
}
for (int i = 0; i < pics.length; i++) {
pics[i].clickedOn();
pics2[i].clickedOn();
}

}

//———————————MOUSE-RELEASED—————————————

void mouseReleased() {
for (int i = 0; i < pics3.length; i++) {
pics3[i].stopDragging();
}
for (int i = 0; i < pics.length; i++) {
pics[i].stopDragging();
pics2[i].stopDragging();
}

for (int i = 0; i < pics.length; i++) {
for (int j = 0; j < spots.length; j++) {
pics[i].check(spots3[j]);
pics2[i].check(spots2[j]);
pics2[i].check(spots[j]);
}
}

for (int i = 0; i < pics2.length; i++) {
for (int j = 0; j< spots2.length; j++) {
pics[i].check(spots[j]);
pics[i].check(spots2[j]);
pics2[i].check(spots3[j]);
}
}
for (int i = 0; i < pics3.length; i++) {
for (int j = 0; j x && mouseX y && mouseY < y + h) {
on =!on;
dragging = true;
}
}

void check(Spot s) {
if (dist(x,y, s.x, s.y) < 40) {
x = s.x;
y = s.y;
}
}

void stopDragging() {
dragging = false;
}

void drag(int mx, int my) {
if (dragging) {
x = mx + offsetX;
y = my + offsetY;
}
}
}

//————————————-SPOT CLASS—————————————-

class Spot {
int x;
int y;
int w;
int h;

Spot(int tempX,int tempY) {
x = tempX;
y = tempY;
w = 100;
h = 100;
}

void show(){
fill(123);
rect(x, 0, width, height);
rect(x*100+0, 100, width, height);
rect(x, 200, width, height);
}
}

Posted in Uncategorized | Leave a comment

11_1

9_3[]

// 30 Integers
int [ ] integers = new int [0]{
}
// 100 floating point numbers
float [ ] floatPoints = new float [100]

// 56 Zoog Objects
Zoog [ ] zoogs = new Zoog [56]

9-4
1. Valid
2. Valid

5. Valid
6. Valid

9.5

Zoog [ ] zoogs = new Zoog [3]
zoogs [0] = new zoog ( 100, 100, 50, 60,16)
zoog [1] = new zoog (200, 200, 30, 40, 10)
zoog [2] = new zoog (50, 50, 5, 10, 2)

9.6
1. for (int i = 0; i < nums.length; i++){
nums [i] = nums[i] * nums[i];
}

2. for (int i = 0; i <nums.length; i++) {
nums[i] += int (10);
}

3. for (int i = 0; i < nums.length-1; i++) {
nums[i] += nums[i+1];
}

4. int [] nums = {2,4,5,7,6,8,5,2,8,10};
for ( int i = 0; i < nums.length; i++) {
nums [i] += nums.length;
}

Posted in Uncategorized | Tagged , | Leave a comment

Final Blog Post

so i set out to create a puzzle game which was interactive with the mouse.i was able to actually complete my project besides the fact that i couldn’t get the random function to do what i wanted. challenges i came along was actually chopping up the picture to make the pieces, and also making the piece sensitive to a spot when it was near one.

Posted in Uncategorized | 1 Comment

Nafis Sabir Final Project

For my project I set out to create a game based around Robotron, and inspired by the Anime character, Naruto. The story is that Naruto is out for a training session utilizing his special clone jutsu. I wanted to have the main character in the middle of the screen, with clone attackers coming from all directions. The player could shoot stars at the clones to destroy them. If the player got a certain number of clones, they would level up and the image would change to reflect it. In addition the clones would change and take more hits to destroy as the games difficulty increased. If the clones reached the middle you would lose hit points, go back a level, or die.

As it stands now, the game works with only about 20% of the bells and whistles. The player is in the middle, the clones come from four directions. A mouse press in on of the four directions will shoot stars in that direction. I was having trouble with getting the collision function to operate using the arraylist, so the stars only shoot past. The stars will also change direction if the mouse position is moved, which isn’t the desired effect. It probably would have been better to use vectors. I ended up creating a clone class for each display/movement direction and passing them into my arraylist, because of difficulties I was having with getting it to work in a single array. (Crazy, right?) The game over screen comes up when the clones reach the middle. But, because the detector is in the classes instead of the main program, you can still shoot stars. I have a background image that’s commented out because it was crashing in js.

Ultimately, I’d like to complete the game, if only for the sake of seeing my vision fully realized.

Posted in Uncategorized | Leave a comment

10.2

Moons [] array Offullmoon = new Moon [9];

void setup(){
size(700, 700);
for(int i = 0; i < array Of-fullmoon.length; i++){
arrayOffullmoon [i] = new Suns(color (random(0, 225)), int (random(0, width)), int (random(0, height)), int (random(50, 100)), int (random(50, 100)));

}
}

void draw(){

background(208,234,180);

for(int i = 0; i < array of-fullmoon.length; i++) {
array[i].display();
}

}

class Moons {
int w;
int h;
int moonColor;
int xpos;
int ypos;

Moons(color tempColor, int _xpos, int _ypos, int _w, int _h){
w = _w;
h = _h;
moonColor = tempColor;
xpos = _xpos;
ypos = _ypos;
}

void display(){
fill(moonColor);
ellipse(xpos, ypos, w, h);
}

}

Posted in Uncategorized | Leave a comment

11.2

Bus []bus=new Bus[10];
Bus myBus;

boolean trigger= false;
void setup() {
size(780, 500);
for (int i=0;i<bus.length;i++) {
bus[i] = new Bus(color(146, 180, 250), i*10,i*90, 1, 20, 80, 2);

}
}
void draw() {
background(200);
for (int i=0;i<bus.length;i++) {
if(trigger){
bus[i].xpos=bus[i].xpos+bus[i].xspeed;
}
else{
background(125);
stroke(0);
}}
for (int i=0;i<bus.length;i++) {

bus[i].move();
bus[i].display();
bus[i].busreverse();
}
}
void mousePressed(){
for (int i=0;i<bus.length;i++) {
if (bus[i].xpos<mouseX && mouseXwidth){
}
xpos2=xspeed+xpos2;
if(xpos2>width){
}

if(xpos2>width){
}
}
void busreverse(){

if((xposwidth)){
xspeed=xspeed*-2;

}}}

Posted in Uncategorized | Leave a comment

Final Project – Erick Asadobay

For my final project I created an interactive game similar to Lane Splitter, in the main class i wrote the code for the cars and the driver, also i include the collision statements, the sound and the pictures. On the other two classes i did one for the buildings and the other for the street. I had some trouble creating the collisions statements with the boolean on and off, i wish i had created different levels with different velocities but at the end i created the basic of this game and im happy with it but not satisfied, i just want to say thanks because in this class i have learned a lot Thank you Calli. 🙂

Posted in Uncategorized | Leave a comment

Matthew Soto Final project documentation

So for my final my goal was to create a shooting gallery game. The game would include 4 levels. 2 training levels, a military level, and a zombie apocalypse level. So the level that I got one was the first tutorial level. I was able to get the layout of the level the way I wanted it to as well as being able to replace the mouse cursor with my own custom crosshair.One of the difficulties I had was getting the arrays to be lined up neatly rather than random. But I plan to work on this more during the summer. So I plan to do things like display the score, add sounds, have the bullet disappear as you click the mouse, have text, and so much more. I hope to have the whole game done soon. This level was literally only the beginning.

Posted in Uncategorized | Leave a comment