7/23/2014

TUGAS SOFTSKILL

TUGAS KELOMPOK SOFTSKILL PROCESSING




disusun oleh:
Andrie Syahriandy (50411824)
Budi Setiawan (57411784)
Faris Zuhair (52411711)

       


          Pada tugas kali ini kami memodifikasi game yang sudah ada di Openprocessing.org . game ini bertemakan tentang katak yang harus melewati rintangan mobil dan menyebrangi kayu yang ada diatas air hingga bisa mencapai tujuannya.

Interface


Dari segi interface game ini memiliki tampilan yang simple. hanya ada objek katak, mobil, kayu, jalanan, air dan daun. objek katak disini dibuat dengan listing program yang mudah, dan nanti akan kami jelaskan di bawah.


Level

Dari segi level, game ini mungkin game yang cukup mudah untuk dimainkan diwaktu senggang. maka kami tidak membuat level-level agar user tidak menjadi adiktif dalam memainkan sebuah game, karena pada hakikatnya game hanya bertujuan untuk menghibur pengguna. maka game ini dibuat simple dan ringan untuk hiburan dan pembelajaran.

How to play?

cara memainkan gamenya sangat mudah yakni dengan cara mengarahkan katak menggunakan cursor pad. Katak diberikan 5 nyawa untuk mencapai tujuan sampai ke ujung dan berdiri diaras daun, setelah itu katak akan kembali ke awal dan mendapat score. apabila katak mengenai mobil atau jatuh dari atas kayu ke dalam air, maka nyawa katak akan berkurang dan score akan berkurang. maka pengguna harus bisa memperhatikan timing saat menggerakkan katak agar mencapai score maksimal.


Listing program

game:
float fxpos; //Declare float variables for frog position
float fypos;
int life = 5; //Decale int variables for life and score count
int score = 0;

Water Water1; //Declare water objects as global variables
Water Water2;
Water Water3;
Water Water4;
Water Water5;
Water Water6;
Water Water7;
Water Water8;
Water Water9;
Water Water10;

Logs Logs1; //Declare log objects as global variables
Logs Logs2;
Logs Logs3;
Logs Logs4;
Logs Logs5;
Logs Logs6;
Logs Logs7;
Logs Logs8;
Logs Logs9;
Logs Logs10;

Car Car1; //Decalre car objects as global variables
Car Car2;
Car Car3;
Car Car4;
Car Car5;
Car Car6;
Car Car7;
Car Car8;

void setup() {
  size(500,600);
  smooth(); //Draw all edges smooth
  textFont(createFont("Helvetica",24)); //Set text font and font size
  
  fxpos = width/2; //The starting position of the frog
  fypos = 580;
  
  Water1 = new Water(color(20,70,255),125,75,-1); //Initialise water objects
  Water2 = new Water(color(20,70,255),375,75,-1); 
  Water3 = new Water(color(20,70,255),125,125,2); 
  Water4 = new Water(color(20,70,255),375,125,2); 
  Water5 = new Water(color(20,70,255),375,175,-2); 
  Water6 = new Water(color(20,70,255),125,175,-2); 
  Water7 = new Water(color(20,70,255),125,225,1); 
  Water8 = new Water(color(20,70,255),375,225,1); 
  Water9 = new Water(color(20,70,255),225,275,-2); 
  Water10 = new Water(color(20,70,255),475,275,-2); 
  
  Logs1 = new Logs(color(170,120,10),0,75,-1); //Initialise log objects
  Logs2 = new Logs(color(170,120,10),0,125,2); 
  Logs3 = new Logs(color(170,120,10),0,175,-2); 
  Logs4 = new Logs(color(170,120,10),250,175,-2); 
  Logs5 = new Logs(color(170,120,10),0,225,1); 
  Logs6 = new Logs(color(170,120,10),100,275,-2); 
  Logs7 = new Logs(color(170,120,10),350,275,-2);
  Logs8 = new Logs(color(170,120,10),210,75,-1);
  Logs9 = new Logs(color(170,120,10),210,125,2);
  Logs10 = new Logs(color(170,120,10),210,225,1);
  
  Car1 = new Car(color(255,0,0),0,375,4); //Initialise car objects
  Car2 = new Car(color(245,125,5),250,375,4); 
  Car3 = new Car(color(0,255,0),500,425,-3); 
  Car4 = new Car(color(95,5,245),250,425,-3); 
  Car5 = new Car(color(0,0,255),0,475,2); 
  Car6 = new Car(color(245,5,235),250,475,2); 
  Car7 = new Car(color(230,250,5),500,525,-2); 
  Car8 = new Car(color(255),250,525,-2); 
}

void draw() {
  background(20,70,255); //Set background colour to blue
  
  noStroke(); //Draw starting point
  fill(100);
  rectMode(CORNERS);
  rect(0,550,500,600);
    
  fill(200); //Draw road
  rect(0,350,500,550);
    
  fill(100); //Draw halfway point
  rect(0,300,500,350);
    
  stroke(25,85,10); //Draw lilypads
  fill(45,175,10);
  ellipse(50,30,45,45);
  ellipse(150,30,45,45);
  ellipse(250,30,45,45);
  ellipse(350,30,45,45);
  ellipse(450,30,45,45);
  
  fill(255);
  text("Lives: " + life,15,585); //Insert text
  text("Score: " + score,375,585); //Insert text
  
  Water1.display(); //Operate water objects by calling display and move methods
  Water1.move();
  Water2.display();
  Water2.move();
  Water3.display();
  Water3.move();
  Water4.display();
  Water4.move();
  Water5.display();
  Water5.move();
  Water6.display();
  Water6.move();
  Water7.display();
  Water7.move();
  Water8.display();
  Water8.move();
  Water9.display();
  Water9.move();
  Water10.display();
  Water10.move();
  
  Logs1.display(); //Operate log objects by calling display and move methods
  Logs1.move();
  Logs2.display();
  Logs2.move();
  Logs3.display();
  Logs3.move();
  Logs4.display();
  Logs4.move();
  Logs5.display();
  Logs5.move();
  Logs6.display();
  Logs6.move();
  Logs7.display();
  Logs7.move();
  Logs8.display();
  Logs8.move();
  Logs9.display();
  Logs9.move();
  Logs10.display();
  Logs10.move();

  ellipseMode(CENTER); //Draw Frog
  stroke(0);
  fill(255);
  ellipse(fxpos-8,fypos-12,10,10); //Left Eye
  ellipse(fxpos+8,fypos-12,10,10); //Right Eye
  fill(0,180,0); 
  ellipse(fxpos-13,fypos+5,8,10); //Left Leg
  ellipse(fxpos+13,fypos+5,8,10); //Right Leg
  ellipse(fxpos,fypos,25,25); //Body
  
  Car1.display(); // Operate car objects by calling display and move methods
  Car1.move();
  Car2.display();
  Car2.move();
  Car3.display();
  Car3.move();
  Car4.display();
  Car4.move();
  Car5.display();
  Car5.move();
  Car6.display();
  Car6.move();
  Car7.display();
  Car7.move();
  Car8.display();
  Car8.move();
  
  if(life == 0) { //If there are 0 lives then reset the score and life count
    fxpos = width/2;
    fypos = 580;
    life = 5;
    score = 0;
  }
  
  if(fxpos > 0 && fxpos < 500 && fypos > 0 && fypos < 50) { //If the position of the frog is at the top of the screen, reset the frog to its starting position
    fxpos = width/2;
    fypos = 580;
    score = score + 100; //If the position of the frog is at the top of the screen, change the score count
  } 
}

void keyPressed() {
  if(key == CODED) {
    if(keyCode == UP) {
      fypos = fypos - 50; //When the up arrow key is pressed the frog will move up
    } else if (keyCode == DOWN) {
      fypos = fypos + 50; //When the down arrow key is pressed the frog will move down
    } else if (keyCode == LEFT) {
      fxpos = fxpos - 50; //When the left arrow key is pressed the frog will move left
    } else if (keyCode == RIGHT) {
      fxpos = fxpos + 50; //When the eight arrow key is pressed the frog will move right
    }
  }
}

cars:
class Car { //Define the "Car" class
  color c; 
  float xpos; //Declare float variables for car position and speed
  float ypos;
  float xspeed; 
  
  Car(color tempC, float tempXpos, float tempYpos, float tempXspeed) { //Constructor
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    xspeed = tempXspeed;
  }
  
  void display() { //Function to display the car object
    noStroke();
    fill(0);
    ellipse(xpos-15,ypos-15,15,10); //Draw wheels of the car object
    ellipse(xpos+15,ypos-15,15,10);
    ellipse(xpos-15,ypos+15,15,10);
    ellipse(xpos+15,ypos+15,15,10);
    rectMode(CENTER); //Draw car object
    stroke(0);
    strokeWeight(2);
    fill(c);
    rect(xpos,ypos,40,30);
  }
  
  void move() { //Function to move the car object
    xpos = xpos + xspeed;
    if (xpos > width) { //If the car object is greater than the width of the sketch window then reset to original position
      xpos = 0;
    } else if (xpos < 0) { //If the car object is less than the width of the sketch window then change x position to 500
      xpos = 500;
    }
    
    if (fxpos > xpos - 20 && fxpos < xpos + 20 && fypos > ypos && fypos < ypos + 15) { //If frog position intersects with car object then reset frog to starting position and change the score and life count
      fxpos = width/2;
      fypos = 580;
      life = life - 1; 
      score = score - 25;
    } 
  }
}

logs:
class Logs { //Define the "Log" class
  color c;
  float xpos; //Declare float variables for log position and speed
  float ypos;
  float xspeed;

  Logs(color tempC, float tempXpos, float tempYpos, float tempXspeed) { //Constructor
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    xspeed = tempXspeed;
  }
  
  void display() { //Function to display Log object
    rectMode(CENTER); //Draw Log object
    stroke(55,25,15);
    strokeWeight(2);
    fill(c);
    rect(xpos,ypos,100,38);
  }
  
  void move() { //Function to move Log object
    xpos = xpos + xspeed;
    if (xpos > width) { //If the log object is greater than the width of the sketch window then reset to original position
      xpos = 0;
    } else if (xpos < 0) { //If the log object is less than the width of the sketch window then change x position to 500
      xpos = 500;
    }
    
    if (fxpos > xpos - 50 && fxpos < xpos + 50 && fypos > ypos && fypos < ypos + 38) { //If frog position is on the log object then frog will move with the log object 
      fxpos = fxpos + xspeed;
    }
  }
}
water:
class Water { //Define "Water" object
  color c;
  float xpos; //Declare float variables for water position and speed
  float ypos;
  float xspeed;
  
  Water(color tempC, float tempXpos, float tempYpos, float tempXspeed) { //Constructor
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    xspeed = tempXspeed;
  }
  
  void display() { //Function to display water object
    rectMode(CENTER); //Draw water object
    noStroke();
    fill(c);
    rect(xpos,ypos,100,38);
  }
  
  void move() { //Function to move water object
    xpos = xpos + xspeed;
    if (xpos > width) { //If the water object is greater than the width of the sketch window then reset to original position
      xpos = 0;
    } else if (xpos < 0) {//If the water object is less than the width of the sketch window then change x position to 500
      xpos = 500;
    }
    
    if (fxpos > xpos - 50 && fxpos < xpos + 50 && fypos > ypos && fypos < ypos + 38) { //If frog position intersects with water object then reset frog to starting position and change the score and life count
      fxpos = width/2;
      fypos = 580;
      life = life - 1;
      score = score - 25;
    }
  }
}

Output Program:
setelah di run


dibawah ini merupakan hasil setelah berhasil menyebrang ke daun: