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