Project3

Second Test:

GameTest from Shelby Derck on Vimeo.

I created a game based of my dog Buddy’s first food theft of pizza. The goal was to be to get the pizza while creating as little noise as possible but there are still some problems with the sound and jumping, along with the movement of the cats. So the main goal is avoid the cats, get the pizza and runaway from the owner before she catches you. It is still a work in progress.

During the creation so far I have had the dog get stuck on or in a platform, the cats stayed in one place while walking and the owner move right at the beginning. Though I still have some bugs to work out I do have the basic elements installed.

Second Program:

var ground;
var platform, platform1, platform2, platform3;
var Dog, PizzaDog, tag, t = 1;;
var Pizza;
var Cat, Cat1, Cat2, hiss, c;
var Owner, heels;
var amp;
var bg;
var win;

function preload() {
tag = loadSound(“Dog/Tag.m4a”);
hiss = loadSound(“Cat/Hiss.m4a”);
heels = loadSound(“Owner/Heels.m4a”);
}

function setup() {
createCanvas(1300, 800);
stroke(0)
amp = new p5.Amplitude();
var Sound = createDiv(‘SoundRate:’ + amp.getLevel());
Sound.style(‘font-family’, ‘Avenir’);
bg = createSprite(600,550);
bg.addImage(loadImage(“Background.png”));
//Owner
Owner = createSprite(-220, 350);
var myAnimation = Owner.addAnimation(“standing”, “Owner/Owner1.png”, “Owner/Owner1.png”);
Owner.addAnimation(“moving”, “Owner/Owner1.png”, “Owner/Owner4.png”);

//Ground
ground = createSprite(770, 770);
ground.addImage(loadImage(“Platforms/ground.png”));

win = createSprite(600, 400);
win.addImage(loadImage(“Winner.png”));
win.visible = false;
//Platform
platform1 = createSprite(900, 350);
platform1.addImage(loadImage(“Bottom.png”));

platform2 = createSprite(500, 150);
platform2.addImage(loadImage(“Bottom.png”));

platform3 = createSprite(450, 550);
platform3.addImage(loadImage(“Bottom.png”));

//Dog
Dog = createSprite(400, 700);
var myAnimation = Dog.addAnimation(“standing”, “Dog/Dog1.png”, “Dog/Dog1.png”);
Dog.addAnimation(“moving”, “Dog/Dog1.png”, “Dog/Dog4.png”);
Dog.addAnimation(“sleep”, “Dog/Dog6.png”, “Dog/Dog9.png”);
Dog.addAnimation(“jump”, “Dog/Dog5.png”, “Dog/Dog5.png”);
Dog.addAnimation(“crawl”, “Dog/Dog10.png”, “Dog/Dog13.png”);
Dog.addAnimation(“PIZZAstanding”, “Dog/PizzaDog1.png”, “Dog/PizzaDog1.png”);
Dog.addAnimation(“PIZZAmoving”, “Dog/PizzaDog1.png”, “Dog/PizzaDog4.png”);
Dog.addAnimation(“PIZZAjump”, “Dog/PizzaDog5.png”, “Dog/PizzaDog5.png”);
Dog.frameDelay = 1000;
Dog.setCollider(“Dog”, 0, 0, 55);

Pizza = createSprite(100, 95);
var myAnimation = Pizza.addAnimation(‘float’, ‘Pizza/Pizza1.png’, ‘Pizza/Pizza1.png’);

Cat = createSprite(250, 100);
var myAnimation = Cat.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);

Cat.frameDelay = 1000;
Cat.setCollider(“Cat”, 0, 0, 55);

Cat1 = createSprite(1200,280);
var myAnimation = Cat1.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat1.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);

Cat1.frameDelay = 1000;
Cat1.setCollider(“Cat1”, 0, 0, 55);

Cat2 = createSprite(400, 500);
var myAnimation = Cat2.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat2.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);

Cat2.frameDelay = 1000;
Cat2.setCollider(“Cat2”, 0, 0, 55);
}

function draw() {
background(0, 255, 246);
fill(0);
stroke(0);

//Dog Controls
if (keyIsDown(LEFT_ARROW)) {
Dog.changeAnimation(“moving”);
Dog.mirrorX(-1);
Dog.velocity.x = -3;
if (!tag.isPlaying()) {
tag.play();
tag.rate(t);
t += 0.001;
Dog.velocity.y = 9;
}

if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = -3;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
}
if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“crawl”);
Dog.velocity.x = -3;
Dog.velocity.y = 9;
t += 0;
}
} else if (keyIsDown(RIGHT_ARROW)) {
Dog.changeAnimation(“moving”);
Dog.mirrorX(1);
Dog.velocity.x = 3;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
Dog.velocity.y = 9;
}

if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = 3;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
}
if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“crawl”);
Dog.velocity.x = 3;
Dog.velocity.y = 9;

}
} else if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = 0;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
} else if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“sleep”);
Dog.velocity.x = 0;
Dog.velocity.y = 9;
} else {
Dog.changeAnimation(“standing”);
Dog.velocity.x = 0;
t -= 0.001;
Dog.velocity.y = 9;
}

//Collisions
Dog.collide(platform1);
Dog.collide(platform2);
Dog.collide(platform3);
Dog.collide(ground);

Cat.collide(ground);
Cat.collide(platform1);
Cat.collide(platform3);
Cat.collide(platform2);
Cat1.collide(ground);
Cat1.collide(platform1);
Cat1.collide(platform3);
Cat1.collide(platform2);
Cat2.collide(ground);
Cat2.collide(platform1);
Cat2.collide(platform3);
Cat2.collide(platform2);
//Pizza
if (Pizza.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Pizza.position.x = Dog.position.x;
Pizza.position.y = Dog.position.y;
Owner.changeAnimation(“moving”);
Owner.velocity.x = 2;
if (!heels.isPlaying()) {
heels.play();
}
if (Owner.overlapPixel(Dog.position.x, Dog.position.y) === true) {
if (keyIsDown(DOWN_ARROW) === true) {
Owner.mirrorX(-1);
Owner.changeAnimation(“moving”);
Owner.velocity.x = -10;
} else {
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
if (Dog.collide(ground) == false) {
Dog.velocity.y += 3;
}
if (Dog.collide(ground) == true) {
Dog.velocity.y = 0;
}
Owner.changeAnimation(“moving”);
Owner.velocity.x = 0;
}
//Owner
if (Pizza.overlapPixel(Dog.position.x, Dog.position.y) === false) {
Owner.changeAnimation(“standing”);
Owner.velocity.x = 0;
}

}
if (t >= 1) {
Owner.changeAnimation(“moving”);
Owner.velocity.x = 1;
if (!heels.isPlaying()) {
heels.play();
}

}
//cat
if (Cat.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat.changeAnimation(“hiss”);
Cat.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat.changeAnimation(“walking”);
Cat.mirrorX(-1);
Cat.velocity.x = 2;
Cat.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
if (Cat.position.y>100){
Cat.mirrorX(1);
Cat.velocity.x = -2;
}else
if (Cat.position.y>300){
Cat.mirrorX(-1);
Cat.velocity.x = 2;
}
}

if (Cat1.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat1.changeAnimation(“hiss”);
Cat1.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat1.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat1.changeAnimation(“walking”);
Cat1.mirrorX(1);
Cat1.velocity.x = -2;
Cat1.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
if (Cat1.position.y>300){
Cat1.mirrorX(-1);
Cat1.velocity.x = 2;
}else
if (Cat1.position.y>500){
Cat1.mirrorX(1);
Cat1.velocity.x = -2;
}
}
if (Cat2.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat2.changeAnimation(“hiss”);
Cat2.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat2.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat2.changeAnimation(“walking”);
Cat2.mirrorX(-1);
Cat2.velocity.x = 2;
Cat2.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
if (Cat2.position.y>500){
Cat2.mirrorX(1);
Cat2.velocity.x = -2;
}
}
if(Pizza.position.x > 1200){
win.visible = true;
if (mousePressed=true){
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
win.visible = false;
}
}
drawSprite(bg);
drawSprite(ground);
drawSprite(Owner);
drawSprites(platform,platform1,platform2,platform3);
drawSprite(Pizza);
drawSprite(Dog);
}

First Test:

Game3 from Shelby Derck on Vimeo.
First program:

var ground;
var platform, platform1, platform2, platform3;
var Dog, PizzaDog, tag, t = 1;;
var Pizza;
var Cat, Cat1, Cat2, hiss, c;
var Owner, heels;
var amp;

function preload() {
tag = loadSound(“Dog/Tag.m4a”);
hiss = loadSound(“Cat/Hiss.m4a”);
heels = loadSound(“Owner/Heels.m4a”);
}

function setup() {
createCanvas(1300, 800);
stroke(0)
amp = new p5.Amplitude();
var Sound = createDiv(‘SoundRate:’ + amp.getLevel());
Sound.style(‘font-family’, ‘Avenir’);

//Owner
Owner = createSprite(-220, 350);
var myAnimation = Owner.addAnimation(“standing”, “Owner/Owner1.png”, “Owner/Owner1.png”);
Owner.addAnimation(“moving”, “Owner/Owner1.png”, “Owner/Owner4.png”);

//Ground
ground = createSprite(770, 770);
ground.addImage(loadImage(“Platforms/ground.png”));
ground.debug = true;

//Platform
platform1 = createSprite(900, 350);
platform1.addImage(loadImage(“Platforms/platformW.png”));
platform1.debug = true;
platform2 = createSprite(580, 150);
platform2.addImage(loadImage(“Platforms/platformW.png”));
platform2.debug = true;
platform3 = createSprite(450, 550);
platform3.addImage(loadImage(“Platforms/platformW.png”));
platform3.debug = true;
//Dog
Dog = createSprite(400, 700);
var myAnimation = Dog.addAnimation(“standing”, “Dog/Dog1.png”, “Dog/Dog1.png”);
Dog.addAnimation(“moving”, “Dog/Dog1.png”, “Dog/Dog4.png”);
Dog.addAnimation(“sleep”, “Dog/Dog6.png”, “Dog/Dog9.png”);
Dog.addAnimation(“jump”, “Dog/Dog5.png”, “Dog/Dog5.png”);
Dog.addAnimation(“crawl”, “Dog/Dog10.png”, “Dog/Dog13.png”);
Dog.addAnimation(“PIZZAstanding”, “Dog/PizzaDog1.png”, “Dog/PizzaDog1.png”);
Dog.addAnimation(“PIZZAmoving”, “Dog/PizzaDog1.png”, “Dog/PizzaDog4.png”);
Dog.addAnimation(“PIZZAjump”, “Dog/PizzaDog5.png”, “Dog/PizzaDog5.png”);
Dog.debug = true;
Dog.frameDelay = 1000;
Dog.setCollider(“Dog”, 0, 0, 55);

Pizza = createSprite(100, 95);
var myAnimation = Pizza.addAnimation(‘float’, ‘Pizza/Pizza1.png’, ‘Pizza/Pizza1.png’);

Cat = createSprite(250, 100);
var myAnimation = Cat.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);
Cat.debug = true;
Cat.frameDelay = 1000;
Cat.setCollider(“Cat”, 0, 0, 55);

Cat1 = createSprite(1200,280);
var myAnimation = Cat1.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat1.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);
Cat1.debug = true;
Cat1.frameDelay = 1000;
Cat1.setCollider(“Cat1”, 0, 0, 55);

Cat2 = createSprite(400, 500);
var myAnimation = Cat2.addAnimation(“walking”, “Cat/Cat1.png”, “Cat/Cat2.png”, “Cat/Cat3.png”, “Cat/Cat4.png”);
Cat2.addAnimation(“hiss”, “Cat/Cat5.png”, “Cat/Cat5.png”);
Cat2.debug = true;
Cat2.frameDelay = 1000;
Cat2.setCollider(“Cat2”, 0, 0, 55);
}

function draw() {
background(0, 255, 246);
fill(0);
stroke(0);

//Dog Controls
if (keyIsDown(LEFT_ARROW)) {
Dog.changeAnimation(“moving”);
Dog.mirrorX(-1);
Dog.velocity.x = -2;
if (!tag.isPlaying()) {
tag.play();
tag.rate(t);
t += 0.001;
Dog.velocity.y = 9;
}

if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = -1;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
}
if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“crawl”);
Dog.velocity.x = -1;
Dog.velocity.y = 9;
t += 0;
}
} else if (keyIsDown(RIGHT_ARROW)) {
Dog.changeAnimation(“moving”);
Dog.mirrorX(1);
Dog.velocity.x = 2;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
Dog.velocity.y = 9;
}

if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = 1;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
}
if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“crawl”);
Dog.velocity.x = 1;
Dog.velocity.y = 9;

}
} else if (keyIsDown(UP_ARROW)) {
Dog.changeAnimation(“jump”);
Dog.velocity.x = 0;
Dog.velocity.y = -8;
if (!tag.isPlaying()) {
tag.play();
t += 0.001;
}
} else if (keyIsDown(DOWN_ARROW)) {
Dog.changeAnimation(“sleep”);
Dog.velocity.x = 0;
Dog.velocity.y = 9;
} else {
Dog.changeAnimation(“standing”);
Dog.velocity.x = 0;
t -= 0.001;
Dog.velocity.y = 9;
}

//Collisions
Dog.collide(platform1);
Dog.collide(platform2);
Dog.collide(platform3);
Dog.collide(ground);

Cat.collide(ground);
Cat.collide(platform1);
Cat.collide(platform3);
Cat.collide(platform2);
Cat1.collide(ground);
Cat1.collide(platform1);
Cat1.collide(platform3);
Cat1.collide(platform2);
Cat2.collide(ground);
Cat2.collide(platform1);
Cat2.collide(platform3);
Cat2.collide(platform2);
//Pizza
if (Pizza.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Pizza.position.x = Dog.position.x;
Pizza.position.y = Dog.position.y;
Owner.changeAnimation(“moving”);
Owner.velocity.x = 2;
if (!heels.isPlaying()) {
heels.play();
}
if (Owner.overlapPixel(Dog.position.x, Dog.position.y) === true) {
if (keyIsDown(DOWN_ARROW) === true) {
Owner.mirrorX(-1);
Owner.changeAnimation(“moving”);
Owner.velocity.x = -10;
} else {
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
if (Dog.collide(ground) == false) {
Dog.velocity.y += 3;
}
if (Dog.collide(ground) == true) {
Dog.velocity.y = 0;
}
Owner.changeAnimation(“moving”);
Owner.velocity.x = 0;
}
//Owner
if (Pizza.overlapPixel(Dog.position.x, Dog.position.y) === false) {
Owner.changeAnimation(“standing”);
Owner.velocity.x = 0;
}

}
if (t >= 1) {
Owner.changeAnimation(“moving”);
Owner.velocity.x = 1;
if (!heels.isPlaying()) {
heels.play();
}

}
//cat
if (Cat.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat.changeAnimation(“hiss”);
Cat.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat.changeAnimation(“walking”);
Cat.mirrorX(-1);
Cat.velocity.x = 1;
Cat.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
}

if (Cat1.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat1.changeAnimation(“hiss”);
Cat1.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat1.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat1.changeAnimation(“walking”);
Cat1.mirrorX(1);
Cat1.velocity.x = -1;
Cat1.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
}
if (Cat2.overlapPixel(Dog.position.x, Dog.position.y) == true) {
Cat2.changeAnimation(“hiss”);
Cat2.velocity.x = 0;
if (!hiss.isPlaying()) {
hiss.play();
t += 0.01;
Dog.position.x = 400;
Dog.position.y = 700;
Owner.position.x = -220;
Owner.position.y = 350;
Pizza.position.x = 100;
Pizza.position.y = 95;
Cat.position.x=250;
Cat.position.y= 100;
Cat1.position.x=1200;
Cat1.position.y= 280;
Cat2.position.x=400;
Cat2.position.y= 500;
}
}
if (Cat2.overlapPixel(Dog.position.x, Dog.position.y) == false) {
Cat2.changeAnimation(“walking”);
Cat2.mirrorX(-1);
Cat2.velocity.x = 1;
Cat2.velocity.y = 2;
if (!hiss.isPlaying()) {
hiss.pause();
}
}

drawSprite(ground);
drawSprite(Owner);
drawSprites();
drawSprite(Pizza);
drawSprite(Dog);
}

Advertisements

About dercks

Shelby is a student at Alfred State College in Digital Media and Animation.
This entry was posted in Interactive Authoring and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s