class Mote extends GameObject { PVector vel; Mote() { vel = randomVector(MAX_MOTE_SPEED); pos = new PVector(random(width), height); } void draw() { ellipseMode(RADIUS); noStroke(); float noi = noiseAt(pos.x, pos.y); fill(blendColors(color(0, 0, 128), color(255, 192, 96), noi*1.5)); ellipse(pos.x, pos.y, 3, 3); } void tick() { float xslope = noiseAt(pos.x + SENSE_RADIUS, pos.y) - noiseAt(pos.x - SENSE_RADIUS, pos.y); float yslope = noiseAt(pos.x, pos.y + SENSE_RADIUS) - noiseAt(pos.x, pos.y - SENSE_RADIUS); PVector downhill = new PVector(xslope, yslope); downhill.normalize(); downhill.mult(HILL_ACCEL); vel.add(downhill); vel.y += gravity; vel.y -= antigravity * noiseAt(pos.x, pos.y); if(game_over) vel.y -= gameover_lift; PVector m = new PVector(mouseX, mouseY); if(inRadius(pos, m, REPEL_RADIUS) && !game_over) { vel = PVector.sub(pos, m); } vel.limit(MAX_MOTE_SPEED); pos.add(vel); if(pos.x < 0) { pos.x = -pos.x; vel.x = -vel.x; } if(pos.x > width) { pos.x = width*2 -pos.x; vel.x = -vel.x; } if(pos.y < 0) { pos.y = -pos.y; vel.y = -vel.y; removal_flag = true; if(!game_over) { dreams++; alert_decay *= DECAY_DREAM_PENALTY; alertness += ESCAPE_PENALTY; fill(255); rect(pos.x - 2, 0, 5, height); } } if(pos.y > height) { pos.y = height*2 -pos.y; vel.y = -vel.y; } } }