• fullscreen
  • Background.pde
  • Car.pde
  • Frogger.pde
  • Logs.pde
  • Water_Demons.pde
  • Watkins_R_Frogger.pde
  • //I put the background in it's own class to lessen clutter in the draw box.
    
    class BG {
      
    
      
    
      void showBG(){
      rectMode(CORNER);
      smooth();
    
    //Start
     fill(50);
     rect(0,600,700,200);
     
     //Halfway point
     fill(50);
     rect(0,325,700,48);
     
     //Lilypads
      noFill();
     ellipse(80,35,55,55);
     ellipse(215,35,55,55);
     ellipse(350,35,55,55);
     ellipse(485,35,55,55); 
     ellipse(620,35,55,55);
       
      //Lilypad backgrounds
      noStroke();
      fill(18,85,3);
      rect(0,0,52,75);
      rect(106,0,82,75);
      rect(241,0,82,75);
      rect(376,0,82,75);
      rect(511,0,82,75);
      rect(646,0,82,75);   
      rect(0,0,700,5);
      //Road
      stroke(0);
      fill(145);
      rect(0,373,700,226);
      
      //Water
      fill(27,14,232);
      rect(0,60,700,265);
      
      
    
      }
    
      
    
    }
    
    class Car { 
      //Car variables
      float xpos;
      float ypos;
      float xspeed;
      float c = random(0,255);
      float cr;
      Car(float tempXpos, float tempYpos, float tempXspeed) {
        c = random(50,255);
        xpos = tempXpos;
        ypos = tempYpos;
        xspeed = tempXspeed;
      }
    //Shows the car
      void display() {
        rectMode(CORNER);
        cr = 15;
        stroke(0);
        fill(180,c,c);
        rect(xpos,ypos,cr*3,cr*2);
        fill(0);
        ellipse(xpos+9,ypos-3,9,9);
        ellipse(xpos+9,ypos+33,9,9);
        ellipse(xpos+36,ypos-3,9,9);
        ellipse(xpos+36,ypos+33,9,9);
        
      }
    //Moves the car
      void move() {
        xpos = xpos + xspeed;
        if (xpos > width) {
          xpos = 0;
        }
        if (xpos < 0) {
          xpos = 700;
        }
      }
      //Kills the frog if they intersect
      boolean intersect(Frog a) {
        float distance = dist(xpos,ypos,a.x_,a.y_);
        if (distance < cr + a.r -5 ) {
          return true;
        } else {
          return false;
        }
        
      }
      
    
    }
    
    
    class Frog {
      
      int x_,y_,r;
      
    
     Frog(int frogxpos, int frogypos) {
           //Frog Variables  
           
           x_ = frogxpos;
           y_ = frogypos;
    
     }
      
    
        void show() {
             r = 15;
            smooth();
          fill(51,165,27);
          stroke(0);
          strokeWeight(3);
          ellipse(x_,y_,r*2,r*2);//Body
          fill(0);
          ellipse(x_+8,y_-15,8,8); //Eye #1
          ellipse(x_-8,y_-15,8,8); //Eye #2
          
           if (y_ < 50) {
          x_ = 350; 
          y_ = 620;}
        
        }
    
    //Commands to make the Frog move
    
      void Down(){ 
        y_= y_+45;} 
        
      void Up(){ 
        y_= y_-45;} 
        
      void Left(){ 
        x_= x_-45;} 
        
      void Right(){ 
        x_= x_+45;}
        
      
         //When the frog dies.  
      void die(){ 
        x_= 350;
        y_= 620; } 
        
        //When the frog jumps on a log going right
        void rideright() {
          x_ = x_ + 16; }
          
        void rideleft() {
          x_ = x_ - 8; }
         
    }  
    
    void keyPressed(){ 
      if(key==CODED){ 
        if(keyCode==DOWN){ 
        Frogger.Down(); } 
        else if(keyCode==UP){ 
        Frogger.Up();} 
        else if(keyCode==LEFT){ 
        Frogger.Left();} 
        else if(keyCode==RIGHT){ 
        Frogger.Right();} 
      }} 
    
    
        
        
        
    
    //Logs that can help or hinder you
    
    class Log { 
      float xpos;
      float ypos;
      float xspeed;
     float lr; 
      Log(float tempXpos, float tempYpos, float tempXspeed) { 
        xpos = tempXpos;
        ypos = tempYpos;
        xspeed = tempXspeed;
      }
    //Shows the log
      void display() {
        lr = 15;
        stroke(0);
        fill(162,101,8);
        rect(xpos,ypos,lr*3,lr*2);
        fill(0);
    
        
      }
    //Moves the log
      void move() {
        xpos = xpos + xspeed;
        if (xpos > width) {
          xpos = 0;
        }
        if (xpos < 0) {
          xpos = 700;
        }
      }
        boolean ride(Frog a) {
        float distance = dist(xpos+15,ypos+15,a.x_,a.y_);
        if (distance < lr + a.r  ) {
          return true;
        } else {
          return false;
        }
        
      }
    }
    
    //Class for the little water demons that eat Frogs yet for some reason can't climb on lilypads or stop moving in set patterns.
    
    class Demon {
      float xpos, ypos, mr, xspeed;
      
      Demon(float tempXpos, float tempYpos, float tempXspeed) {
        
        xpos = tempXpos;
        ypos = tempYpos;
        xspeed = tempXspeed;
      }
      //Shows the demons
      void display() {
      mr = 7;
      fill (176,17,21);
      ellipse(xpos,ypos,mr*5,mr*3);
      fill(0);
      ellipse(xpos-7,ypos+1, 5,5);
      strokeWeight(3);
      line(xpos-14,ypos+5, xpos -5, ypos -10); 
      }
      //Moves the demons
      void move() {
        xpos = xpos + xspeed;
        if (xpos > width) {
          xpos = 0;
        }
        if (xpos < 0) {
          xpos = 700;
        }
      }
      //These guys eat frogs, so if they run into Frogger he's dinner.
        boolean intersect(Frog a) {
        float distance = dist(xpos,ypos,a.x_,a.y_);
        if (distance < mr + a.r -5 ) {
          return true;
        } else {
          return false;
        }
        
      }
    }
    
    
    //R.M. Watkins
    //Learning Processing
    //NMD102 
    
    
    //Frogger: Watkins Edition
    
    //Controls: Arrow keys control Frogger
    
    /*This version of Frogger is played a little differently than the normal Frogger in the following ways.
    
    -Instead of a score, a player must try to hit the exact center of the lilypad. Since the lilypads aren't refreshed with draw, it's easy to see how many attempts it took by
    the frog imprints left each time a player reaches the end.
    
    -Water doesn't kill you in this game. I could have made invisible "cars" that are design to look like water follow before and after the logs and make it play like normal 
    Frogger, but come on, Frog's can swim. 
    
    -Because water doesn't kill you, I made it more interesting by adding the red little demons. They are the Watkins edition equivalent of Snakes, since I felt that dodging 
    Snakes on the logs was too easy. 
    
    -Logs can help or hinder you. 
    
        -Logs that go to the left Frogger can ride on and use to aim the perfect Lilypad jump, which are almost essential for a perfect game.
        -Logs that go to the right are too fast for Frogger to ride. They only push him, which can be bad when trying to avoid the red demons!.
        -If you avoid all the logs, you can get an automatic perfect lilypad jump. However, dodging both logs and demons is no easy task. 
        
        
        The reason I made these changes is because video games these days are a lot more intense. I believe if a modern-day equivalent of Frogger was made, it would be more
        like this. Constantly moving and having to think on your toes is usually what's required in games these days and old school Frogger is just too slow-paced. */
        
        
        
    void setup() {
      frameRate(20);
      size(700,700);
      //Initialize custom made decorative background
    gamebg = new BG();
      //Initialize actual Processing background. This enables the player to leave a Frog imprint whenever they reach the end. 
    background(32,139,18);
    //Initialize Cars
    car1 = new Car(0,375,-7); 
    car2 = new Car(255,420,6);
    car3 = new Car(200,465,-7); 
    car4 = new Car(350,510,6);
    car5 = new Car(500,555,-6); 
    car6 = new Car(350,375,-7); 
    car7 = new Car(650,420,6);
    car8 = new Car(350,465,-7); 
    car9 = new Car(125,510,6);
    car10 = new Car(75,555, -6); 
    //Initialize logs
    log1 = new Log(75, 65, -4);
    log2 = new Log(475, 65, -4);
    log3 = new Log(350, 110, 6);
    log4 = new Log(650, 110, 6);
    log5 = new Log(350, 155, -4);
    log6 = new Log(650, 155, -4);
    log7 = new Log(350, 200, 6);
    log8 = new Log(500, 200, 6);
    log9 = new Log(350, 245, -4);
    log10 = new Log(200, 245, -4);
    log11 = new Log(0, 290, 6);
    log12 = new Log(255, 290, 6);
    
    //Initialize Demons
    demon1 = new Demon(175, 80, -15);
    demon2 = new Demon(525, 80, -12);
    demon3 = new Demon(425, 125, 11);
    demon4 = new Demon(500, 125, 13);
    demon5 = new Demon(250, 170, -12);
    demon6 = new Demon(550, 170, -15);
    demon7 = new Demon(150, 215, 13);
    demon8 = new Demon(50, 215, 11);
    demon9 = new Demon(475, 260, -17);
    demon10 = new Demon(300, 260, -15);
    demon11 = new Demon(50, 305, 12);
    demon12 = new Demon(370, 305, 13);
    
    //Initialize Frog
    Frogger = new Frog(350,620);
    }
    
    void draw() {
    gamebg.showBG();
    
    //Logs
      log1.move();
      log1.display();
      log2.move();
      log2.display();
      log3.move();
      log3.display();
      log4.move();
      log4.display();
      log5.move();
      log5.display();
      log6.move();
      log6.display();
      log7.move();
      log7.display();
      log8.move();
      log8.display();
      log9.move();
      log9.display();
      log10.move();
      log10.display();
      log1.move();
      log1.display();
      log2.move();
      log2.display();
      log3.move();
      log3.display();
      log4.move();
      log4.display();
      log5.move();
      log5.display();
      log6.move();
      log6.display();
      log7.move();
      log7.display();
      log8.move();
      log8.display();
      log9.move();
      log9.display();
      log10.move();
      log10.display();
      log11.move();
      log11.display();
      log12.move();
      log12.display();
      //Frogger rides logs going left to the left
       if (log1.ride(Frogger)) {
      Frogger.rideleft(); }
      if (log2.ride(Frogger)) {
      Frogger.rideleft();}
    if (log5.ride(Frogger)) {
      Frogger.rideleft();}
    if (log6.ride(Frogger)) {
      Frogger.rideleft();}
    if (log9.ride(Frogger)) {
      Frogger.rideleft();}
    if (log10.ride(Frogger)) {
      Frogger.rideleft();}
      //Frogger rides logs going right to the right
      if (log3.ride(Frogger)) {
      Frogger.rideright(); }
      if (log4.ride(Frogger)) {
      Frogger.rideright();}
    if (log7.ride(Frogger)) {
      Frogger.rideright();}
    if (log8.ride(Frogger)) {
      Frogger.rideright();}
    if (log11.ride(Frogger)) {
      Frogger.rideright();}
    if (log12.ride(Frogger)) {
      Frogger.rideright();}
      //Frog
      Frogger.show();
      
      //Cars
      car1.move();
    car1.display();
    car2.move();
    car2.display();
    car3.move();
    car3.display();
    car4.move();
    car4.display();
    car5.move();
    car5.display();
    car6.move();
    car6.display();
    car7.move();
    car7.display();
    car8.move();
    car8.display();
    car9.move();
    car9.display();
    car10.move();
    car10.display();
    
    //If Frogger gets hit by a car, he dies and is replaced by his clone brother at the start.
    if (car1.intersect(Frogger)) {
        Frogger.die();
    }if (car2.intersect(Frogger)) {
        Frogger.die();
    }if (car3.intersect(Frogger)) {
        Frogger.die();
    }if (car4.intersect(Frogger)) {
        Frogger.die();
    }if (car5.intersect(Frogger)) {
        Frogger.die();
    }if (car6.intersect(Frogger)) {
        Frogger.die();
    }if (car7.intersect(Frogger)) {
        Frogger.die();
    }
    if (car8.intersect(Frogger)) {
        Frogger.die();
    }if (car9.intersect(Frogger)) {
        Frogger.die();
    }if (car10.intersect(Frogger)) {
        Frogger.die();
    }
    
    //Demons
    demon1.move();
    demon1.display();
    demon2.move();
    demon2.display();
    demon3.move();
    demon3.display();
    demon4.move();
    demon4.display();
    demon5.move();
    demon5.display();
    demon6.move();
    demon6.display();
    demon7.move();
    demon7.display();
    demon8.move();
    demon8.display();
    demon9.move();
    demon9.display();
    demon10.move();
    demon10.display();
    demon11.move();
    demon11.display();
    demon12.move();
    demon12.display();
    demon12.move();
    
    //They kill Frogger
    if (demon1.intersect(Frogger)) {
        Frogger.die();
    }if (demon2.intersect(Frogger)) {
        Frogger.die();
    }if (demon3.intersect(Frogger)) {
        Frogger.die();
    }if (demon4.intersect(Frogger)) {
        Frogger.die();
    }if (demon5.intersect(Frogger)) {
        Frogger.die();
    }if (demon6.intersect(Frogger)) {
        Frogger.die();
    }if (demon7.intersect(Frogger)) {
        Frogger.die();
    }
    if (demon8.intersect(Frogger)) {
        Frogger.die();
    }if (demon9.intersect(Frogger)) {
        Frogger.die();
    }if (demon10.intersect(Frogger)) {
        Frogger.die();
    }
    if (demon11.intersect(Frogger)) {
        Frogger.die();
    }if (demon12.intersect(Frogger)) {
        Frogger.die();
    }
    
    }
    
    Frog Frogger;
    BG gamebg;
    Car car1;
    Car car2;
    Car car3;
    Car car4;
    Car car5;
    Car car6;
    Car car7;
    Car car8;
    Car car9;
    Car car10;
    Log log1;
    Log log2;
    Log log3;
    Log log4;
    Log log5;
    Log log6;
    Log log7;
    Log log8;
    Log log9;
    Log log10;
    Log log11;
    Log log12;
    Log log13;
    Log log14;
    
    Demon demon1;
    Demon demon2;
    Demon demon3;
    Demon demon4;
    Demon demon5;
    Demon demon6;
    Demon demon7;
    Demon demon8;
    Demon demon9;
    Demon demon10;
    Demon demon11;
    Demon demon12;
    Demon demon13;
    Demon demon14;
    Demon demon15;
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    R.M. Watkins

    Project Two: Frogger

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    //Frogger: Watkins Edition

    //Controls: Arrow keys control Frogger

    /*This version of Frogger is played a little differently than the normal Frogger in the following ways.

    -Instead of a score, a player must try to hit the exact center of the lilypad. Since the lilypads aren't refreshed with draw, it's easy to see how many attempts it took by
    the frog imprints left each time a player reaches the end.

    -Water doesn't kill you in this game. I could have made invisible "cars" that are design to look like water follow before and after the logs and make it play like normal
    Frogger, but c

    You need to login/register to comment.