Mercurial > touhou
comparison pytouhou/game/eclrunner.py @ 52:ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 22 Aug 2011 22:37:14 +0200 |
parents | 0707ff53e7b5 |
children | e72166f73e30 |
comparison
equal
deleted
inserted
replaced
51:0707ff53e7b5 | 52:ab826bc29aa2 |
---|---|
1 # -*- encoding: utf-8 -*- | |
2 ## | |
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> | |
4 ## | |
5 ## This program is free software; you can redistribute it and/or modify | |
6 ## it under the terms of the GNU General Public License as published | |
7 ## by the Free Software Foundation; version 3 only. | |
8 ## | |
9 ## This program is distributed in the hope that it will be useful, | |
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ## GNU General Public License for more details. | |
13 ## | |
14 | |
15 | |
1 from math import atan2, cos, sin | 16 from math import atan2, cos, sin |
2 | 17 |
3 | 18 |
4 class MetaRegistry(type): | 19 class MetaRegistry(type): |
5 def __new__(mcs, name, bases, classdict): | 20 def __new__(mcs, name, bases, classdict): |
146 self._enemy._removed = True | 161 self._enemy._removed = True |
147 | 162 |
148 | 163 |
149 @instruction(2) | 164 @instruction(2) |
150 def relative_jump(self, frame, instruction_pointer): | 165 def relative_jump(self, frame, instruction_pointer): |
166 """Jumps to a relative offset in the same subroutine. | |
167 | |
168 Warning: the relative offset has been translated to an instruction pointer | |
169 by the ECL parsing code (see pytouhou.formats.ecl). | |
170 """ | |
151 self.frame, self.instruction_pointer = frame, instruction_pointer | 171 self.frame, self.instruction_pointer = frame, instruction_pointer |
152 | 172 |
153 | 173 |
154 @instruction(3) | 174 @instruction(3) |
155 def relative_jump_ex(self, frame, instruction_pointer, variable_id): | 175 def relative_jump_ex(self, frame, instruction_pointer, value_id): |
176 """If the given variable is non-zero, decrease it by 1 and jump to a | |
177 relative offset in the same subroutine. | |
178 | |
179 Warning: the relative offset has been translated to an instruction pointer | |
180 by the ECL parsing code (see pytouhou.formats.ecl). | |
181 """ | |
156 counter_value = self._getval(variable_id) | 182 counter_value = self._getval(variable_id) |
157 if counter_value: | 183 if counter_value: |
158 self._setval(variable_id, counter_value - 1) | 184 self._setval(variable_id, counter_value - 1) |
159 self.frame, self.instruction_pointer = frame, instruction_pointer | 185 self.frame, self.instruction_pointer = frame, instruction_pointer |
160 | 186 |
165 self._setval(variable_id, self._getval(value)) | 191 self._setval(variable_id, self._getval(value)) |
166 | 192 |
167 | 193 |
168 @instruction(6) | 194 @instruction(6) |
169 def set_random_int(self, variable_id, maxval): | 195 def set_random_int(self, variable_id, maxval): |
196 """Set the specified variable to a random int in the [[0, maxval)) range. | |
197 """ | |
170 self._setval(variable_id, int(self._getval(maxval) * self._game_state.prng.rand_double())) | 198 self._setval(variable_id, int(self._getval(maxval) * self._game_state.prng.rand_double())) |
171 | 199 |
172 | 200 |
173 @instruction(8) | 201 @instruction(8) |
174 def set_random_float(self, variable_id, maxval): | 202 def set_random_float(self, variable_id, maxval): |
203 """Set the specified variable to a random float in [0, maxval) range. | |
204 """ | |
175 self._setval(variable_id, self._getval(maxval) * self._game_state.prng.rand_double()) | 205 self._setval(variable_id, self._getval(maxval) * self._game_state.prng.rand_double()) |
176 | 206 |
177 | 207 |
178 @instruction(20) | 208 @instruction(20) |
179 def add(self, variable_id, a, b): | 209 def add(self, variable_id, a, b): |