xxxxxxxxxx
329
/*
Sally Linares
May 6, 2024
Final Project
THE BOOTLEG VERSION OF GUESS THE COLOR CODE
Sound 3: "Magic 12" by RICHERlandTV-MAY 21st, 2015 https://freesound.org/people/RICHERlandTV/sounds/274602/
Sound 2: "Cute UI Sound" by EminYILDIRIM-OCTOBER 18th 2021
https://freesound.org/people/EminYILDIRIM/sounds/592658/
Sound 1: "Nice anime sword hit" by xkenl-OCTOBER 18th, 2023
https://freesound.org/people/xkeril/sounds/706204/
"w""a""s""d" are used to make the character moved!
*PRESS UR KEYBOARD TO PUT IN THE CODE TO MAKE THE DOOR BUTTON TO APPEAR*
*CODE "PBG" P=PINK B=BLUE G=GREEN*
*/
var columnSlider;
let button;
var r;
var g;
var b;
var a;
let movingUp = false;
let movingDown = false;
let movingRight = false;
let movingLeft = false;
let xpos = 59;
let ypos = 345;
let mpos = 49;
let spos = 340;
let kpos = 70;
let jpos = 334;
let bpos = 353;
let qpos = 76;
let wpos = 45;
let apos = 10;
let speed = 15;
function setup() {
var canvas = createCanvas(600, 400);
var main = canvas.parent();
console.log(main);
var landscapeButton = createButton("Generate a landscape");
landscapeButton.mousePressed(landscape);
landscapeButton.parent(main);
var colorCodeButton = createButton("CODE IS PBG LOWERCASE");
colorCodeButton.mousePressed(landscape);
colorCodeButton.parent(main);
createSpan("Set number of trees & flowers:");
columnSlider = createSlider(0, 20, 10);
columnSlider.input(landscape);
landscape();
button = createButton('Door');
button.position(260,350);
button.mousePressed(changeBG);
}
function changeBG() {
let val = random(255);
background("black");
textSize(20);
text("SIKE THERE WAS NEVER A DOOR LOL!", 250,250);
text("THERE NOT ESCAPING THIS GAME LOL!", 290,290);
}
function saveImage() {
save("landscape.png");
}
function preload() {
greenButton = loadSound("Sword.wav");
blueButton = loadSound("Cute.wav");
pinkButton = loadSound("Magic.mp3");
}
function keyPressed() {
if (keyCode == 71) {
//"g"
greenButton.play();
blueButton.stop();
pinkButton.stop();
{
}
}
if (keyCode == 66) {
//"b"
blueButton.play();
pinkButton.stop();
greenButton.stop();
{
}
}
if (keyCode == 80) {
//"p"
pinkButton.play();
blueButton.stop();
greenButton.stop();
button.hide();
} else {
button.show();
}
if (key == 'w') {
movingUp = true;
}
if (key == 'a') {
movingLeft = true;
}
if (key == 's') {
movingDown = true;
}
if (key == 'd') {
movingRight = true;
}
}
function keyReleased() {
if (key == 'w') {
movingUp = false;
}
if (key == 'a') {
movingLeft = false;
}
if (key == 's') {
movingDown = false;
}
if (key == 'd') {
movingRight = false;
}
}
function landscape() {
background("lightblue");
fill("green");
noStroke();
rect(0, 300, width, 100);
//pond
fill("lightblue");
ellipse(300, 370, 400, 40);
Sun(15, 50);
//Three Stars
push();
fill("lime");
circle(120, 330, 20);
fill("aqua");
circle(300, 310, 15);
fill("deeppink");
circle(550, 320, 10);
//number of trees
var n = columnSlider.value();
var w = width / n; //width of each column
for (var x = 0; x <= width; x += 50) {
var y = random(20, 140);
cloud(x, y, "white");
var s = random(50, 100);
tree(x, 220, s);
var f = random(50, 100);
flower(x, 290, f);
var r = random(90, 140);
rain(x, y + 30, r);
}
}
function Sun() {
fill("Gold");
circle(30, random(130), 80);
}
function draw(){
//Kirby ball
r = random(255);
g = random(100,200);
b = random(100)
a = random(200,255);
fill(r,g,b,a);
ellipse(xpos, ypos, 60, 60);
//Kirby left eye
fill(73, 134, 255);
ellipse(mpos, spos, 15, 20);
fill("white");
ellipse(mpos, jpos, 10, 10);
//right eye
fill(73, 134, 255);
ellipse(kpos, spos, 15, 20);
fill("white");
ellipse(kpos, jpos, 10, 10);
//tiny blush
fill(255, 135, 179);
ellipse(qpos, bpos, 10, 5);
ellipse(wpos, bpos, 10, 5);
//Tree with COLOR CODE
fill("brown");
rect(12, 326, 5, 25);
fill("Darkgreen");
ellipse(15, 322, 30, 30);
fill("Gold");
textAlign(CENTER);
textSize(7);
text("The", 15, 315);
text("Code", 15, 322);
text("Is", 15, 328);
text("PGB!", 15, 334);
//kribymoving
if (movingRight) {
xpos += speed;
}
if (movingLeft) {
xpos -= speed;
}
if (movingUp) {
ypos -= speed;
}
if (movingDown) {
ypos += speed;
}
if (movingRight){
mpos += speed;
}
if (movingLeft){
mpos -= speed;
}
if (movingUp){
spos -= speed;
}
if (movingDown){
spos += speed;
}
if (movingRight){
kpos += speed;
}
if(movingLeft){
kpos -= speed;
}
if (movingUp){
jpos -= speed;
}
if (movingDown){
jpos += speed;
}
if(movingRight){
qpos += speed;
}
if(movingLeft){
qpos -= speed;
}
if (movingUp){
bpos -= speed;
}
if (movingDown){
bpos += speed;
}
if (movingRight){
wpos += speed;
}
if (movingLeft){
wpos -= speed;
}
if (movingUp){
apos -= speed;
}
if (movingDown){
apos += speed;
}
}
function rain(x, y, r) {
fill("DeepSkyBlue");
circle(x - 20, y + 30, 9);
circle(x - 40, y + 60, 9);
circle(x, y, 4);
}
function cloud(x, y, c) {
fill(c);
circle(x, y, 50);
circle(x + 20, y + 20, 50);
circle(x + 20, y + 20, 50);
circle(x - 20, y + 20, 50);
}
function tree(x, y, s) {
fill("brown");
rect(x, y, 20, 100, 5);
fill("green");
circle(x + 10, y, s);
}
function flower(x, y, f) {
fill("ForestGreen");
rect(x - 15, y - 15, 10, 60, 10);
fill(random(255), random(255), random(255));
ellipse(x, y, 20, 20);
ellipse(x - 15, y + 5, 20, 20);
ellipse(x - 25, y - 5, 20, 20);
ellipse(x - 17, y - 20, 20, 20);
ellipse(x, y - 15, 20, 20);
}