Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Smileys are go

  • Loading branch information...
commit 860401fe062cbcedf3c366c9693cd1e6cef8f487 1 parent 76a7211
@qrush authored
Showing with 25 additions and 2 deletions.
  1. +2 −2 TODO
  2. +23 −0 kidsmash.pjs
View
4 TODO
@@ -6,10 +6,10 @@
[X] Fullscreen by default
[X] Instructions visible
[X] Title fades out after a while
-[ ] Faces on shapes
+[X] Faces on shapes
[X] Print only A-Za-z0-9
[X] Make a shape class
[X] s/randInt/random
[X] resize canvas when window resizes
-[ ] Mouse tracking with shape
+[X] Mouse tracking with shape
[ ] Instructions on page if you have a crappy browser
View
23 kidsmash.pjs
@@ -7,6 +7,7 @@ var shapes = [];
class Shape {
int x, y, alpha;
+ string smile;
color c;
Shape(int xin, int yin) {
@@ -14,6 +15,7 @@ class Shape {
y = yin;
alpha = 255;
c = color(random(255), random(255), random(255));
+ smile = smiley();
}
void update(fade) {
@@ -26,6 +28,17 @@ class Shape {
fill(c, alpha);
custom.call();
}
+
+ void drawSmiley() {
+ pushMatrix();
+ translate(x, y);
+ rotate(radians(90));
+ translate(-x-25,-y+25);
+ fill(0, 0, 0, alpha)
+ textSize(80);
+ text(smile, x, y);
+ popMatrix();
+ }
}
class Help extends Shape {
@@ -110,6 +123,7 @@ class Circle extends Shape {
void draw() {
draw(function() {
ellipse(x, y, circleWidth, circleHeight);
+ drawSmiley();
});
}
}
@@ -122,6 +136,7 @@ class Square extends Shape {
void draw() {
draw(function() {
rect(x, y, 200, 200);
+ drawSmiley();
});
}
}
@@ -140,6 +155,7 @@ class Triangle extends Shape {
triangle(x-100, y+100,
x, y-100,
x+100, y+100);
+ drawSmiley();
});
}
}
@@ -159,6 +175,7 @@ class Trapezoid extends Shape {
x+75, y-100,
x+125, y+100,
x-125, y+100)
+ drawSmiley();
});
}
}
@@ -186,6 +203,7 @@ class Star extends Shape {
vertex(x+100, y-20); // right
vertex(x+30, y-30);
endShape();
+ drawSmiley();
});
}
}
@@ -258,6 +276,11 @@ void draw() {
}
}
+string smiley() {
+ var smileys = [":)", ":D", ":P", ":o", ":]", "8)", "8D", "XD", ";)"];
+ return smileys[random(smileys.length)|0];
+}
+
Shape randomShape() {
var which = 0 | random(NUM_SHAPES);

0 comments on commit 860401f

Please sign in to comment.
Something went wrong with that request. Please try again.