]> gitweb.factorcode.org Git - factor.git/blob - extra/jamshred/game/game.factor
factor: trim using lists
[factor.git] / extra / jamshred / game / game.factor
1 ! Copyright (C) 2007, 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays jamshred.player jamshred.sound
4 jamshred.tunnel kernel math math.constants sequences ;
5 IN: jamshred.game
6
7 TUPLE: jamshred sounds tunnel players running quit ;
8
9 : <jamshred> ( -- jamshred )
10     <sounds> <random-tunnel> "Player 1" pick <player>
11     2dup swap play-in-tunnel 1array f f jamshred boa ;
12
13 : jamshred-player ( jamshred -- player )
14     ! TODO: support more than one player
15     players>> first ;
16
17 : jamshred-update ( jamshred -- )
18     dup running>> [
19         jamshred-player update-player
20     ] [ drop ] if ;
21
22 : toggle-running ( jamshred -- )
23     dup running>> [
24         f >>running drop
25     ] [
26         [ jamshred-player moved ]
27         [ t >>running drop ] bi
28     ] if ;
29
30 : mouse-moved ( x-radians y-radians jamshred -- )
31     jamshred-player -rot turn-player ;
32
33 CONSTANT: units-per-full-roll 50
34
35 : jamshred-roll ( jamshred n -- )
36     [ jamshred-player ] dip 2 pi * * units-per-full-roll / roll-player ;
37
38 : mouse-scroll-x ( jamshred x -- ) jamshred-roll ;
39
40 : mouse-scroll-y ( jamshred y -- )
41     neg swap jamshred-player change-player-speed ;