WASD keys to move. Refresh for sound. Use Q and E to attack - but don't when the vultures are looking at you!
A fork of Save the Mushrooms by German spy anti furry
xxxxxxxxxx
/*
Hey sableraph and friends!
I am not kitten around, figuring out how to code this was pretty purr-plexing! But at the same time, purr-y fun!
Hope you all enjoy!
Store link to get yourself a Shirt!: https://streamlabs.com/sl_id_72a9c899-5992-36f4-ba16-9cfb419365a6/merch
If you like this short game you may also like my new game I created called Wizarding World! Link: https://openprocessing.org/sketch/2119935
p5play website and very helpful reference page: https://p5play.org/learn/
*/
//music Music by <a href="https://pixabay.com/users/geoffharvey-9096471/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=150613">Geoff Harvey</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=150613">Pixabay</a>
//cat sprite https://opengameart.org/content/cat-sprites-0
//mushroom from https://opengameart.org/content/large-mushroom
//background image / win image / thumbnail image - created using midjourney. Prompt:
//Music by: <a href="https://pixabay.com/users/alexiaction-26977400/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=166693">Alexi Action</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=166693">Pixabay</a>
//win sound from https://pixabay.com/sound-effects/success-fanfare-trumpets-6185/
let ImageAppear=false
let score = 0;
let moveRight=false
let coinTimer=false
let coinSoundCounter=0
let YouWon=false
let ballAtDefaultPos=true
let ballToMouse=true
let winnerSoundPlaying=false
let playerAttackRight=false
let playerAttackLeft=false
let playTheMusic=true
function preload()
{
vultureImg = loadImage('vulture.png');
grassImg = loadImage('grass.png');
grasstopImg = loadImage('weeds.png');
coinsImg = loadImage('Mushroom.png');
fungibg = loadImage('catbg2.png');
charactersImg = loadImage('spriteSheet.png');
soundFormats('mp3', "wav");
song = loadSound('CatMusic.mp3');
winnerSound = loadSound('success-fanfare-trumpets-6185.mp3');
winImg= loadImage('catwin.png');
}
function playmusic()
{
if(playTheMusic==true)
{
song.play() //play and loop sound
song.loop()
playTheMusic=false
}
}
function setup()
{
new Canvas(400, 160, 'pixelated');
world.gravity.y = 10; //gravity
allSprites.pixelPerfect = true;
grass = new Group(); //grass block data
grass.layer = 0;
grass.collider = 'static';
grass.img = grassImg;
grass.tile = 'g';
grassTop = new Group(); //grass that is transparent data
grassTop.layer = 2;
grassTop.collider = 'static';
grassTop.img = grasstopImg;
grassTop.tile = 'w';
coins = new Group(); //mushroom data
coins.layer = 2;
coins.collider = 'static';
coins.img = coinsImg;
coins.scale=.098
coins.y=100
coins.tile = 'm';
new Tiles(
[ //below here is the map of the level.
//"g"= grass block
//"w"= weeds block
//"m"= mushroom block
'',
' m ',
' g ',
' m m g m ',
' g gg g ',
' m ggg m m ',
' www gggg g ',
' wgggw g m m g g ggggg m g g g ',
'wwwwwwwwwwwwgggggwwwwwgwwwwwwgwwwwwwwwwwwwwwwwwwwwwwwwwggggggwwwwwwwwwwwwwwwww g ',
'gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg',
' ',
' ',
],
8,
8,
16,
16
);
// (xpos, ypos, travel length on x axis, vulture number)
vulture1= createVulture(100,0,70,1)
vulture2= createVulture(170,50,130,2)
vulture3= createVulture(370,75,90,3)
vulture4= createVulture(675,55,90,4)
vulture5= createVulture(1010,100,160,5)
vulture6= createVulture(1010,50,125,6)
vulture7= createVulture(1525,200,125,7)
//player data
player = new Sprite(48, 100, 12, 12); //48
player.layer = 1;
player.anis.w = 17;
player.anis.h = 17;
player.anis.offset.y = 1;
player.anis.offset.x = 1;
player.anis.frameDelay = 8;
player.spriteSheet = charactersImg;
player.addAnis({
idle: { row: 2, frames: 2 },
knockback: { row: 0, frames: 1 },
run: { row: 3, frames: 7 },
jump: { row: 1, col: 3, frames: 2 },
attack: { row: 5, frames: 4 }
});
player.ani = 'idle';
player.rotationLock = true;
// IMPORTANT! prevents the player from sticking to the sides of walls
player.friction = 0;
player.drag=0
player.overlaps(coins, collectCoin);
groundSensor = new Sprite(48, 106, 6, 12); //ground sensor data
groundSensor.visible = false;
groundSensor.mass = 0.01;
groundSensor.overlaps(allSprites);
new GlueJoint(player, groundSensor);
textAlign(CENTER);
winImage = new Sprite(width/2,height/2,'dynamic'); //final game image
winImage.img = winImg
winImage.scale=.25
winImage.overlaps(allSprites);
grassTop.overlaps(player);
}
function collectCoin(player, coin) //if you collect a mushroom
{
score++
coin.remove();
}
function draw()
{
background(0);
image(fungibg, 48-(player.x/5)-100, 0); //background image
fungibg.resize(width+420, height); //resize background image
if(YouWon==true) //if you win
{
winImage.x=player.x+50 //position the win image where the player is
winImage.y=93
player.vel.x = 0 //stop player from moving
song.stop() //stop the halloween song
if(winnerSoundPlaying==false) //this code makes the trumpet sound play one time. Without this trumpets will loop
{
winnerSound.play()
winnerSoundPlaying=true
}
}
else //if player did not win
{
winImage.x=player.x+50 //the win image follows the player off screen underground
winImage.y=500
fill(255);
if(score<10) text('Mushrooms Needed to Save the Forest: ' + eval(10-score), 130, 20); //display text if score is not 10
else YouWon=true //score is 10, you win
}
if (groundSensor.overlapping(grass))
{
if (kb.presses('up') || kb.presses('space'))
{
player.ani = 'jump';
player.vel.y = -4.5;
playerAttackRight=false
playerAttackLeft=false
}
}
if (kb.pressing('e'))
{
player.ani = 'attack';
player.vel.x = 1.5;
player.mirror.x = false;
playerAttackRight=true
}
else if (kb.pressing('q'))
{
player.ani = 'attack';
player.vel.x = -1.5;
player.mirror.x = true;
playerAttackLeft=true
}
else if (kb.pressing('left'))
{
player.ani = 'run';
player.vel.x = -1.5;
player.mirror.x = true;
playerAttackRight=false
playerAttackLeft=false
}
else if (kb.pressing('right'))
{
player.ani = 'run';
player.vel.x = 1.5;
player.mirror.x = false;
playerAttackRight=false
playerAttackLeft=false
playmusic()
}
else
{
player.ani = 'idle';
player.vel.x = 0;
playerAttackRight=false
playerAttackLeft=false
}
if (player.y > 400) //if player dies
{
player.speed = 0;
player.x = 48;
player.y = 100;
}
if (kb.presses('up') || kb.presses('space')) //alows player to infinitly jump
{
player.ani = 'jump';
player.vel.y = -4.5;
}
camera.x = player.x + 52;
if(YouWon==false)
{
for(i=1;i<8;i++)
{
eval("updateVulture(vulture"+i+");")
}
}
}
function createVulture(x,y,endx,num)
{
AVulture = new Sprite(x,y,'kinematic');
AVulture.num=num
AVulture.startx=x
AVulture.starty=y
AVulture.endy=y+450
AVulture.endx=x+endx
AVulture.HitStart=true
AVulture.LookingRight=true
AVulture.layer = 1;
AVulture.anis.w = 64;
AVulture.anis.h = 45;
AVulture.anis.offset.y = 6;
AVulture.anis.frameDelay = 18;
AVulture.spriteSheet = vultureImg;
AVulture.scale=.6
AVulture.addAnis({
idle: { row: 0, frames: 3 },
});
AVulture.ani = 'idle';
AVulture.rotationLock = true;
AVulture.friction = 0;
AVulture.overlaps(grass);
AVulture.overlaps(coins);
return AVulture
}
function updateVulture(AVulture)
{
if(AVulture.num!=7)
{
AVulture.y=AVulture.starty
}
if( (AVulture.x > player.x) && AVulture.LookingRight==true && playerAttackRight==true && AVulture.collides(player))
{
AVulture.remove()
}
if( (AVulture.x < player.x) && AVulture.LookingRight==false && playerAttackLeft==true && AVulture.collides(player))
{
AVulture.remove()
}
if( (AVulture.x > player.x) && AVulture.LookingRight==false && AVulture.collides(player))
{
player.speed = 0;
player.x = 48;
player.y = 100;
}
if( (AVulture.x < player.x) && AVulture.LookingRight==false && AVulture.collides(player))
{
player.speed = 0;
player.x = 48;
player.y = 100;
}
if(AVulture.num==7)
{
if(AVulture.HitStart==true)
{
AVulture.y++
AVulture.LookingRight=false
AVulture.mirror.x = false
}
if(AVulture.HitStart==false)
{
AVulture.y--
}
if(AVulture.y<=20)
{
AVulture.HitStart=true
}
if(AVulture.y>=200)
{
AVulture.HitStart=false
}
}
if(AVulture.num!=7)
{
if(AVulture.HitStart==true)
{
AVulture.x++
AVulture.LookingRight=true
AVulture.mirror.x = true;
}
if(AVulture.HitStart==false)
{
AVulture.x--
AVulture.LookingRight=false
AVulture.mirror.x = false
}
if(AVulture.x<=AVulture.startx)
{
AVulture.HitStart=true
}
if(AVulture.x>=AVulture.endx)
{
AVulture.HitStart=false
}
}
}