Permalink
Browse files

Resize window, Help is now a Shape

  • Loading branch information...
qrush committed May 10, 2010
1 parent 43eeb19 commit ebe994c6b0ef14e94f8defa6cf6fc68b121ca72e
Showing with 23 additions and 25 deletions.
  1. +2 −1 TODO
  2. +0 −4 index.html
  3. +21 −20 kidsmash.pjs
View
3 TODO
@@ -10,5 +10,6 @@
[X] Print only A-Za-z0-9
[X] Make a shape class
[X] s/randInt/random
-[ ] resize canvas when window resizes
+[X] resize canvas when window resizes
[ ] Mouse tracking with shape
+[ ] Instructions on page if you have a crappy browser
View
@@ -6,10 +6,6 @@
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
- <!--
- <h1>KID SMASH</h1>
- <p>let your kids play on the computer! press f to go full screen!</a></p>
--->
<script language="javascript" src="processing-0.8.min.js"></script>
<canvas datasrc="kidsmash.pjs" />
</body>
View
@@ -5,33 +5,21 @@ int yellowFill = 0, redFill = 121;
boolean move = true;
var shapes = [];
-class Help {
- int x, y, alpha;
- int fade = 5;
-
+class Help extends Shape {
Help() {
- x = 0;
- y = HEIGHT - 25;
- alpha = 255;
- }
-
- function update() {
- if(alpha > 0)
- alpha -= fade;
-
- return true;
+ super(0,0)
+ alpha = 2000
}
- function draw() {
+ void draw() {
pushMatrix();
textSize(50);
fill(0,0,0,alpha);
- text("KID SMASH!", x, y);
+ text("KID SMASH!", x, HEIGHT - 25);
- translate(3, 15);
- fill(0,0,0);
+ fill(0,0,0,alpha);
textSize(12);
- text("let your kids play on the computer! press F11 to go full screen", x, y);
+ text("let your kids play on the computer! press F11 to go full screen", x + 3, HEIGHT - 8);
popMatrix();
}
}
@@ -111,7 +99,7 @@ class Circle extends Shape {
circleWidth = 200;
circleHeight = 200;
}
-
+
Circle(int nX, int nY, int w, int h) {
super(nX, nY);
circleWidth = w;
@@ -198,6 +186,19 @@ void setup() {
size(WIDTH, HEIGHT);
frameRate(15);
textAlign(CENTER);
+
+ // Check every second for the window resize
+ setInterval(function() {
+ nWIDTH = window.innerWidth;
+ nHEIGHT = window.innerHeight;
+
+ if(WIDTH != nWIDTH || HEIGHT != nHEIGHT) {
+ WIDTH = nWIDTH;
+ HEIGHT = nHEIGHT;
+ shapes.unshift(new Help());
+ size(WIDTH, HEIGHT);
+ }
+ }, 1000);
}
// Main draw loop

0 comments on commit ebe994c

Please sign in to comment.