processing实现带音效小动物加农炮发射距离比拼小游戏代码

代码语言:html

所属分类:游戏

代码描述:processing实现带音效小动物加农炮发射距离比拼小游戏代码,左右键控制大炮发射角度,空格键发射。还可以选择不同的小动物,看看谁飞的更远。

代码标签: processing 音效 小动物 加农炮 发射 距离 比拼 小游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
* {
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

body {
  background: #367396;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
body canvas {
  box-shadow: 0.2em 0.2em 2em #0008;
  border: none;
  outline: none;
}
</style>

  
  
</head>

<body translate="no">
  <canvas id="canvas"></canvas>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/processing.1.4.8.js"></script>
<audio id="explosive" src="//repo.bfw.wiki/bfwrepo/sound/66d12ba103e33.mp3" preload="auto"></audio>
<audio id="bomb" src="//repo.bfw.wiki/bfwrepo/sound/66d12bc052e2d.mp3" preload="auto"></audio>
<audio id="trampoline" src="//repo.bfw.wiki/bfwrepo/sound/66d12beddd4aa.mp3" preload="auto"></audio>
<audio id="mud" src="//repo.bfw.wiki/bfwrepo/sound/66d12c0b1fae4.mp3" preload="auto"></audio>
<audio id="flytrap" src="//repo.bfw.wiki/bfwrepo/sound/66d12c51e76a0.mp3" preload="auto"></audio>
<audio id="fire" src="//repo.bfw.wiki/bfwrepo/sound/66d12b86d190c.mp3" preload="auto"></audio>
<audio id="ground" src="//repo.bfw.wiki/bfwrepo/sound/66d12b76b704b.mp3" preload="auto"></audio>
  
      <script>


var sketchProc = function(processingInstance) {
  with (processingInstance) {
    size(900, 600); 
    frameRate(60);    
    smooth();

    textFont(createFont("Trebuchet MS"));

    var game;

    var Button = function(args) {
        this.x = args.x;
        this.y = args.y;
        this.w = args.w || 120;
        this.h = args.h || 50;
        this.content = args.content;
        this.func = args.func;
        this.enabled = args.enabled || false;
    };
    Button.prototype = {
        over: function() {
            return (mouseX > this.x && 
                    mouseX < this.x + this.w && 
                    mouseY > this.y && 
                    mouseY < this.y + this.h);
        },
        draw: function() {
            noStroke();

            if(this.enabled && this.over()) {
                game.hover = true;
                fill(69, 66, 69);
            }
            else {
                fill(46, 47, 48);
            }

            //Draw the button
            rect(this.x, this.y, this.w, this.h);

            //Draw the text on the button
            pushStyle();
                textAlign(CENTER, CENTER);
                textSize(18);
                fill(255);
                text(this.content, this.x + this.w / 2, this.y + this.h / 2);
            popStyle();

            //If the mouse was clicked and the mouse was over the button
            if(this.enabled && game.clicked && this.over()) {
                //Run the function
                this.func();
            }
        }
    };

    //Transition object (between scenes)
    var Transition = function() {
        this.h = 0;
        this.vy = 15;
        this.active =  false;
        this.scene = "home";

        this.reset = function() {
            this.h = 0;
            this.vy = 15;
        };
        this.draw = function() {
            if(this.active) {
                pushStyle();
                    fill(64, 57, 59);
                    rect(-20, -20, width + 40, this.h);
                    rect(-20, height-this.h, width + 40, this.h + 20);
                popStyle();
            }
        };
        this.update = function() {
            if(this.active) {
                this.h+= this.vy;

                //if halfway across the screen then change the scene
                if(this.h >= 300) {
                    game.scene = this.scene;
                    this.vy*= -1;
                }
                //else if it's completely off the screen reset it and set to inactive
                else if(this.h < 0) {
                    this.reset();
                    this.active = false;
                }
            }
        };
        this.run = function() {
            this.draw();
            this.update();
        };
    };

    var Block = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        this.vx = args.vx || 0;
        this.vy = args.vy || 0;
    };
    Block.new = function(args) {
        var obj = Object.create(Block.prototype);
        Block.apply(obj, arguments);
        return obj;
    };
    Block.prototype = {
        move: function() {
            this.x += this.vx;
            this.y += this.vy;
        },
        draw: function() {
            pushStyle();
                noStroke();
                fill(194, 91, 81);
                rect(this.x, this.y, this.w, this.h);
            popStyle();
        },
        go: function() {
            this.draw();
            this.move();
        }
    };

    var Trampoline = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        // this.vx = args.vx || 0;
        // this.vy = args.vy || 0;
        this.dead = false;
    };
    Trampoline.new = function(args) {
        var obj = Object.create(Trampoline.prototype);
        Trampoline.apply(obj, arguments);
        return obj;
    };
    Trampoline.prototype = {
        draw: function() {
            pushStyle();
                noStroke();
                fill(194, 91, 81);
                //legs
                //front left
                rect(this.x + this.w * 0.12, this.y + this.h * 0.8, this.w * 0.08, this.h * 0.8);
                //front right
                rect(this.x + this.w * 0.8, this.y + this.h * 0.8, this.w * 0.08, this.h * 0.8);
                //back left
                rect(this.x + this.w * 0.01, this.y + this.h * 0.6, this.w * 0.08, this.h * 0.8);
                //back right
                rect(this.x + this.w * 0.91, this.y + this.h * 0.6, this.w * 0.08, this.h * 0.8);
                //main body
                fill(80, 222, 201);
                ellipse(this.x + this.w * 0.5, this.y + this.h * 0.5, this.w * 1.1, this.h * 1.1);
                fill(79, 82, 82);
                ellipse(this.x + this.w * 0.5, this.y + this.h * 0.40, this.w * 0.90, this.h * 0.55);

                // noFill();
                // stroke(0);
                // rect(this.x, this.y, this.w, this.h);
            popStyle();
        },
        update: function() {
            // this.x += this.vx;
            // this.y += this.vy;
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var Mud = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        this.dead = false;
    };
    Mud.new = function(args) {
        var obj = Object.create(Mud.prototype);
        Mud.apply(obj, arguments);
        return obj;
    };
    Mud.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);

                pushStyle();
                    noStroke();

                    // fill(120, 96, 60);
                    // ellipse(this.w * 1.2, this.h * 1.2, this.w * 0.4, this.h * 0.7);
                    // ellipse(-this.w * 0.3, this.h * 1.3, this.w * 0.4, this.h * 0.6);
                    // ellipse(this.w * 0.2, this.h * 2.0, this.w * 0.4, this.h * 0.6);

                    fill(97, 72, 26);
                    ellipse(this.w * 0.5, this.h * 0.8, this.w * 1.6, this.h * 1.8);

                    fill(120, 106, 44);
                    ellipse(this.w * 0.5, this.h * 0.7, this.w * 1.4, this.h * 1.4);

                    fill(102, 80, 45);
                    ellipse(this.w * 0.5, this.h * 0.7, this.w * 1, this.h * 1);

                    fill(120, 106, 44);
                    ellipse(this.w * 0.4, this.h * 0.6, this.w * 0.4, this.h * 0.5);
                popStyle();
            popMatrix();
        },
        update: function() {
            // this.x += this.vx;
            // this.y += this.vy;
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var Bomb = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        this.dead = false;
    };
    Bomb.new = function(args) {
        var obj = Object.create(Bomb.prototype);
        Bomb.apply(obj, arguments);
        return obj;
    };
    Bomb.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);

                pushStyle();
                    //balloon
                    stroke(50);
                    strokeWeight(1);
                    fill(227, 93, 88);
                    ellipse(0, -this.h * 1.5, this.w, this.h * 1.1);

                    //shadow on balloon
                    pushMatrix();
                        translate(-this.w * 0.25, -this.h * 1.7);

                        rotate(radians(35));
                        noStroke();
                        fill(242, 242, 242, 200);
                        ellipse(0, 0, this.w * 0.2, this.h * 0.3);
                    popMatrix();

                    //string connecting the bomb to the balloon
                    stroke(50);
                    line(0, -this.h, 0, 0);

                    //bomb
                    pushMatrix();
                        rotate(radians(-25));

                        fill(148, 145, 148);
                        beginShape();
                            vertex(-this.w * 0.4, -this.h * 0.2);
                            vertex( this.w * 0.3, -this.h * 0.2);
                            vertex( this.w * 0.4, -this.h * 0.1);
                            vertex( this.w * 0.5, -this.h * 0.2);
                            vertex( this.w * 0.6, -this.h * 0.2);
                            vertex( this.w * 0.6,  this.h * 0.2);
                            vertex( this.w * 0.5,  this.h * 0.2);
                            vertex( this.w * 0.4,  this.h * 0.1);
                            vertex( this.w * 0.3,  this.h * 0.2);
                            vertex(-this.w * 0.4,  this.h * 0.2);
                            bezierVertex(-this.w * 0.55, this.h * 0.1, -this.w * 0.55, -this.h * 0.1, -this.w * 0.4, -this.h * 0.2);
                        endShape();

                        //string around bomb
                        line(this.w * 0.1, -this.h * 0.2, this.w * 0.05, this.h * 0.2);

                        //words on bomb
                        textSize(12);
                        fill(0);
                        text("BOMB", -this.w * 0.34, this.h * 0.09);
                    popMatrix();
                popStyle();
            popMatrix();
        },
        update: function() {
            // this.x += this.vx;
            this.y += game.sin(radians(frameCount * 2)) * 0.4;
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var Explosive = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        this.dead = false;
    };
    Explosive.new = function(args) {
        var obj = Object.create(Explosive.prototype);
        Explosive.apply(obj, arguments);
        return obj;
    };
    Explosive.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);

                pushStyle();
                    //barrel
                    stroke(38, 38, 38);
                    strokeWeight(1);
                    fill(120, 119, 120);
                    beginShape();
                        vertex(0, 0);
                        vertex(this.w * 0.5, 0);
                        vertex(this.w * 0.5, this.h);
                        bezierVertex(this.w * 0.3, this.h * 1.1, this.w * 0.2, this.h * 1.1, 0, this.h);
                    endShape(CLOSE);
                    ellipse(this.w * 0.25, 0, this.w * 0.5, this.h * 0.15);
                    bezier(0, this.h * 0.3, this.w * 0.15, this.h * 0.41, this.w * 0.35, this.h * 0.41, this.w * 0.5, this.h * 0.3);
                    bezier(0, this.h * 0.7, this.w * 0.15, this.h * 0.81, this.w * 0.35, this.h * 0.81, this.w * 0.5, this.h * 0.7);
                    //hole in top of barrel
                    noStroke();
                    fill(41, 40, 41);
                    ellipse(this.w * 0.15, 0, this.w * 0.15, this.h * 0.05);

                    //skull and cross bones on barrel
                    stroke(66, 63, 63);
                    strokeWeight(3);
                    line(this.w * 0.1, this.h * 0.5, this.w * 0.4, this.h * 0.75);
                    line(this.w * 0.1, this.h * 0.75, this.w * 0.4, this.h * 0.5);
                    strokeWeight(1);
                    noStroke();
                    ellipse(this.w * 0.1, this.h * 0.5, 5, 7);
                    ellipse(this.w * 0.4, this.h * 0.75, 5, 7);
                    ellipse(this.w * 0.1, this.h * 0.75, 5, 7);
                    ellipse(this.w * 0.4, this.h * 0.5, 5, 7);
                    ellipse(this.w * 0.25, this.h * 0.3, this.w * 0.3, this.h * 0.3);
                    ellipse(this.w * 0.25, this.h * 0.4, this.w * 0.2, this.h * 0.3);
                    fill(156, 153, 156);
                    ellipse(this.w * 0.2, this.h * 0.3, this.w * 0.06, this.h * 0.10);
                    ellipse(this.w * 0.3, this.h * 0.3, this.w * 0.06, this.h * 0.10);

                    //TNT
                    randomSeed(100);
                    stroke(40);
                    fill(219, 89, 57);
                    for(var i = 0; i < 10; i++) {
                        pushMatrix();
                            rotate(radians(random(-5, 5)));
                            rect(random(this.w * 0.5, this.w * 0.9), random(-this.h * 0.1, this.h * 0.05), this.w * 0.08, this.h * 0.4);
                        popMatrix();
                    }

                    //TNT box
                    stroke(40);
                    fill(200, 140, 115);
                    rect(this.w * 0.5, this.h * 0.3, this.w * 0.5, this.h * 0.7);
                    line(this.w * 0.5, this.h * 0.65, this.w, this.h * 0.65);
                    fill(36, 35, 36);
                    textSize(14);
                    textAlign(CENTER);
                    text("TNT", this.w * 0.75, this.h * 0.6);
                    text("TNT", this.w * 0.75, this.h * 0.95);
                popStyle();
            popMatrix();
        },
        update: function() {
            // this.x += this.vx;
            // this.y += this.vy;
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var FlyTrap = function(args) {
        this.x = args.x  || 0;
        this.y = args.y || 0;
        this.w = args.w || 100;
        this.h = args.h || this.w;
        this.angle = 20;
        this.eat = false;
        this.dead = false;
        this.color = color(108, 158, 27);
    };
    FlyTrap.new = function(args) {
        var obj = Object.create(FlyTrap.prototype);
        FlyTrap.apply(obj, arguments);
        return obj;
    };
    FlyTrap.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);

                pushStyle();

                    //main stem
                    strokeWeight(7);
                    stroke(50);
                    bezier(0, this.h * 0.48, this.w * 0.25, this.h * 0.7, -this.w * 0.25, this.h * 0.8, 0, this.h * 1.1);

                    strokeWeight(5);
                    stroke(108, 158, 27);
                    bezier(0, this.h * 0.48, this.w * 0.25, this.h * 0.7, -this.w * 0.25, this.h * 0.8, 0, this.h * 1.1);

                    //branches
                    fill(108, 158, 27);
                    strokeWeight(3);
                    stroke(50);
                    bezier(0, this.h * 0.7, -this.w * 0.2, this.h * 0.7, -this.w * 0.4, this.h * 0.7, -this.w * 0.5, this.h * 0.9);
                    bezier(0, this.h * 0.8,  this.w * 0.2, this.h * 0.8,  this.w * 0.4, this.h * 0.7,  this.w * 0.5, this.h * 0.95);

                    fill(108, 158, 27);
                    strokeWeight(2);
                    stroke(108, 158, 27);
                    bezier(0, this.h * 0.7, -this.w * 0.2, this.h * 0.7, -this.w * 0.4, this.h * 0.7, -this.w * 0.5, this.h * 0.9);
                    bezier(0, this.h * 0.8,  this.w * 0.2, this.h * 0.8,  this.w * 0.4, this.h * 0.7,  this.w * 0.5, this.h * 0.95);

                    //head
                    stroke(50);
                    strokeWeight(1);
                    fill(108, 158, 27);
                    //left
                    pushMatrix();
                        translate(0, this.h * 0.5);
                        rotate(radians(-this.angle));

                        beginShape();
                            vertex(0, 0);
                            vertex(-this.w * 0.1, -this.h * 0.2);
                            vertex( this.w * 0.1, -this.h * 0.4);
                            vertex(-this.w * 0.1, -this.h * 0.6);
                            vertex( this.w * 0.1, -this.h * 0.8);
                            vertex(0, -this.h);
                            bezierVertex(-this.w * 0.65, -this.h * 0.9, -this.w * 0.65, -this.h * 0.1, 0, 0);
                        endShape();
                    popMatrix();
                    //right
                    pushMatrix();
                        translate(0, this.h * 0.5);
                        rotate(radians(this.angle));

                        beginShape();
                            vertex(0, 0);
                            vertex(-this.w * 0.1, -this.h * 0.2);
                            vertex( this.w * 0.1, -this.h * 0.4);
                            vertex(-this.w * 0.1, -this.h * 0.6);
                            vertex( this.w * 0.1, -this.h * 0.8);
                            vertex(0, -this.h);
                            bezierVertex(this.w * 0.65, -this.h * 0.9, this.w * 0.65, -this.h * 0.1, 0, 0);
                        endShape();
                    popMatrix();

                    //pot
                    strokeWeight(1);
                    stroke(50);
                    fill(219, 165, 57);
                    beginShape();
                        vertex(-this.w * 0.5, this.h * 1.1);
                        vertex( this.w * 0.5, this.h * 1.1);
                        vertex( this.w * 0.4, this.h * 2);
                        vertex(-this.w * 0.4, this.h * 2);
                    endShape(CLOSE);
                    fill(176, 130, 39);
                    beginShape();
                        vertex(-this.w * 0.55, this.h * 1.1);
                        vertex( this.w * 0.55, this.h * 1.1);
                        vertex( this.w * 0.55, this.h * 1.3);
                        vertex(-this.w * 0.55, this.h * 1.3);
                    endShape(CLOSE);
                popStyle();
            popMatrix();
        },
        update: function() {
            if(this.eat) {
                this.angle = lerp(this.angle, 0, 0.08);
            }
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var Player = function(args) {
        this.x = args.x;
        this.y = args.y;
        this.vx = args.vx || 0;
        this.vy = args.vy || 0;
        this.diameter = args.diameter || 100;
        this.scale = this.diameter / 300;
        this.radius = this.diameter / 2;
        this.circumference = 2 * PI * this.radius;
        this.vymax = ~~this.diameter * 0.65;
        this.vxmax = ~~this.diameter * 0.5;
        this.gravity = args.gravity || 0.2;
        this.friction = args.friction || 0;// || 0.02;
        this.angle = args.angle || 0;
        this.rot = args.rot || 0;
        this.color = args.color || color(204, 192, 55);
        this.eaten = false;
        this.type = args.type || "cat";
    };
    Player.new = function(args) {
        var obj = Object.create(Player.prototype);
        Player.apply(obj, arguments);
        return obj;
    };
    Player.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);
                rotate(radians(this.angle));
                scale(this.scale);

                switch(this.type) {
                    case "cat":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.cat, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "dog":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.dog, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "sheep":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.sheep, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "pig":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.pig, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "cow":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.cow, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "mouse":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.mouse, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "rabbit":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.rabbit, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "chicken":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.chicken, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                    case "horse":
                        pushStyle();
                            imageMode(CENTER);
                            image(game.images.horse, 0, 0);
                            imageMode(CORNER);
                        popStyle();
                        break;
                }
            popMatrix();
        },
        update: function() {
            this.vx = constrain(this.vx - this.friction, 0, this.vxmax);
            this.x+= this.vx;
            this.vy = constrain(this.vy + this.gravity, this.vy, this.vymax);
            this.y+= this.vy;

            this.angle+= this.vx / this.circumference * 360 * 0.2;
        },
        go: function() {
            this.draw();
            this.update();
        }
    };

    var Cannon = function(args) {
        this.x = args.x;
        this.y = args.y;
        this.vx = args.vx || 0;
        this.vy = args.vy || 0;
        this.rot = {
            min: 20,
            max: 70
        };
        this.angle = args.angle || this.rot.min;
        this.vel = args.vel || 10;
        this.power = 0;
        this.topSpeed = args.topSpeed || 40;
        this.diameter = args.diameter || 150;
        this.length = args.length || 200;
        this.cos = cos;
        this.sin = sin;
    };
    Cannon.new = function(args) {
        var obj = Object.create(Cannon.prototype);
        Cannon.apply(obj, arguments);
        return obj;
    };
    Cannon.prototype = {
        draw: function() {
            pushMatrix();
                translate(this.x, this.y);
                pushStyle();
                    //base
                    noStroke();
                    fill(48, 46, 47);
                    arc(0, 0, this.diameter, this.diameter, radians(180), radians(360));

                    //barrel
                    pushMatrix();
                        rotate(radians(this.angle));
                        stroke(0);
                        strokeWeight(1);
                        fill(166, 171, 170);
                        rect(-12, -this.length, 24, this.length * 0.5, 5);
                        rect(-14, -this.length * 0.8, 28, this.length * 0.8 * 0.5, 5);
                        rect(-16, -this.length * 0.55, 32, this.length * 0.55 * 0.5, 5);
                    popMatrix();

                    noStroke();
                    fill(71, 69, 71);
                    arc(0, 0, this.diameter * 0.9, this.diameter * 0.9, radians(180), radians(360));

                    textAlign(CENTER);
                    textSize(20);
                    fill(250, 200);
                    text(~~this.vel, 0, -this.diameter * 0.25);

                    fill(147, 150, 147);
                    rect(-this.diameter * 0.25, -this.diameter * 0.15, this.diameter * 0.5, this.diameter * 0.1, 5);
                    fill(map(this.vel, 5, this.topSpeed, 235, 130), map(this.vel, 5, this.topSpeed, 40, 235), map(this.vel, 5, this.topSpeed, 40, 135));
                    rect(-this.diameter * 0.25, -this.diameter * 0.15, map(this.vel, 5, this.topSpeed, 0, this.diameter * 0.5), this.diameter * 0.1, 5);

                popStyle();
            popMatrix();
        },
        // move: function() {
        //     if((game.keys[UP] || game.keys[87])) { //Up arrow or W
        //          this.angle = constrain(this.angle - 2, 0, 90);
        //     }
        //     if(game.keys[DOWN] || game.keys[83]) { //Down arrow or S
        //          this.angle = constrain(this.angle + 1, 0, 90);
        //     }

        //     this.angle = constrain(this.angle + 1, 0, 90);
        // },
        update: function() {
            this.x+= this.vx;
            this.y+= this.vy;

            this.vel = map(this.sin(radians(frameCount * 10)), -1, 1, 5, this.topSpeed);
        },
        go: function() {
            this.draw();
            //this.move();
            this.update();
        }
    };

    //game object
    var Game = function() {
        this.scene = "load";
        this.started = false;
        this.images = undefined;
        this.imageIndex = 0;
        this.loaded = false;
        this.gameOpened = false;
        this.valid = true;
        this.score = 0; 
        this.bestScore = 0; 
        this.highscores = [
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            },
            {
                name: "Could be you",
                score: 0
            }
        ];
        this.addFrequency = {
            min: 500,
            max: 900,
            value: ~~random(500, 900)
        };
        this.cam = {
            x: 0,
            y: 0
        };
        this.shake = 0;
        this.shakedown = 0.1;
        this.gameOver = false;
        this.gameOverTimer = 0;
        this.transition = new Transition();
        this.sound = false;
        this.sounds = {
            explosive: document.getElementById('explosive'),
            bomb: document.getElementById('bomb'),
            trampoline: document.getElementById('trampoline'),
            mud: document.getElementById('mud'),
            flytrap: document.getElementById('flytrap'),
            fire: document.getElementById('fire'),
            ground: document.getElementById('ground')
        };
        this.colors = {
            back: color(133, 130, 133),
            heading: color(212, 205, 212),
            text: color(255)
        };
        this.ground = {
            x: 0,
            y: 550,
            w: 600,
            h: 50
        };
        this.player = Player.new({
            x: 450,
            y: 100,
            vx: 0,
            diameter: 80,
            gravity: 0.2,
            rot: 15,
            trails: []
        });
        this.cannon = Cannon.new({
            x: 450,
            y: 550,
            vel: 10,
            length: 170
        });
        this.avatars = {
            selected: "dog",
            cat: new Button({
                x: 50,
                y: 180,
                w: 90,
                h: 30,
                content: "Cat",
                enabled: true,
                func: function() {
                    game.player.type = "cat";
                }
            }),
            dog: new Button({
                x: 240,
                y: 180,
                w: 90,
                h: 30,
                content: "Dog",
                enabled: true,
                func: function() {
                    game.player.type = "dog";
                }
            }),
            sheep: new Button({
                x: 430,
                y: 180,
                w: 90,
                h: 30,
                content: "Sheep",
                enabled: true,
                func: function() {
                    game.player.type = "sheep";
                }
            }),
            pig: new Button({
                x: 50,
                y: 320,
                w: 90,
                h: 30,
                content: "Pig",
                enabled: true,
                func: function() {
                    game.player.type = "pig";
                }
            }),
            cow: new Button({
                x: 240,
                y: 320,
                w: 90,
                h: 30,
                content: "Cow",
                enabled: true,
                func: function() {
                    game.player.type = "cow";
                }
            }),
            mouse: new Button({
                x: 430,
                y: 320,
                w: 90,
                h: 30,
                content: "Mouse",
                enabled: true,
                func: function() {
                    game.player.type = "mouse";
                }
            }),
            rabbit: new Button({
                x: 50,
                y: 470,
                w: 90,
                h: 30,
                content: "Rabbit",
                enabled: true,
                func: function() {
                    game.player.type = "rabbit";
                }
            }),
            chicken: new Button({
                x: 240,
                y: 470,
                w: 90,
                h: 30,
                content: "Chicken",
                enabled: true,
                func: function() {
                    game.player.type = "chicken";
                }
            }),
            horse: new Button({
                x: 430,
                y: 470,
                w: 90,
                h: 30,
                content: "Horse",
                enabled: true,
                func: function() {
                    game.player.type = "horse";
                }
            })
        };
        this.explosions = [];
        this.trampolines = [];
        this.bombs = [];
        this.explosives = [];
        this.flyTraps = [];
        this.muds = [];
        this.trees = [];
        this.bomb = Bomb.new({
           x: 150,
           y: 300,
           w: 50
        });
        this.explosive = Explosive.new({
            x: 70,
            y: 500,
            w: 70,
            h: 50
        });
        this.trampoline = Trampoline.new({
            x: 220,
            y: 540,
            w: 80,
            h: 15
        });
        this.flytrap = FlyTrap.new({
            x: 600,
            y: 450,
            w: 50
        });
        this.mud = Mud.new({
            x: 720,
            y: 530,
            w: 80,
            h: 15
        });
        this.clicked = false;
        this.hover = false;
        this.keys = [];
        this.gameOverImage = undefined;
        this.buttons = {
            play: new Button({
                x: 700,
                y: 150,
                size: 100,
                content: "Play", 
                enabled: true,
                func: function() {
                    game.reset();
                    game.transition.scene = "play";
                    game.transition.active = true;
                }
            }),
            replay: new Button({
                x: 390,
                y: 280,
                content: "Replay", 
                enabled: true,
                func: function() {
                    game.reset();
                    game.transition.scene = "play";
                    game.transition.active = true;
                }
            }),
            home: new Button({
                x: 390,
                y: 350,
                content: "Home", 
                enabled: true,
                func: function() {
                    game.transition.scene = "home";
                    game.transition.active = true;
                }
            }),
            back: new Button({
                x: 400,
                y: 530,
                content: "Home", 
                enabled: true,
                func: function() {
                    game.transition.scene = "home";
                    game.transition.active = true;
                }
            }),
            playHome: new Button({
                x: 50,
                y: 50,
                content: "Home", 
                enabled: true,
                func: function() {
                    game.transition.scene = "home";
                    game.transition.active = true;
                }
            }),
            playSound: new Button({
                x: 50,
                y: 120,
                size: 80,
                content: "Sound (OFF)",
                enabled: true,
                func: function() {
                    game.sound = !game.sound;
                    this.content = "Sound (" + (game.sound === true ? "ON" : "OFF") + ")";
                }
            }),
            scoreboard: new Button({
                x: 700,
                y: 360,
                size: 80,
                content: "Scoreboard",
                enabled: true,
                func: function() {
                    game.transition.scene = "scoreboard";
                    game.transition.active = true;
                }
            }),
            sound: new Button({
                x: 700,
                y: 220,
                size: 80,
                content: "Sound (OFF)",
                enabled: true,
                func: function() {
                    game.sound = !game.sound;
                    this.content = "Sound (" + (game.sound === true ? "ON" : "OFF") + ")";
                }
            }),
            store: new Button({
                x: 700,
                y: 290,
                size: 80,
                content: "Characters",
                enabled: true,
                func: function() {
                    game.transition.scene = "store";
                    game.transition.active = true;
                }
            })
        };
        this.sin = sin;
        this.cos = cos;
        this.triangles = [];
        this.setup();
    };
    Game.prototype = {
        shakeScreen: function() {
            if(this.shake > 0) {
                this.shake = lerp(this.shake, 0, this.shakedown);
                translate(round(random(-this.shake, this.shake)), round(random(-this.shake, this.shake)));
            }
        },
        cat: function() {
            strokeWeight(1);

            //ears
            stroke(8);
            fill(186, 103, 40);
            beginShape();
                vertex(184, 23);
                bezierVertex(197, 12, 208, 7, 218, 11);
                bezierVertex(226, 22, 221, 34, 210, 46);
            endShape(CLOSE);
            beginShape();
                vertex(121, 23);
                bezierVertex(113, 14, 103, 4, 90, 8);
                bezierVertex(84, 15, 87, 30, 98, 42);
            endShape(CLOSE);

            //tail
            fill(198, 146, 44);
            beginShape();
                vertex(216, 262);
                bezierVertex(232, 262, 243, 268, 250, 274);
                bezierVertex(260, 279, 269, 276, 272, 265);
                bezierVertex(273, 255, 272, 250, 272, 245);
                bezierVertex(280, 241, 286, 247, 286, 264);
                bezierVertex(284, 277, 275, 287, 266, 292);
                bezierVertex(258, 294, 248, 290, 242, 284);
                bezierVertex(236, 277, 228, 274, 220, 273);
                vertex(205, 272);
            endShape(CLOSE);

            //arms
            beginShape();
                vertex(202, 155);
                bezierVertex(214, 148, 237, 142, 257, 142);
                bezierVertex(259, 134, 261, 129, 267, 125);
                bezierVertex(273, 127, 274, 132, 275, 138);
                bezierVertex(281, 137, 288, 138, 291, 142);
                bezierVertex(292, 146, 290, 150, 282, 151);
                bezierVertex(286, 157, 289, 161, 289, 164);
                bezierVertex(286, 166, 278, 164, 272, 159);
                bezierVertex(272, 162, 269, 168, 266, 170);
                bezierVertex(260, 168, 258, 160, 257, 155);
                bezierVertex(242, 152, 224, 156, 210, 166);
            endShape(CLOSE);
            beginShape();
                vertex(94, 158);
                bezierVertex(85, 150, 66, 144, 43, 145);
                bezierVertex(43, 141, 40, 131, 36, 127);
                bezierVertex(30, 129, 28, 136, 28, 141);
                bezierVertex(22, 141, 16, 141, 11, 144);
                bezierVertex(10, 149, 14, 154, 20, 157);
                bezierVertex(18, 160, 15, 162, 14, 167);
                bezierVertex(18, 168, 23, 167, 29, 163);
                bezierVertex(30, 167, 31, 172, 36, 173);
                bezierVertex(41, 168, 43, 162, 46, 156);
                bezierVertex(63, 156, 75, 160, 86, 167);
            endShape(CLOSE);

            //legs
            beginShape();
                vertex(201, 273);
                bezierVertex(205, 287, 208, 303, 204, 321);
                bezierVertex(212, 323, 219, 322, 224, 325);
                bezierVertex(225, 329, 220, 336, 211, 340);
                bezierVertex(203, 339, 196, 335, 192, 333);
                bezierVertex(192, 318, 190, 296, 181, 280);
            endShape(CLOSE);
            beginShape();
                vertex(104, 272);
                bezierVertex(94, 285, 93, 306, 94, 324);
                bezierVertex(87, 325, 80, 325, 76, 331);
                bezierVertex(78, 338, 82, 340, 85, 342);
                bezierVertex(92, 343, 100, 343, 107, 340);
                bezierVertex(108, 317, 112, 295, 120, 280);
            endShape(CLOSE);

            //body
            fill(198, 146, 44);
            beginShape();
                vertex(150, 130);
                bezierVertex(172, 130, 199, 139, 216, 159);
                bezierVertex(234, 184, 233, 226, 226, 250);
                bezierVertex(213, 276, 191, 284, 168, 289);
                bezierVertex(145, 290, 122, 289, 100, 277);
                bezierVertex(74, 257, 64, 233, 65, 206);
                bezierVertex(68, 182, 78, 163, 96, 151);
                bezierVertex(113, 140, 128, 134, 149, 130);
            endShape(CLOSE);

            //head
            beginShape();
                vertex(154, 12);
                bezierVertex(179, 12, 204, 27, 222, 48);
                bezierVertex(234, 71, 229, 94, 217, 115);
                bezierVertex(205, 130, 181, 143, 159, 145);
                bezierVertex(132, 145, 107, 132, 88, 114);
                bezierVertex(77, 95, 77, 72, 90, 48);
                bezierVertex(108, 27, 128, 14, 154, 12);
            endShape(CLOSE);

            //mouth
            bezier(153, 91, 155, 104, 169, 112, 180, 106);
            bezier(152, 92, 147, 106, 133, 111, 123, 104);

            //nose
            fill(186, 103, 40);
            beginShape();
                vertex(154, 73);
                bezierVertex(161, 73, 168, 77, 169, 81);
                bezierVertex(164, 90, 163, 91, 156, 94);
                bezierVertex(152, 93, 144, 89, 141, 84);
                bezierVertex(140, 80, 141, 75, 154, 73);
            endShape(CLOSE);

            //eyes
            fill(240);
            beginShape();
                vertex(171, 47);
                bezierVertex(178, 48, 182, 53, 182, 60);
                bezierVertex(180, 65, 175, 69, 168, 68);
                bezierVertex(162, 64, 162, 59, 162, 55);
                bezierVertex(162, 52, 165, 49, 171, 47);
            endShape(CLOSE);
            beginShape();
                vertex(140, 39);
                bezierVertex(147, 39, 153, 41, 156, 50);
                bezierVertex(155, 58, 152, 64, 146, 67);
                bezierVertex(134, 67, 126, 61, 126, 55);
                bezierVertex(126, 48, 131, 42, 140, 39);
            endShape(CLOSE);

            //eye balls
            fill(8);
            ellipse(143, 56, 10, 10);
            ellipse(173, 58, 7, 7);
            fill(240);
            ellipse(141, 52, 4, 4);
            ellipse(171, 56, 3, 3);

            //stripes on head
            noStroke();
            fill(8);
            beginShape();
                vertex(224, 53);
                bezierVertex(216, 58, 206, 62, 197, 65);
                bezierVertex(209, 68, 220, 68, 229, 65);
                bezierVertex(227, 60, 226, 57, 224, 53);
            endShape(CLOSE);
            beginShape();
                vertex(229, 72);
                bezierVertex(226, 77, 218, 79, 210, 80);
                bezierVertex(216, 84, 222, 85, 229, 85);
                bezierVertex(228, 81, 229, 77, 229, 72);
            endShape(CLOSE);
            beginShape();
                vertex(225, 98);
                bezierVertex(221, 100, 212, 100, 204, 97);
                bezierVertex(208, 101, 213, 105, 220, 110);
                bezierVertex(222, 107, 224, 104, 225, 99);
            endShape(CLOSE);
            beginShape();
                vertex(90, 48);
                bezierVertex(94, 53, 105, 60, 112, 63);
                bezierVertex(106, 65, 93, 65, 86, 59);
                bezierVertex(84, 56, 86, 54, 90, 48);
            endShape(CLOSE);
            beginShape();
                vertex(82, 68);
                bezierVertex(84, 73, 93, 77, 105, 79);
                bezierVertex(96, 81, 87, 81, 80, 81);
                bezierVertex(81, 79, 80, 75, 82, 70);
            endShape(CLOSE);
            beginShape();
                vertex(81, 97);
                bezierVertex(86, 99, 97, 100, 110, 98);
                bezierVertex(103, 103, 96, 106, 85, 110);
                bezierVertex(84, 106, 83, 103, 81, 97);
            endShape(CLOSE);

            //stripes on body
            beginShape();
                vertex(222, 174);
                bezierVertex(213, 182, 201, 186, 189, 189);
                bezierVertex(204, 192, 216, 191, 228, 190);
                bezierVertex(228, 185, 227, 181, 223, 173);
            endShape(CLOSE);
            beginShape();
                vertex(230, 209);
                bezierVertex(219, 211, 208, 211, 194, 209);
                bezierVertex(205, 216, 218, 220, 230, 221);
                bezierVertex(231, 216, 231, 214, 230, 209);
            endShape(CLOSE);
            beginShape();
                vertex(229, 235);
                bezierVertex(221, 238, 210, 238, 193, 237);
                bezierVertex(203, 241, 214, 245, 227, 245);
                bezierVertex(227, 243, 228, 240, 229, 235);
            endShape(CLOSE);
            beginShape();
                vertex(217, 263);
                bezierVertex(208, 266, 197, 266, 181, 265);
                bezierVertex(192, 270, 200, 271, 209, 272);
                bezierVertex(212, 271, 214, 267, 217, 264);
            endShape(CLOSE);
            beginShape();
                vertex(74, 174);
                bezierVertex(83, 180, 92, 184, 107, 189);
                bezierVertex(96, 190, 81, 185, 72, 182);
                bezierVertex(72, 180, 74, 178, 74, 174);
            endShape(CLOSE);
            beginShape();
                vertex(66, 201);
                bezierVertex(75, 205, 88, 210, 107, 213);
                bezierVertex(92, 214, 74, 215, 66, 215);
                bezierVertex(65, 212, 65, 209, 66, 203);
            endShape(CLOSE);
            beginShape();
                vertex(69, 231);
                bezierVertex(78, 233, 94, 236, 109, 234);
                bezierVertex(96, 240, 84, 242, 74, 244);
                bezierVertex(71, 239, 70, 237, 69, 233);
            endShape(CLOSE);
            beginShape();
                vertex(87, 265);
                bezierVertex(99, 268, 118, 269, 130, 265);
                bezierVertex(123, 271, 111, 272, 99, 276);
                bezierVertex(96, 273, 94, 270, 87, 266);
            endShape(CLOSE);
        },
        dog: function() {
            // noFill();
            // stroke(0);
            // rect(0, 0, 300, 300);

            strokeWeight(1);

            //feet
            stroke(8);
            fill(234, 148, 47);
            beginShape();
                vertex(215, 234);
                bezierVertex(227, 249, 237, 264, 241, 275);
                bezierVertex(251, 266, 264, 261, 277, 268);
                bezierVertex(263, 277, 252, 285, 239, 296);
                bezierVertex(231, 276, 220, 256, 204, 244);
            endShape(CLOSE);
            beginShape();
                vertex(99, 237);
                bezierVertex(88, 253, 81, 263, 73, 277);
                bezierVertex(64, 269, 50, 265, 38, 269);
                bezierVertex(47, 277, 63, 286, 75, 296);
                bezierVertex(83, 277, 94, 258, 109, 246);
            endShape(CLOSE);

            //arms
            beginShape();
                vertex(203, 130);
                bezierVertex(220, 124, 249, 125, 265, 132);
                bezierVertex(271, 125, 273, 121, 277, 120);
                bezierVertex(283, 121, 282, 130, 279, 134);
                bezierVertex(285, 137, 292, 138, 296, 141);
                bezierVertex(296, 146, 292, 150, 283, 148);
                bezierVertex(286, 153, 287, 157, 287, 161);
                bezierVertex(284, 163, 276, 159, 270, 152);
                bezierVertex(270, 156, 269, 158, 266, 160);
                bezierVertex(259, 158, 258, 150, 258, 143);
                bezierVertex(243, 136, 226, 135, 210, 142);
            endShape(CLOSE);
            beginShape();
                vertex(84, 123);
                bezierVertex(67, 120, 46, 125, 32, 130);
                bezierVertex(30, 125, 26, 120, 21, 118);
                bezierVertex(16, 119, 14, 125, 17, 134);
                bezierVertex(9, 135, 7, 138, 4, 141);
                bezierVertex(3, 145, 8, 149, 16, 149);
                bezierVertex(13, 151, 11, 154, 12, 159);
                bezierVertex(16, 160, 23, 157, 28, 150);
                bezierVertex(28, 154, 30, 159, 33, 159);
                bezierVertex(40, 157, 41, 150, 38, 141);
                bezierVertex(50, 136, 67, 135, 82, 136);
            endShape(CLOSE);

            //ears
            noStroke();
            fill(0);
            beginShape();
                vertex(152, 31);
                bezierVertex(163, 18, 177, 8, 190, 2);
                bezierVertex(198, 2, 205, 6, 206, 13);
                bezierVertex(203, 18, 199, 21, 189, 22);
                bezierVertex(173, 22, 162, 25, 153, 31);
            endShape(CLOSE);
            beginShape();
                vertex(110, 35);
                bezierVertex(92, 30, 78, 26, 60, 26);
                bezierVertex(44, 31, 36, 40, 32, 52);
                bezierVertex(40, 62, 51, 64, 64, 54);
                bezierVertex(73, 46, 90, 38, 111, 38);
            endShape(CLOSE);

            //body
            stroke(8);
            fill(234, 148, 47);
            beginShape();
                vertex(150, 24);
                bezierVertex(187, 42, 224, 61, 259, 75);
                bezierVertex(256, 101, 236, 111, 205, 118);
                bezierVertex(224, 158, 236, 198, 220, 233);
                bezierVertex(200, 260, 158, 268, 114, 253);
                bezierVertex(78, 236, 69, 178, 76, 135);
                bezierVertex(85, 89, 117, 47, 148, 25);
            endShape(CLOSE);

            //spot on left of body
            noStroke();
            fill(8);
            beginShape();
                vertex(219, 151);
                bezierVertex(228, 177, 230, 200, 225, 218);
                bezierVertex(213, 212, 203, 202, 201, 189);
                bezierVertex(201, 169, 211, 158, 219, 151);
            endShape(CLOSE);

            //spot on right of body
            beginShape();
                vertex(75, 150);
                bezierVertex(71, 189, 81, 224, 100, 242);
                bezierVertex(117, 234, 129, 206, 123, 180);
                bezierVertex(110, 154, 89, 151, 76, 149);
            endShape(CLOSE);

            //other spots
            beginShape();
                vertex(119, 92);
                bezierVertex(126, 94, 133, 98, 134, 106);
                bezierVertex(132, 117, 129, 122, 120, 123);
                bezierVertex(111, 121, 106, 115, 104, 107);
                bezierVertex(105, 98, 110, 94, 118, 92);
            endShape(CLOSE);
            beginShape();
                vertex(166, 151);
                bezierVertex(173, 150, 179, 155, 179, 160);
                bezierVertex(178, 165, 175, 170, 171, 171);
                bezierVertex(166, 171, 164, 167, 162, 163);
                bezierVertex(162, 158, 163, 155, 166, 151);
            endShape(CLOSE);
            beginShape();
                vertex(145, 214);
                bezierVertex(155, 215, 158, 220, 159, 225);
                bezierVertex(158, 231, 156, 234, 146, 236);
                bezierVertex(137, 234, 134, 231, 133, 226);
                bezierVertex(133, 222, 137, 217, 144, 214);
            endShape(CLOSE);

            //eyes
            stroke(8);
            fill(224, 222, 220);
            beginShape();
                vertex(116, 11);
                bezierVertex(126, 12, 134, 21, 135, 33);
                bezierVertex(134, 45, 126, 50, 117, 51);
                bezierVertex(105, 50, 99, 39, 99, 31);
                bezierVertex(99, 22, 104, 13, 115, 11);
            endShape(CLOSE);
            beginShape();
                vertex(146, 12);
                bezierVertex(152, 12, 158, 16, 160, 24);
                bezierVertex(160, 31, 156, 37, 151, 38);
                bezierVertex(145, 40, 138, 35, 136, 28);
                bezierVertex(135, 21, 138, 15, 144, 12);
            endShape(CLOSE);

            //eye balls
            fill(8);
            ellipse(119, 31, 8, 8);
            ellipse(149, 28, 6, 6);

            //nose
            beginShape();
                vertex(258, 61);
                bezierVertex(268, 62, 278, 73, 277, 86);
                bezierVertex(274, 95, 267, 101, 259, 101);
                bezierVertex(242, 98, 238, 90, 237, 81);
                bezierVertex(237, 72, 247, 63, 257, 61);
            endShape(CLOSE);
            fill(224);
            ellipse(264, 71, 5, 5);

            stroke(8);
            noFill();
            //mouth
            bezier(206, 118, 181, 123, 156, 91, 146, 73);
            bezier(149, 69, 147, 70, 144, 73, 141, 77);
            bezier(174, 108, 172, 112, 167, 113, 162, 114);
            bezier(196, 101, 194, 106, 189, 112, 187, 121);
            bezier(203, 108, 200, 112, 198, 117, 196, 122);
        },
        cow: function() {
            strokeWeight(1);

            //horns
            fill(246, 136, 73);
            beginShape();
                vertex(116, 26);
                bezierVertex(118, 17, 122, 10, 126, 6);
                bezierVertex(131, 7, 131, 16, 125, 29);
            endShape(CLOSE);
            beginShape();
                vertex(99, 31);
                bezierVertex(92, 22, 87, 18, 83, 17);
                bezierVertex(79, 21, 86, 30, 93, 38);
            endShape(CLOSE);

            //ears
            fill(8);
            beginShape();
                vertex(133, 37);
                bezierVertex(141, 25, 154, 17, 163, 16);
                bezierVertex(170, 17, 175, 21, 171, 26);
                bezierVertex(163, 31, 155, 34, 141, 42);
            endShape(CLOSE);
            beginShape();
                vertex(86, 52);
                bezierVertex(75, 49, 63, 47, 57, 50);
                bezierVertex(51, 55, 46, 60, 54, 62);
                bezierVertex(62, 63, 76, 58, 85, 57);
            endShape(CLOSE);

            //arms
            fill(228, 218, 219);
            beginShape();
                vertex(173, 157);
                bezierVertex(192, 154, 213, 157, 233, 165);
                bezierVertex(235, 161, 239, 157, 243, 152);
                bezierVertex(249, 152, 252, 157, 249, 167);
                bezierVertex(256, 169, 262, 172, 263, 177);
                bezierVertex(261, 181, 255, 182, 251, 180);
                bezierVertex(253, 185, 253, 191, 252, 194);
                bezierVertex(247, 194, 241, 189, 239, 184);
                bezierVertex(237, 189, 235, 192, 231, 192);
                bezierVertex(227, 189, 227, 183, 227, 176);
                bezierVertex(212, 170, 195, 166, 185, 170);
            endShape(CLOSE);
            beginShape();
                vertex(88, 171);
                bezierVertex(75, 169, 53, 175, 33, 187);
                bezierVertex(27, 183, 24, 180, 19, 178);
                bezierVertex(17, 180, 14, 185, 18, 192);
                bezierVertex(15, 197, 8, 199, 5, 207);
                bezierVertex(9, 212, 14, 212, 18, 210);
                bezierVertex(18, 213, 18, 216, 22, 219);
                bezierVertex(25, 216, 29, 211, 32, 208);
                bezierVertex(34, 213, 38, 215, 42, 213);
                bezierVertex(44, 207, 44, 199, 41, 196);
                bezierVertex(54, 186, 66, 183, 82, 184);
            endShape(CLOSE);

            //legs
            beginShape();
                vertex(213, 281);
                bezierVertex(226, 296, 241, 306, 259, 316);
                vertex(254, 332);
                bezierVertex(232, 323, 214, 310, 199, 297);
            endShape(CLOSE);
            beginShape();
                vertex(93, 295);
                bezierVertex(81, 313, 72, 342, 69, 365);
                vertex(88, 367);
                bezierVertex(92, 339, 99, 317, 109, 303);
            endShape(CLOSE);

            //feet
            fill(8);
            beginShape();
                vertex(251, 311);
                vertex(260, 315);
                vertex(253, 332);
                vertex(244, 328);
            endShape(CLOSE);
            beginShape();
                vertex(71, 356);
                vertex(90, 359);
                vertex(88, 367);
                vertex(70, 365);
            endShape(CLOSE);

            //tail
            noFill();
            beginShape();
                vertex(88, 281);
                bezierVertex(77, 290, 69, 290, 57, 289);
                bezierVertex(45, 285, 33, 283, 23, 287);
            endShape();

            bezier(46, 287, 41, 290, 35, 293, 26, 298);
            bezier(44, 288, 41, 293, 37, 300, 34, 310);
            bezier(45, 285, 47, 290, 46, 297, 45, 304);

            //body
            fill(228, 218, 219);
            beginShape();
                vertex(167, 146);
                bezierVertex(193, 168, 219, 192, 225, 226);
                bezierVertex(228, 260, 215, 288, 190, 303);
                bezierVertex(156, 314, 120, 315, 92, 299);
                bezierVertex(72, 277, 65, 249, 68, 219);
                bezierVertex(72, 193, 81, 172, 91, 151);
            endShape(CLOSE);

            //head
            beginShape();
                vertex(106, 26);
                bezierVertex(121, 25, 135, 33, 157, 49);
                bezierVertex(181, 74, 194, 99, 196, 134);
                bezierVertex(191, 160, 163, 174, 135, 175);
                bezierVertex(106, 173, 79, 161, 70, 139);
                bezierVertex(65, 110, 70, 85, 78, 62);
                bezierVertex(85, 42, 94, 31, 106, 26);
            endShape(CLOSE);

            //face
            fill(245, 139, 151);
            beginShape();
                vertex(69, 128);
                bezierVertex(93, 109, 153, 95, 188, 96);
                bezierVertex(197, 113, 200, 135, 189, 152);
                bezierVertex(171, 170, 152, 177, 131, 175);
                bezierVertex(113, 174, 95, 167, 85, 159);
                bezierVertex(77, 154, 68, 142, 69, 128);
            endShape(CLOSE);

            //spots on body
            fill(8);
            beginShape();
                vertex(179, 184);
                bezierVertex(187, 185, 193, 189, 195, 197);
                bezierVertex(194, 205, 189, 208, 182, 210);
                bezierVertex(174, 211, 170, 205, 168, 200);
                bezierVertex(168, 193, 172, 187, 179, 184);
            endShape(CLOSE);
            beginShape();
                vertex(105, 211);
                bezierVertex(117, 212, 128, 221, 130, 234);
                bezierVertex(132, 250, 126, 267, 110, 270);
                bezierVertex(96, 270, 82, 260, 81, 243);
                bezierVertex(82, 228, 91, 214, 105, 211);
            endShape(CLOSE);
            beginShape();
                vertex(203, 233);
                bezierVertex(212, 234, 220, 240, 222, 248);
                bezierVertex(219, 258, 213, 263, 205, 265);
                bezierVertex(197, 264, 189, 258, 186, 250);
                bezierVertex(188, 241, 194, 236, 203, 233);
            endShape(CLOSE);
            beginShape();
                vertex(153, 288);
                bezierVertex(161, 287, 167, 289, 170, 296);
                bezierVertex(167, 303, 167, 306, 158, 307);
                bezierVertex(151, 308, 143, 306, 142, 301);
                bezierVertex(142, 294, 147, 290, 153, 288);
            endShape(CLOSE);

            //eyes
            fill(240);
            beginShape();
                vertex(108, 44);
                bezierVertex(117, 44, 127, 53, 128, 65);
                bezierVertex(128, 76, 120, 86, 113, 85);
                bezierVertex(98, 85, 92, 76, 91, 67);
                bezierVertex(91, 55, 94, 46, 108, 44);
            endShape(CLOSE);
            beginShape();
                vertex(139, 44);
                bezierVertex(148, 45, 155, 52, 155, 58);
                bezierVertex(154, 65, 150, 72, 142, 73);
                bezierVertex(133, 72, 131, 66, 127, 62);
                bezierVertex(127, 57, 129, 49, 139, 44);
            endShape(CLOSE);

            //eyeballs
            noStroke();
            fill(8);
            ellipse(112, 62, 10, 10);
            ellipse(142, 58, 7, 7);

            //mouth
            noFill();
            stroke(8);
            beginShape();
                vertex(177, 128);
                bezierVertex(164, 140, 147, 154, 123, 153);
                bezierVertex(102, 149, 94, 144, 86, 138);
            endShape();

            bezier(90, 137, 89, 137, 87, 138, 84, 141);
            bezier(173, 124, 176, 124, 178, 126, 180, 131);

            //nostrils
            noStroke();
            fill(8);
            beginShape();
                vertex(143, 105);
                bezierVertex(147, 107, 148, 113, 147, 119);
                bezierVertex(144, 118, 141, 111, 143, 106);
            endShape(CLOSE);
            beginShape();
                vertex(108, 113);
                bezierVertex(112, 114, 114, 120, 114, 124);
                bezierVertex(110, 124, 107, 119, 108, 113);
            endShape(CLOSE);
        },
        pig: function() {
            strokeWeight(1);

            //ears
            stroke(8);
            fill(246, 172, 205);
            beginShape();
                vertex(232, 41);
                bezierVertex(246, 30, 262, 24, 274, 23);
                bezierVertex(283, 25, 288, 33, 283, 47);
                bezierVertex(272, 60, 260, 66, 244, 70);
            endShape(CLOSE);
            beginShape();
                vertex(110, 41);
                bezierVertex(101, 31, 91, 23, 79, 20);
                bezierVertex(69, 19, 63, 26, 64, 38);
                bezierVertex(72, 53, 82, 63, 94, 76);
            endShape(CLOSE);

            //arms
            beginShape();
                vertex(250, 120);
                vertex(324, 90);
                vertex(333, 110);
                vertex(251, 157);
            endShape(CLOSE);
            beginShape();
                vertex(88, 132);
                vertex(18, 95);
                vertex(4, 114);
                vertex(89, 173);
            endShape(CLOSE);

            //hands
            fill(8);
            beginShape();
                vertex(314, 94);
                vertex(324, 90);
                vertex(333, 111);
                vertex(322, 116);
            endShape(CLOSE);
            beginShape();
                vertex(27, 100);
                vertex(18, 95);
                vertex(4, 114);
                vertex(14, 121);
            endShape(CLOSE);

            //legs
            fill(246, 172, 205);
            beginShape();
                vertex(220, 259);
                bezierVertex(239, 273, 254, 297, 262, 324);
                vertex(240, 324);
                bezierVertex(232, 304, 222, 286, 209, 272);
            endShape(CLOSE);
            beginShape();
                vertex(121, 248);
                bezierVertex(102, 265, 89, 289, 81, 314);
                vertex(100, 321);
                bezierVertex(111, 294, 121, 277, 136, 264);
            endShape(CLOSE);

            //feet
            fill(8);
            beginShape();
                vertex(257, 310);
                bezierVertex(260, 314, 260, 317, 262, 324);
                vertex(241, 324);
                bezierVertex(239, 321, 238, 318, 237, 315);
            endShape(CLOSE);
            beginShape();
                vertex(104, 310);
                bezierVertex(104, 313, 102, 316, 100, 321);
                vertex(81, 314);
                bezierVertex(81, 313, 81, 310, 84, 306);
            endShape(CLOSE);

            //tail
            noFill();
            stroke(8);
            beginShape();
                vertex(237, 231);
                bezierVertex(247, 224, 259, 220, 266, 225);
                bezierVertex(271, 232, 269, 241, 263, 243);
                bezierVertex(257, 237, 257, 231, 263, 226);
                bezierVertex(271, 224, 278, 224, 288, 231);
            endShape();

            //body
            fill(246, 172, 205);
            beginShape();
                vertex(171, 5);
                bezierVertex(193, 4, 229, 20, 245, 53);
                bezierVertex(260, 94, 262, 148, 254, 196);
                bezierVertex(245, 236, 221, 280, 192, 288);
                bezierVertex(166, 296, 134, 278, 120, 259);
                bezierVertex(96, 229, 82, 190, 82, 151);
                bezierVertex(78, 117, 82, 78, 96, 52);
                bezierVertex(114, 27, 137, 9, 171, 5);
            endShape(CLOSE);

            //eyes
            fill(240);
            ellipse(154, 54, 50, 50);
            ellipse(213, 58, 35, 35);

            //eyeballs
            fill(8);
            ellipse(154, 52, 10, 10);
            ellipse(208, 62, 9, 9);

            ///snout
            fill(234, 205, 227);
            beginShape();
                vertex(182, 69);
                bezierVertex(196, 70, 214, 72, 221, 83);
                bezierVertex(224, 93, 221, 103, 204, 113);
                bezierVertex(192, 117, 174, 116, 160, 112);
                bezierVertex(148, 105, 143, 94, 147, 82);
                bezierVertex(158, 71, 170, 70, 182, 69);
            endShape(CLOSE);

            //nostrils
            fill(246, 172, 205);
            ellipse(201, 97, 10, 18);
            ellipse(161, 97, 10, 18);

            //mouth
            fill(8);
            beginShape();
                vertex(121, 93);
                bezierVertex(130, 104, 151, 116, 165, 120);
                bezierVertex(150, 126, 137, 135, 121, 137);
                bezierVertex(112, 135, 105, 127, 108, 116);
                bezierVertex(112, 108, 117, 102, 121, 95);
            endShape(CLOSE);

            noFill();
            bezier(129, 91, 123, 94, 115, 96, 106, 95);

            //tounge
            noStroke();
            fill(176, 29, 71);
            beginShape();
                vertex(120, 129);
                bezierVertex(123, 128, 127, 128, 130, 130);
                bezierVertex(131, 134, 127, 136, 122, 136);
                bezierVertex(117, 136, 113, 132, 110, 129);
                bezierVertex(109, 126, 111, 124, 113, 123);
                bezierVertex(116, 124, 117, 125, 120, 128);
            endShape(CLOSE);
        },
        horse: function() {
            strokeWeight(1);

            //hair
            fill(197, 57, 60);
            beginShape();
                vertex(97, 46);
                bezierVertex(101, 38, 106, 32, 116, 27);
                bezierVertex(112, 22, 108, 20, 106, 15);
                bezierVertex(110, 9, 121, 10, 132, 16);
                bezierVertex(136, 12, 139, 9, 144, 7);
                bezierVertex(149, 9, 152, 13, 154, 20);
                bezierVertex(160, 18, 167, 17, 174, 17);
                bezierVertex(176, 23, 174, 28, 166, 33);
                bezierVertex(169, 36, 174, 40, 175, 47);
                bezierVertex(173, 55, 171, 58, 168, 63);
              .........完整代码请登录后点击上方下载按钮下载查看

网友评论0