1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
=head1 DESCRIPTION
eventhandler.pir - a tetris event handler class
=cut
.namespace ["Tetris::EventHandler"]
.sub __onload :load
$P0 = get_class "Tetris::EventHandler"
unless null $P0 goto END
load_bytecode "library/SDL/EventHandler.pir"
get_class $P0, ['SDL'; 'EventHandler']
subclass $P0, $P0, "Tetris::EventHandler"
$P1 = new 'String'
$P1 = "BUILD"
setprop $P0, "BUILD", $P1
addattribute $P0, "app"
END:
.end
.sub BUILD :method
.param pmc app
setattribute self, 'app', app
.end
.sub app :method
.local pmc app
getattribute app, self, 'app'
.return (app)
.end
.sub dispatch_event :method
.local pmc app
.local int ret
app = self."app"()
app."setTimer"( 0 )
$P0 = get_hll_global ['SDL'; 'Event'], "disptach_event"
ret = $P0()
app."setTimer"( 1 )
.return (ret)
.end
.sub nextBlock :method
.param int boardID
.param int blockID
.local pmc app
.local pmc board
.local pmc block
print "next block on board "
print boardID
print " is "
print blockID
print "\n"
app = self."app"()
board = app."board"( boardID )
# get the current next block
block = board."getNextBlock"()
# set the wanted block as new next block
board."nextBlock"( blockID )
# make it active by activating a new block
board."nextBlock"()
# restore the old "nextBlock"
board."setNextBlock"( block )
.end
.sub key_down_escape :method
end
.end
.sub key_down_0 :method
self."nextBlock"( 0, -1 )
.end
.sub key_down_1 :method
self."nextBlock"( 0, 0 )
.end
.sub key_down_2 :method
self."nextBlock"( 0, 1 )
.end
.sub key_down_3 :method
self."nextBlock"( 0, 2 )
.end
.sub key_down_4 :method
self."nextBlock"( 0, 3 )
.end
.sub key_down_5 :method
self."nextBlock"( 0, 4 )
.end
.sub key_down_6 :method
self."nextBlock"( 0, 5 )
.end
.sub key_down_7 :method
self."nextBlock"( 0, 6 )
.end
.sub key_down_space :method
$P0 = self."app"()
$P0."fall"( 0 )
.end
.sub key_down_left :method
$P0 = self."app"()
$P0."move"( 0, -1, 0 )
.end
.sub key_down_right :method
$P0 = self."app"()
$P0."move"( 0, +1, 0 )
.end
.sub key_down_up :method
$P0 = self."app"()
$P0."rotate"( 0, -1 )
.end
.sub key_down_down :method
$P0 = self."app"()
$P0."rotate"( 0, +1 )
.end
.sub key_down_F1 :method
$P0 = self."app"()
$P0."newGame"( 1 )
.end
.sub key_down_F2 :method
$P0 = self."app"()
$P0."newGame"( 2 )
.end
=head1 AUTHOR
Jens Rieks E<lt>parrot at jensbeimsurfen dot deE<gt> is the author
and maintainer.
Please send patches and suggestions to the Perl 6 Internals mailing list.
=head1 COPYRIGHT
Copyright (C) 2004-2008, Parrot Foundation.
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
|