// MAUI Window Game // Copyright 2009 Les Hall // This software is protected by the GNU General Public License // // Many thanks to Kassen for the phasor sound :) // // Instructions: // Click on the target button to score points. // Button gets faster with every mouse click (hit or miss). // Button gets smaller every time you successfully click on it. // Game will run forever if not halted. 1.1 => float speedUp; // adjusts how quickly game speeds up 200 => int size; // initial target size 50::ms => dur timeStep; // initial time between steps class scoreBoard { int score; MAUI_View scoreView; scoreView.size(200, 100); scoreView.position(0, 50); MAUI_Button message; message.size(200, 100); scoreView.addElement(message); scoreView.display(); fun void incrementScore() { if (score == 1) { message.name("score is " + score + " point"); } else { message.name("score is " + score + " points"); } 1 +=> score; } incrementScore(); } scoreBoard board; class window { 0 => int xMin; 1023 - size => int xMax; 0 => int yMin; 767 - size => int yMax; Math.rand2(xMin, xMax) => int xPos; Math.rand2(yMin, yMax) => int yPos; Math.rand2(-5, 5) => int xStep; Math.rand2(-5, 5) => int yStep; MAUI_View window; window.size(size, size); window.position(xPos, yPos); MAUI_Button target; target.toggleType(); target.size(size, size); window.addElement(target); window.display(); while (!target.state()) { timeStep => now; xStep +=> xPos; yStep +=> yPos; if (xPos < xMin) {xMin + (xMin - xPos) => xPos; -1 *=> xStep;} if (xPos > xMax) {xMax - (xPos - xMax) => xPos; -1 *=> xStep;} if (yPos < yMin) {yMin - (yPos - yMin) => yPos; -1 *=> yStep;} if (yPos > yMax) {yMax + (yMax - yPos) => yPos; -1 *=> yStep;} window.position(xPos, yPos); } window.destroy(); (size / speedUp + 1) $ int => size; } class phasor { SubNoise s=>dac; int n; fun void shoot() { while(n<200) { 1 +=> n; n => s.rate; n::ms => now; } } spork ~ shoot(); } class mouse { 0 => int device; Hid hi; HidMsg msg; if (!hi.openMouse(device)) { <<<"Error - can't find mouse", "">>>; me.exit(); } fun void faster() { timeStep / speedUp => timeStep; } fun void timeLoop() { while (true) { hi => now; while (hi.recv(msg)) { if (msg.isButtonDown()) { faster(); } } } } spork ~ timeLoop(); } mouse mickey; while (true) { window game; board.incrementScore(); phasor zap; }