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#1551' allowfullscreen></iframe>
int castlehealth = 750; int enemycastlehealth = 750; int yourmoney = 150; int enemymoney = 150; int lastunitspawned = -1000; int lastunitspawnedenemy = -1000; int delaytime = 500; int delaytimeenemy= 500; int rateomoney = 5; int rateomoneyenemy = 5; boolean knightspawn, archerspawn, incomespawn; class Knight { int x; int y; boolean attack; int hp = 60; int dmg = 20; int lastattack; } class Archer { int x; int y; boolean attack; int hp = 40; int dmg = 20; int lastattack; } ArrayList<Knight> knights= new ArrayList<Knight>(); ArrayList<Archer> archers= new ArrayList<Archer>(); ArrayList<Knight> enemyknights= new ArrayList<Knight>(); PImage castle; PImage enemycastle; PImage backgroundImage; PImage knight; PImage enemyknight; PImage archer; PImage money; PImage loss; PImage win; void setup() { size (1800, 800); castle = loadImage ("http://cliparts.co/cliparts/kTM/nq9/kTMnq9kzc.gif"); enemycastle = loadImage ("http://mindgearlabs.com/wp-content/uploads/2015/01/castle6.png"); backgroundImage = loadImage ("http://i.imgur.com/aYvTmoY.png"); enemyknight = loadImage ("http://img4.wikia.nocookie.net/__cb20120629122150/assassinscreed/images/8/88/DVD-Knight.png"); knight = loadImage ("http://lvlt.bioware.cdn.ea.com/bioware/u/f/eagames/bioware/dragonage2/assets/content/world/class-warrior.png"); archer = loadImage ("http://rangersapprentice-rpg.weebly.com/uploads/1/2/3/6/12366939/2059947_orig.png"); money = loadImage ("http://simpleicon.com/wp-content/uploads/money-bag-4.png"); loss = loadImage ("http://img1.wikia.nocookie.net/__cb20141109223427/adventuretimewithfinnandjake/images/7/77/S2e16_You_lose.png"); win = loadImage ("http://ajournalofmusicalthings.com/wp-content/uploads/YouWin.png"); } void draw() { background(110); image (backgroundImage, 0, 0); image (castle, 50, 300, 300, 200); image (enemycastle, 1500, 300, 300, 200); fill (0); rect (0, 599, width, 50); fill (255, 0, 0); rect (0, 599, castlehealth * width / 750, 50); fill (80, 160, 240); for (int x = 0; x < 3; x++) { rect (300 + 400 * x, 649, 400, 151); } image (knight, 500, 649, 200, 350); image (archer, 900, 649, 200, 200); image (money, 1300, 649, 200, 151); fill (255); textSize (18); text ("Spawn a Knight", 350, 669); text ("$50", 350, 699); text ("Spawn an Archer", 750, 669); text ("$85", 750, 699); text ("Increase Income", 1150, 669); text ("$90", 1150, 699); fill (0); text ("Castle Health: " + castlehealth, 50, 619); text ("Enemy Castle Health: " + enemycastlehealth, 50, 679); text ("Money: " + yourmoney, 50, 639); textSize (25); text ("1", 315, 669); text ("2", 715, 669); text ("3", 1115, 669); if (frameCount % 60 == 0) { yourmoney += rateomoney; enemymoney += rateomoneyenemy; } ai(); drawallunits(); fight(); knightmove(); archermove(); if (castlehealth <= 0) { image (loss, 0, 0, width, height); } if (enemycastlehealth <= 0) { image (win, 0, 0, width, height); } } void ai() { if (millis() - lastunitspawnedenemy >= delaytimeenemy) { lastunitspawnedenemy = millis(); if (enemymoney >= 50) { enemymoney -= 50; spawnenemyknight(); } } } void drawallunits() { for (int i = 0; i < knights.size(); i++) { Knight k = knights.get(i); image (knight, k.x, k.y, 60, 110); } for (int i = 0; i < archers.size(); i++) { Archer a = archers.get(i); image (archer, a.x, a.y, 75, 125); } for (int i = 0; i < enemyknights.size(); i++) { Knight k = enemyknights.get(i); image (enemyknight, k.x, k.y, 60, 110); } } void spawntheunits () { if (millis() - lastunitspawned >= delaytime) { lastunitspawned = millis(); if (knightspawn) { if (yourmoney >= 50) { yourmoney -= 50; spawnknight(); } } if (archerspawn) { if (yourmoney >= 85) { yourmoney -= 85; spawnarcher(); } } if (incomespawn) { if (yourmoney >= 90) { yourmoney -= 90; rateomoney += 5; } } } } // this will signel for friendly troops to spawn void keyPressed() { if (key == '1') { knightspawn = true; } if (key == '2') { archerspawn = true; } if (key == '3') { incomespawn = true; } spawntheunits(); } void keyReleased () { if (key == '1') { knightspawn = false; } if (key == '2') { archerspawn = false; } if (key == '3') { incomespawn = false; } } void spawnknight () { Knight newknight = new Knight(); newknight.x = 500; newknight.y = 450; knights.add(newknight); } void spawnarcher () { Archer newarcher = new Archer (); newarcher.x = 500; newarcher.y = 420; archers.add(newarcher); } void spawnenemyknight () { Knight newenemyknight = new Knight(); newenemyknight.x = 1410; newenemyknight.y = 420; enemyknights.add(newenemyknight); } void fight () { for (int alpha = 0; alpha < enemyknights.size(); alpha++) { Knight enemycurrentknight = enemyknights.get(alpha); enemycurrentknight.attack = false; for (int beta = 0; beta < knights.size(); beta++) { Knight currentknight = knights.get(beta); if (enemycurrentknight.x - currentknight.x <= 60) { currentknight.attack = true; enemycurrentknight.attack = true; if (millis () - currentknight.lastattack >= 1000) { currentknight.lastattack = millis(); enemycurrentknight.hp -= currentknight.dmg; } if (millis () - enemycurrentknight.lastattack >= 1000) { enemycurrentknight.lastattack = millis(); currentknight.hp -= enemycurrentknight.dmg; } } if (currentknight.hp <= 0) { knights.remove(beta); } } for (int theta = 0; theta < archers.size(); theta++) { Archer currentarcher = archers.get(theta); if (enemycurrentknight.x - currentarcher.x <= 210) { currentarcher.attack = true; if (millis () - currentarcher.lastattack >= 1200) { currentarcher.lastattack = millis(); enemycurrentknight.hp -= currentarcher.dmg; } } if (enemycurrentknight.x - currentarcher.x <= 60) { enemycurrentknight.attack = true; if (millis () - enemycurrentknight.lastattack >= 1000) { enemycurrentknight.lastattack = millis(); currentarcher.hp -= enemycurrentknight.dmg; } } if (currentarcher.hp <= 0) { archers.remove(theta); } } // end of archer loop if (enemycurrentknight.hp <= 0) { enemyknights.remove(alpha); } else if (500 - enemycurrentknight.x >= 0) { enemycurrentknight.attack = true; if (millis () - enemycurrentknight.lastattack >= 1000) { enemycurrentknight.lastattack = millis (); castlehealth -= enemycurrentknight.dmg; } } } } void knightmove () { int move = 1; for (int i = 0; i < knights.size(); i++) { Knight k = knights.get(i); if (1470 - k.x <= 60) { k.attack = true; if (millis () - k.lastattack >= 1000) { k.lastattack = millis (); enemycastlehealth -= k.dmg; } } if (k.x <= 1410 && k.attack == false) { k.x += move; } k.attack = false; } for (int i = 0; i < enemyknights.size(); i++) { Knight k = enemyknights.get(i); if (k.x >= 500 && k.attack == false) { k.x -= move; } k.attack = false; } } void archermove () { int move = 1; for (int i = 0; i < archers.size(); i++) { Archer a = archers.get(i); if (1470 - a.x <= 210) { a.attack = true; if (millis () - a.lastattack >= 1200) { a.lastattack = millis(); enemycastlehealth -= a.dmg; } } if (a.x <= 1260 && a.attack == false) { a.x += move; } a.attack = false; } }