Charlene - L

By Charlene
//This creature is very insecure. //Pat it to calm it down. Monster m; PShape s; PShape s2; void setup() { size(600, 400); smooth(); s = loadShape("Monster2.svg"); s2 = loadShape("Monster.svg"); m = new Monster(); m.assignValues(0); } void draw() { background(255); m.display(); m.move(); } class Monster { float x = width/2; float y = height/2; float speed; float d; Monster() { } void assignValues(float sd) { speed = sd; } void move() { x += random(-1, 1) * speed; y += random(-1, 1) * speed; x = constrain(x, 0, width); y = constrain(y, 0, height); if(dist(x, y, mouseX, mouseY) < 20) { speed = speed - speed; } else if(dist(x, y, mouseX, mouseY) > 20) { speed = speed + 0.05; } } void display() { d = dist(x, y, mouseX, mouseY); shape(s, x, y, d/2, d/2); shape(s2, x, y, 90, 80); shapeMode(CENTER); } }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*