No description provided
The showcase player uses a modified version of Processing.js in combination with jsweet to let students program their apps in Java code while still allowing for browser support.
Content created by students is scaled to fit the showcase frame while maintaining aspect ratio and cursor position. This is why some projects may appear blurry in fullscreen, or why some small details may not be visible on a small screen
<iframe width='500px' height='400px' src='https://nest.ktbyte.com/nest#12691' allowfullscreen></iframe>
float rectx; float recty; float vx; float vy; float g = 0.1; boolean leftKey, rightKey; int screen = 0; float goalx = 550; float goaly = 150; float timeat2; float timeat4; int jump; void setup() { noStroke(); imageMode(CENTER); size(800, 600); rectx = 0; recty = height - 100; } void draw() { if (screen == 1) { drawScreen1(); } else if(screen == 0) { drawScreen0(); if(keyPressed || mousePressed) { screen = 1; } } else if (screen == 2) { drawScreen2(); } else if (screen == 4) { drawScreen4(); } else if (screen == 5) { drawScreen5(); } else if (screen == 6) { drawScreen6(); } else if (screen == 7) { drawScreen7(); } else if (screen == 8) { drawScreen8(); } } void move() { rectx += vx; recty += vy; vy += g; if (rightKey) { vx = 5; } else if (leftKey) { vx = -5; } else { vx = 0; } border(); } void border() { if (recty >= height - 100) { vy = 0; jump = 3; //whenever the square hits the ground the number of jumps is reset to 3 } if (recty < 0) { vy = 5; } if (rectx < 0) { vx = 0.1; } if (rectx > width - 100) { vx = - 0.1; } } void keyPressed() { if (keyCode == UP && jump > 0) { vy = -6; jump --; //every time you press the up arrow the number of jumps decreases by 1 } if (keyCode == LEFT) { leftKey = true; } if (keyCode == RIGHT) { rightKey = true; } } void keyReleased() { if (keyCode == LEFT) { leftKey = false; } if (keyCode == RIGHT) { rightKey = false; } } void drawPlatform(platform p) { if(p.deadly) { fill(200, 0, 0); if ((rectx > p.x - p.nx && rectx < p.x + p.px) && (recty < p.y + p.py && recty > p.y - p.ny)) { screen = 4; timeat4 = frameCount; } } else { fill(128); } imageMode(CENTER); rect(p.x, p.y, p.w, p.h); } void drawGoal() { fill(0, 200, 0); rect(goalx, goaly, 200, 10); if ((recty < goaly - 100 && recty > goaly - 105) && (rectx > goalx - 20 && rectx < goalx + 120)) { screen += 1; timeat2 = frameCount; //this if statement checks to make sure that the rectangle is on the platform //and if it is the screen changes and the time is recorded } } void drawScreen0() { background(0); textSize (40); textAlign (CENTER, CENTER); fill (255); text("Use the arrows to move,", width/2, height/2 - 50); text("try to reach the green platform,", width/2, height/2); text("and don't touch the red", width/2, height/2 + 50); } void drawScreen1() { background(255); fill(0, 0, 200); rect(rectx, recty, 100, 100); move(); drawGoal(); platform a = new platform(); a.deadly = true; a.x = 400; a.y = 200; a.w = 20; a.h = 200; a.px = 30; a.nx = 100; a.py = 190; a.ny = 90; drawPlatform(a); } void drawScreen2 () { textSize (64); textAlign (CENTER, CENTER); fill(0, 200, 0); text("Level Passed", width/2, height/2); if ((frameCount - timeat2) > 30) { screen = 5; rectx = 0; recty = height - 100; //this if statement sees how long it has been since we have been on screen 2 //and after a certain amount of time it changes screens and resets the position of the square } } void drawScreen4() { textSize (64); textAlign (CENTER, CENTER); fill(200, 0, 0); text("Level Failed, try again", width/2, height/2); if ((frameCount - timeat4) > 30) { screen = 3; } if (screen == 3) { reset(); } } void drawScreen5() { background(255); fill(0, 0, 200); rect(rectx, recty, 100, 100); move(); drawGoal(); platform a = new platform(); a.deadly = true; a.x = 400; a.y = 200; a.w = 20; a.h = 200; a.px = 30; a.nx = 100; a.py = 190; a.ny = 90; drawPlatform(a); platform b = new platform(); b.deadly = true; b.x = 550; b.y = 500; b.w = 200; b.h = 20; b.px = 170; b.nx = 100; b.py = 190; b.ny = 90; drawPlatform(b); } void drawScreen6() { textSize (64); textAlign (CENTER, CENTER); fill(0, 200, 0); text("Level Passed", width/2, height/2); if ((frameCount - timeat2) > 30) { screen = 7; rectx = 0; recty = height - 100; } } void drawScreen7() { background(255); fill(0, 0, 200); rect(rectx, recty, 100, 100); move(); drawGoal(); platform a = new platform(); a.deadly = true; a.x = 400; a.y = 200; a.w = 20; a.h = 200; a.px = 30; a.nx = 100; a.py = 190; a.ny = 90; drawPlatform(a); platform b = new platform(); b.deadly = true; b.x = 550; b.y = 500; b.w = 200; b.h = 20; b.px = 170; b.nx = 100; b.py = 190; b.ny = 90; drawPlatform(b); platform c = new platform(); c.deadly = true; c.x = 100; c.y = 100; c.w = 200; c.h = 20; c.px = 170; c.nx = 100; c.py = 10; c.ny = 90; drawPlatform(c); } void drawScreen8() { textSize (64); textAlign (CENTER, CENTER); fill(0, 200, 0); text("Congratulations,", width/2, height/2); text("You Have Won!", width/2, height/2 + 70); if ((frameCount - timeat2) > 50) { screen = 3; } if (screen == 3) { reset(); } } void reset() { if (screen == 3) { screen = 0; rectx = 0; recty = height - 100; } } class platform{ boolean deadly; float x; float y; float w; float h; float px; float nx; float py; float ny; }