comparison pytouhou/vm/eclrunner.py @ 207:709f42eaa55e

Minor refactoring
author Thibaut Girka <thib@sitedethib.com>
date Sat, 05 Nov 2011 20:19:15 +0100
parents 52c0b9399413
children 577f45454402
comparison
equal deleted inserted replaced
206:eca53abdfeab 207:709f42eaa55e
884 for bullet in self._game.bullets: 884 for bullet in self._game.bullets:
885 bullet.speed = 2.0 #TODO 885 bullet.speed = 2.0 #TODO
886 bullet.angle = self._game.prng.rand_double() * pi #TODO 886 bullet.angle = self._game.prng.rand_double() * pi #TODO
887 bullet.delta = (cos(bullet.angle) * bullet.speed, sin(bullet.angle) * bullet.speed) 887 bullet.delta = (cos(bullet.angle) * bullet.speed, sin(bullet.angle) * bullet.speed)
888 elif function == 1: # Cirno 888 elif function == 1: # Cirno
889 offset = self._enemy.bullet_launch_offset 889 offset = (self._game.prng.rand_uint16() % arg - arg / 2,
890 self._enemy.bullet_launch_offset = ( 890 self._game.prng.rand_uint16() % arg - arg / 2)
891 self._game.prng.rand_uint16() % arg - arg / 2, 891 self._enemy.fire(offset=offset)
892 self._game.prng.rand_uint16() % arg - arg / 2)
893 self._enemy.fire()
894 self._enemy.bullet_launch_offset = offset
895 elif function == 13: 892 elif function == 13:
896 if self._enemy.bullet_attributes is None: 893 if self._enemy.bullet_attributes is None:
897 return 894 return
898 895
899 if self._enemy.frame % 6: 896 if self._enemy.frame % 6:
900 return 897 return
901 898
902 offset = self._enemy.bullet_launch_offset 899 (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots,
903 pos = self._enemy.x, self._enemy.y 900 speed, speed2, launch_angle, angle, flags) = self._enemy.bullet_attributes
904 attributes = self._enemy.bullet_attributes
905
906 self._enemy.x, self._enemy.y = (192, 224)
907 type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, launch_angle, angle, flags = attributes
908 for i in range(arg): 901 for i in range(arg):
909 _angle = i*2*pi/arg 902 _angle = i*2*pi/arg
910 _angle2 = _angle + self._getval(-10007) 903 _angle2 = _angle + self._getval(-10007)
911 _distance = self._getval(-10008) 904 _distance = self._getval(-10008)
912 self._enemy.bullet_launch_offset = (cos(_angle2) * _distance, sin(_angle2) * _distance) 905 launch_pos = (192 + cos(_angle2) * _distance,
913 self._enemy.bullet_attributes = (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, self._getval(-10006) + _angle, angle, flags) 906 224 + sin(_angle2) * _distance)
914 self._enemy.fire() 907 bullet_attributes = (type_, anim, sprite_idx_offset,
915 908 bullets_per_shot, number_of_shots,
916 self._enemy.bullet_attributes = attributes 909 speed, speed2,
917 self._enemy.x, self._enemy.y = pos 910 self._getval(-10006) + _angle, angle, flags)
918 self._enemy.bullet_launch_offset = offset 911 self._enemy.fire(launch_pos=launch_pos,
912 bullet_attributes=bullet_attributes)
919 else: 913 else:
920 logger.warn("Unimplemented special function %d!", function) 914 logger.warn("Unimplemented special function %d!", function)
921 915
922 916
923 @instruction(123) 917 @instruction(123)