xxxxxxxxxx
let avatars = [myRacoon, moAvatar, arnavsAvatar, myBunny, maryam, myQuokka]
let messages = ['Happy Halloween', 'i miss uni :(', 'have a great day!', 'boo', 'hahaha', 'im sexy and i know it', 'Hakuna Matata']
let carrots = []
let numCarrots = 100
let face1
let face2
let message
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
for (var i = 0; i < numCarrots; i++) {
let x = random(width)
let y = random(height)
let newCarrot = getCarrot(x, y, random(5, 100), random(5, 100))
carrots.push(newCarrot)
}
face1 = random(avatars)
face2 = random(avatars)
message = random(messages)
}
function draw() {
// background(0)
face1(mouseX, mouseY, 200)
face2(mouseX, mouseY, 100)
mouth(mouseX, mouseY, 100)
speechBubble(mouseX, mouseY, message)
for (var i = 0; i < carrots.length; i++) {
let carrot = carrots[i]
carrot.move()
carrot.eat(mouseX, mouseY)
if (!carrot.isEaten) {
carrot.display()
}
}
}
function getCarrot(x, y, r1, r2) {
let carrot = {}
carrot.color = 'orange'
carrot.len = r1
carrot.wid = r2
carrot.x = x
carrot.y = y
carrot.isEaten = false
carrot.move = function() {
this.x++
this.y++
if (this.x < 0) {
this.x = width
}
if (this.y < 0) {
this.y = height
}
if (this.x > width) {
this.x = 0
}
if (this.y > height) {
this.y = 0
}
}
carrot.eat = function(x, y) {
let distance = dist(x, y, this.x, this.y)
// console.log('distance',distance, this.len)
if (distance < this.len) {
// console.log('eat!')
this.isEaten = true
}
}
carrot.display = function() {
fill(this.color)
ellipse(this.x, this.y, this.len, this.wid)
}
return carrot
}
function mouth(x, y, r) {
fill(34, 155, 215)
// ellipse(x,y+r/4,r/2,r/8*sin(frameCount/100))
ellipse(x, y + r / 2, r, r / 8 * sin(frameCount / 100))
}
function mousePressed() {
face1 = random(avatars)
face2 = random(avatars)
message = random(messages)
}
function speechBubble(x, y, str) {
push()
translate(x, y)
// scale(sin(frameCount/100)*2)
scale(frameCount / 100)
rotate(frameCount / 100)
fill(random(255), random(255), random(255))
textSize(32)
textAlign(CENTER, CENTER)
text(str, 0, 0 - 100)
pop()
}
function myRacoon(x, y, radius) {
push()
translate(x, y)
// head
fill(255)
circle(0, 0, radius)
// eyes
fill(0)
circle(-radius / 4, 0, radius / 2)
circle(radius / 4, 0, radius / 2)
// eyes
fill(255)
circle(-10, 0, radius / 10)
circle(10, 0, radius / 10)
// nose
fill(random(255), random(255), random(255))
circle(0, radius / 2, radius / 10)
pop()
}
function myAvatar(x, y, radius) {
}
function moAvatar(x, y, radius) {
push()
translate(x, y)
// head
fill(255)
ellipse(0, 0, 80, 45)
//ears
triangle(-20, -40, -20, -20, -20, -20)
// eyes
fill(255, 0, 0)
circle(-10, 0, radius / 5)
circle(10, 0, radius / 5)
//
circle(-10, 0, radius / 10)
circle(10, 0, radius / 10)
pop()
}
function arnavsAvatar(x, y, radius) {
push()
translate(x, y)
// head
fill(255, 0, 0)
ellipse(0, 0, 69, 69)
// eyes
fill(0)
circle(-20, 0, radius / 6)
circle(10, 0, radius / 6)
circle(-20, 0, radius / 10)
circle(10, 0, radius / 5)
//mouth
fill(0, 0, 255)
arc(0, 10, 40, 40, 0, PI + QUARTER_PI, CHORD);
pop()
}
function myBunny(x, y, radius) {
push()
translate(x, y)
// head
fill(128, 128, 128)
ellipse(3, 6, radius)
// eyes
fill(0, 0, 0)
ellipse(-10, 0, radius / 5)
ellipse(10, 0, radius / 5)
// eyes
fill(225)
ellipse(2, 0, -12)
ellipse(-2, 0, 12)
// ears
fill(128, 128, 128)
ellipse(-16, -90, -23, radius / 1)
ellipse(16, -90, -23, radius / 1)
pop()
}
function myQuokka(x, y, radius) { //MariamL
push()
translate(x, y)
//ears
fill('brown')
circle(-20, -30, 15)
circle(20, -30, 15)
//head
fill('brown')
ellipse(0, 0, 60, 70)
//eyes
fill(0)
circle(-10, -8, 10)
circle(10, -8, 10)
fill('white')
circle(13, -9, 3)
circle(-7, -9, 3)
//nose
fill(0)
triangle(-5, 0, 5, 0, 0, 10);
//mouth
fill('brown')
arc(0, 10, 10, 10, 0, PI + PI / 20)
pop()
}
function maryam(x, y, radius) {
push()
translate(x, y)
// head
fill(255)
circle(10, 10, 200)
// eyes
fill('pink')
circle(-radius / 3, 0, radius / 2)
circle(radius / 3, 0, radius / 2)
fill('blue')
circle(-12, 6, 10)
circle(12, 6, 10)
fill('black')
circle(0, radius / 2, radius / 10)
pop()
}