4 * An AUDIO-ONLY game by Dan Stowell <danstowell@users.sourceforge.net> (C) 2005
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * This game is inspired by the work of "One Switch"
21 * http://www.oneswitch.org.uk/ - developing games and controllers
22 * to accommodate various types of disability, including...
26 * You are kicking a football into the air. You can hear it fly
27 * up into the air and down again, and when it comes down you
28 * must press SPACE to kick it up again.
30 * The ball may move slightly towards the left or right so you
31 * may need to move left or right using the cursor keys to
32 * keep within range of the ball (wear headphones for best
35 * The aim is to kick it up as many times as you can.
41 s.boot; // First make sure the server is on
43 // Then send it the SynthDefs we need
45 SynthDef(\kuball, { |amp=0.5, pan=0, freq=100|
46 Out.ar(0, Pan2.ar(amp * 2 * (BPF.ar(WhiteNoise.ar, freq, 0.1)*10).clip2 * SinOsc.ar(4.5), pan))
49 SynthDef(\gameover, { Out.ar(0, SinOsc.ar(
50 Line.kr(200, 100, 1.0, doneAction:0),
52 EnvGen.kr(Env([0.3, 0.2, 0.2, 0], [0.1, 0.8, 0.1]), 1, doneAction:2)
55 SynthDef(\whackit, {Out.ar(0, SinOsc.ar(74, 0.5pi,
56 EnvGen.kr(Env.perc(0, 0.05), doneAction:2)).dup(2))}).send(s);
60 // Now define the game (won't run until we run the last line in this file)
64 var whacks, xpos, ypos, xvel, yvel, whack, dogravity, framedur, doc, whackdisabled, whackspacing;
72 framedur = 0.1; // The amount of time between two "frames" of calculation
73 whackdisabled = false;
74 whackspacing = 0.3; // The amount of time you must wait between whacks
81 if((yvel < 0) && (whackdisabled==false),
83 yvel = rrand(6.0, 14.0);
84 ypos = max(0.1, ypos);
88 Task({whackspacing.wait; whackdisabled = false}).play;
93 }; // End of whack function
104 kuball = Synth(\kuball);
106 // Set up keyboard handlers
108 doc = Window("Use LEFT and RIGHT arrows and SPACEBAR");
113 doc.view.keyDownAction_({arg ...args;
115 32 , {whack.value}, // space
116 63234, {xpos = xpos + 0.1}, // left arrow
117 63235, {xpos = xpos - 0.1} // right arrow
121 // This is the loop which runs the game
125 kuball.set(\amp, 0.5 * (1.0/max(1.0, ypos)),
126 \pan, max(-1.0, min(1.0, xpos)),
127 \freq, 200 + max(0, ypos * 10));
131 // Destroy keyboard handlers
132 doc.view.keyDownAction_(nil);
135 // Run the end-of-game feedback etc
138 AppClock.sched(0.0, {doc.close;});
140 0, {("You didn't hit the ball - sorry").speak;},
141 1, {("You hit the ball once").speak;},
142 2, {("You hit the ball twice").speak;},
143 3, {("You hit the ball 3 times").speak;},
144 4, {("You hit the ball 4 times - well done").speak;},
145 5, {("You hit the ball 5 times - well done").speak;},
146 {("You hit the ball "+whacks+" times - well done indeed!").speak;}
154 ~game.value; // Press Enter to play!