top of page
Search

Hello!



Since I am studying the material we learned this semester, I decided to try something with classes and also mouse over. I integrated text, just for the fun of it. This was quite fun :)


This is the code:


int x = 0;

int y = 0;

int speed = 9;

int state = 0;

int w = 500;

int h = 500;


void setup(){

size(800,500);

myBubbles = new Bubble[500];

for (int i=0; i<myBubbles.length; i++) {

myBubbles[i]= new Bubble();

myBubbles[i].x=(int)random(0, width);

myBubbles[i].y=(int)random(0, height);

myBubbles[i].speedX=(int)random(0, 3);

myBubbles[i].speedY=(int)random(0, 3);

}

}


Bubble[] myBubbles;


void draw() {

background(65,205,190);

//bubbles in background

for (int i=0; i<myBubbles.length; i++) {

myBubbles[i].drawMe();

}

//circle

noStroke();

if (mouseX > 150 && mouseX < 650)

{

fill (0);

} else {

fill (255,211,40);

}

ellipse(width/2,height/2,w,h);

//Hello

PFont f = createFont("overgrow", 150);

String s = "HELLO!";

fill(255);

textFont(f);

textSize(175);

text(s,75,320);

}



In another tab I created the class Bubble


class Bubble {

int speedX=2, speedY=1;

int x=0, y=0;


void drawMe() {

x=x+speedX;

noStroke();

fill(255,215,215);

ellipse(x, y, 10, 10);

if (x>width) {

speedX = speedX*-1;

}

if (x<0) {

speedX=speedX*-1;

}


y=y+speedY;

if (y>height || y<0) {

speedY=speedY*-1;

}

}

}

 
 
 

Comments


© 2020 by Maria Guzman. Proudly created with Wix.com.

bottom of page