comparison pytouhou/game/game.pyx @ 473:1c891c71cf22

Cythonize pytouhou.game.text.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 16 Sep 2013 18:42:12 +0200
parents 06f0eeb519bb
children 2f53be1b2f60
comparison
equal deleted inserted replaced
472:8038f1957b71 473:1c891c71cf22
18 from pytouhou.game.bullet cimport Bullet, LAUNCHED, CANCELLED 18 from pytouhou.game.bullet cimport Bullet, LAUNCHED, CANCELLED
19 from pytouhou.game.enemy cimport Enemy 19 from pytouhou.game.enemy cimport Enemy
20 from pytouhou.game.item cimport Item 20 from pytouhou.game.item cimport Item
21 from pytouhou.game.effect cimport Particle 21 from pytouhou.game.effect cimport Particle
22 from pytouhou.game.laser cimport Laser, PlayerLaser 22 from pytouhou.game.laser cimport Laser, PlayerLaser
23 from pytouhou.game.text import Text, NativeText
24 from pytouhou.game.face import Face 23 from pytouhou.game.face import Face
25 24
26 25
27 cdef class Game: 26 cdef class Game:
28 def __init__(self, players, long stage, long rank, long difficulty, bullet_types, 27 def __init__(self, players, long stage, long rank, long difficulty, bullet_types,
227 cpdef new_msg(self, sub): 226 cpdef new_msg(self, sub):
228 self.msg_runner = MSGRunner(self.msg, sub, self) 227 self.msg_runner = MSGRunner(self.msg, sub, self)
229 self.msg_runner.run_iteration() 228 self.msg_runner.run_iteration()
230 229
231 230
232 cdef new_label(self, pos, str text): 231 cdef Text new_label(self, tuple pos, bytes text):
233 label = Text(pos, self.interface.ascii_anm, text=text, xspacing=8, shift=48) 232 label = Text(pos, self.interface.ascii_anm, text=text, xspacing=8, shift=48)
234 label.set_timeout(60, effect='move') 233 label.set_timeout(60, effect='move')
235 self.labels.append(label) 234 self.labels.append(label)
236 return label 235 return label
237 236
238 237
239 cpdef new_native_text(self, pos, text, align='left'): 238 cpdef NativeText new_native_text(self, tuple pos, unicode text, align='left'):
240 label = NativeText(pos, text, shadow=True, align=align) 239 label = NativeText(pos, text, shadow=True, align=align)
241 return label 240 return label
242 241
243 242
244 cpdef new_hint(self, hint): 243 cpdef Text new_hint(self, hint):
245 pos = hint['Pos'] 244 pos = hint['Pos']
246 #TODO: Scale 245 #TODO: Scale
247 246
248 pos = pos[0] + 192, pos[1] 247 pos = pos[0] + 192, pos[1]
249 label = Text(pos, self.interface.ascii_anm, text=hint['Text'], align=hint['Align']) 248 label = Text(pos, self.interface.ascii_anm, text=hint['Text'], align=hint['Align'])
250 label.set_timeout(hint['Time']) 249 label.set_timeout(hint['Time'])
251 label.set_alpha(hint['Alpha']) 250 label.set_alpha(hint['Alpha'])
252 label.set_color(hint['Color'], text=False) 251 label.set_color(None, hint['Color']) #XXX
253 self.labels.append(label) 252 self.labels.append(label)
254 return label 253 return label
255 254
256 255
257 cpdef new_face(self, side, effect): 256 cpdef new_face(self, side, effect):