Changeset 35

Show
Ignore:
Timestamp:
08/24/08 22:51:32 (5 months ago)
Author:
skit
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • project/trunk/example/particle/explosion.py

    r34 r35  
    11 
    22 
    3 import pygame, pyxoo, math, os 
     3import pygame, pyxoo, math, os, sys 
    44 
    55from pyxoo.particle import DisplayObjectParticle 
    66 
    7 RESOLUTION = 640, 48
     7RESOLUTION = 1680, 105
    88COLOR = 255,150,0 
    99 
    1010class App(pyxoo.engine.Application): 
    1111    def init(self): 
    12         os.environ["SDL_VIDEODRIVER"] = "quartz" 
    13          
     12        if sys.platform == "win32": 
     13            os.environ["SDL_VIDEODRIVER"] = "windib"         
    1414        pygame.init() 
    15         self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE
     15        self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32
    1616        self.bg = pygame.Surface(self.screen.get_size()).convert() 
    1717         
  • project/trunk/example/particle/fountain.py

    r34 r35  
    11 
    22 
    3 import pygame, pyxoo, math, random, os 
     3import pygame, pyxoo, math, random, os, sys 
    44 
    5 RESOLUTION = 640, 48
     5RESOLUTION = 1680, 105
    66COLOR = 0,255,255 
    77 
    88class App(pyxoo.engine.Application): 
    99    def init(self): 
    10         os.environ["SDL_VIDEODRIVER"] = "quartz" 
     10        if sys.platform == "win32": 
     11            os.environ["SDL_VIDEODRIVER"] = "windib" 
    1112        pygame.init() 
    12         self.screen = pygame.display.set_mode(RESOLUTION, pygame.HWSURFACE
     13        self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32
    1314        self.bg = pygame.Surface(self.screen.get_size()).convert() 
    1415        self.input_dispatcher.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
     16        self.input_dispatcher.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
    1517         
    1618        self.monitor = pyxoo.utils.monitor.Monitor() 
    1719        self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 100, (0, 0, 255))) 
    18         self.monitor.add_field(pyxoo.utils.monitor.ParticleField(1000, (255,0,0))) 
     20        self.monitor.add_field(pyxoo.utils.monitor.ParticleField(3000, (255,0,0))) 
    1921        self.monitor.start() 
    2022        self.all_sprites = pygame.sprite.RenderPlain((self.monitor)) 
    2123         
    2224        initializer = pyxoo.particle.initializer.StackInitializer() 
    23         initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Dot, 2)) 
     25        initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Star, 5)) 
    2426        initializer.append(pyxoo.particle.initializer.LifeInitializer(3000, 1000)) 
    25         initializer.append(pyxoo.particle.initializer.ExplosionInitializer(200, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
     27        #initializer.append(pyxoo.particle.initializer.ExplosionInitializer(400, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
     28        initializer.append(pyxoo.particle.initializer.ExplosionInitializer(400, pyxoo.structure.Range(math.pi*-.25, math.pi*.25), 50)) 
    2629         
    2730        action = pyxoo.particle.action.StackAction() 
    2831        action.append(pyxoo.particle.action.LifeAction()) 
    2932        action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(0,90))) 
    30         action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(30,0))) 
     33        #action.append(pyxoo.particle.action.ForceAction(pyxoo.structure.Point(50,0))) 
    3134        action.append(pyxoo.particle.action.FrictionAction(.995)) 
    3235        action.append(pyxoo.particle.action.MoveAction()) 
    3336         
    3437        renderer = pyxoo.particle.renderer.BitmapRenderer(self.screen) 
    35         emission = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 300, 350 ), 100) 
    3638         
     39        emission = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 300, 5 ), 200) 
    3740        self.system = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
    3841        self.system.emit(emission) 
     42         
     43        emission2 = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 700, 5 ), 200) 
     44        self.system2 = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
     45        self.system2.emit(emission2) 
     46         
     47        emission3 = pyxoo.particle.emission.ByRateEmission(pyxoo.particle.DisplayObjectParticle, pyxoo.structure.Point( 1100, 5 ), 200) 
     48        self.system3 = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
     49        self.system3.emit(emission3) 
    3950 
    4051    def update(self): 
  • project/trunk/example/particle/mouse_gravity.py

    r34 r35  
    11 
    22 
    3 import pygame, pyxoo, math, random, os 
     3import pygame, pyxoo, math, random, os, sys 
    44 
    55from pyxoo.particle import DisplayObjectParticle 
    66from pyxoo.structure import Point 
    77 
    8 RESOLUTION = 640, 48
     8RESOLUTION = 1680, 105
    99COLOR = 0,255,255 
    1010 
    1111class App(pyxoo.engine.Application): 
    1212    def init(self): 
    13         os.environ["SDL_VIDEODRIVER"] = "quartz" 
     13        if sys.platform == "win32": 
     14            os.environ["SDL_VIDEODRIVER"] = "windib" 
    1415        pygame.init() 
    15         self.screen = pygame.display.set_mode(RESOLUTION, pygame.HWSURFACE
     16        self.screen = pygame.display.set_mode(RESOLUTION,pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.FULLSCREEN, 32
    1617        self.bg = pygame.Surface(self.screen.get_size()).convert() 
    1718        self.input_dispatcher.add_event_listener(pyxoo.event.onQuitEVENT, self.onQuit) 
     19        self.input_dispatcher.add_event_listener(pyxoo.event.onKeyboardKeyDownEVENT, self.onQuit) 
    1820         
    1921        self.monitor = pyxoo.utils.monitor.Monitor() 
    20         self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 100, (0, 0, 255))) 
     22        self.monitor.add_field(pyxoo.utils.monitor.FPSField(self.clock, 300, (0, 0, 255))) 
    2123        self.monitor.add_field(pyxoo.utils.monitor.ParticleField(1000, (255,0,0))) 
    2224        self.monitor.start() 
     
    2426         
    2527        initializer = pyxoo.particle.initializer.StackInitializer() 
    26         initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Dot, 15)) 
     28        initializer.append(pyxoo.particle.initializer.ImageClassInitializer(pyxoo.displayobject.Star, 5)) 
    2729        initializer.append(pyxoo.particle.initializer.LifeInitializer(3000, 1000)) 
    28         initializer.append(pyxoo.particle.initializer.ExplosionInitializer(3, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
     30        #initializer.append(pyxoo.particle.initializer.ExplosionInitializer(3, pyxoo.structure.Range(math.pi-.1, math.pi+.1), 50)) 
     31        initializer.append(pyxoo.particle.initializer.BoxInitializer(self.screen.get_rect())) 
     32         
    2933         
    3034        action = pyxoo.particle.action.StackAction() 
     35        action.append(pyxoo.particle.action.MouseGravity(120, 100)) 
     36        action.append(pyxoo.particle.action.BoundingBox(Point(0,0), Point(RESOLUTION[0], RESOLUTION[1]))) 
     37        #action.append(pyxoo.particle.action.MutualGravity(500, 10)) 
     38        action.append(pyxoo.particle.action.SpeedLimit(150)) 
    3139        action.append(pyxoo.particle.action.MoveAction()) 
    32         action.append(pyxoo.particle.action.MouseGravity(120, 100)) 
    3340         
    3441        renderer = pyxoo.particle.renderer.BitmapRenderer(self.screen) 
    35         emission = pyxoo.particle.emission.FixedCountEmission(DisplayObjectParticle, Point( 300, 350 ), 4
     42        emission = pyxoo.particle.emission.FixedCountEmission(DisplayObjectParticle, Point( 300, 350 ), 30
    3643         
    3744        self.system = pyxoo.particle.system.SimpleParticleSystem(initializer, action, renderer) 
  • project/trunk/src/pyxoo/displayobject.py

    r34 r35  
    11 
    22 
    3 import pygame 
     3import pygame, math, pyxoo 
     4from pyxoo.structure import Point 
    45 
     6_BLACK = pygame.Color('black') 
     7_WHITE = pygame.Color('white') 
    58      
    6 def get_color_key(color): 
    7     if color == (0, 0, 0)
    8         return (255, 255, 255) 
     9def _get_color_key(color): 
     10    if color == _BLACK
     11        return _WHITE 
    912    else: 
    10         return (0, 0, 0) 
     13        return _BLACK 
     14     
     15def _add_radius(radius, point): 
     16    point.x += radius 
     17    point.y += radius 
     18    return point 
    1119 
    1220 
    1321class SurfaceWithColorKey(pygame.Surface): 
    14     def __init__(self, size, color_key=(0, 0, 0)): 
     22    def __init__(self, size, color_key=_BLACK): 
    1523        pygame.Surface.__init__(self, size) 
    16         if color_key != (0, 0, 0)
     24        if color_key != _BLACK
    1725            self.fill(color_key) 
    1826        self.set_colorkey(color_key, pygame.RLEACCEL) 
     
    2028 
    2129class Dot(SurfaceWithColorKey): 
    22     def __init__(self, radius, color=(255, 255, 255)): 
    23         SurfaceWithColorKey.__init__(self, (radius*2, radius*2), get_color_key(color)) 
     30    def __init__(self, radius, color=_WHITE): 
     31        SurfaceWithColorKey.__init__(self, (radius * 2, radius * 2), _get_color_key(color)) 
    2432        pygame.draw.circle(self, color, (radius, radius), radius) 
     33         
     34 
     35class Star(SurfaceWithColorKey): 
     36    def __init__(self, radius, color=_WHITE, width=1): 
     37        SurfaceWithColorKey.__init__(self, (radius * 2, radius * 2), _get_color_key(color)) 
     38        rot_step = math.pi / 5.0 
     39        inner_radius = radius * math.cos(rot_step * 2) 
     40        half_pi = math.pi * 0.5 
     41         
     42        points = list() 
     43        points.append((radius, 0)) 
     44        points.append(_add_radius(radius, Point.polar(inner_radius, rot_step - half_pi)).to_sequence()) 
     45        points.append(_add_radius(radius, Point.polar(radius, 2 * rot_step - half_pi)).to_sequence()) 
     46        points.append(_add_radius(radius, Point.polar(inner_radius, 3 * rot_step - half_pi)).to_sequence()) 
     47        points.append(_add_radius(radius, Point.polar(radius, 4 * rot_step - half_pi)).to_sequence()) 
     48        points.append(_add_radius(radius, Point.polar(inner_radius, 5 * rot_step - half_pi)).to_sequence()) 
     49        points.append(_add_radius(radius, Point.polar(radius, 6 * rot_step - half_pi)).to_sequence()) 
     50        points.append(_add_radius(radius, Point.polar(inner_radius, 7 * rot_step - half_pi)).to_sequence()) 
     51        points.append(_add_radius(radius, Point.polar(radius, 8 * rot_step - half_pi)).to_sequence()) 
     52        points.append(_add_radius(radius, Point.polar(inner_radius, 9 * rot_step - half_pi)).to_sequence()) 
     53        pygame.draw.polygon(self, color, points, width) 
     54         
  • project/trunk/src/pyxoo/engine.py

    r34 r35  
     1import pyxoo, pyxoo.event, pygame 
    12 
    2  
    3  
    4 import pyxoo, pyxoo.event 
    5  
    6  
    7  
    8  
    9 import pygame 
     3__version__ = pyxoo.__version__ 
     4__licence__ = pyxoo.__licence__ 
     5__url__     = pyxoo.__url__ 
     6__author__  = "Alexis Couronne" 
    107 
    118 
    129class Application: 
    13  
    14      
    1510    def __init__(self, max_fps=0, flip_method=pygame.display.flip): 
    1611        self.input_dispatcher = pyxoo.event.InputDispatcher() 
  • project/trunk/src/pyxoo/particle/action.py

    r34 r35  
    55 
    66class ActionStrategy: 
     7    def set_system(self, system): 
     8        pass 
     9     
     10    def get_system(self): 
     11        pass 
     12     
    713    def prepare_action(self, time): 
    814        pass 
     
    1420class AbstractAction(ActionStrategy): 
    1521    _time_step = None 
     22    def set_system(self, system): 
     23        self._system = system 
     24         
     25    def get_system(self): 
     26        return self._system 
     27     
    1628    def prepare_action(self, time): 
    1729        self._time_step = time / 1000.0 
     
    2537 
    2638 
    27 class StackAction(ActionStrategy, list): 
     39class StackAction(ActionStrategy, list):     
     40    def set_system(self, system): 
     41        self._system = system 
     42        for action in self: 
     43            action.set_system(system) 
     44 
     45    def get_system(self): 
     46        return self._system 
     47     
    2848    def prepare_action(self, time): 
    2949        for action in self: 
     
    4969             
    5070 
    51 class _SineData: 
    52     def __init__(self, position, sine=0, amplitude=1, frequency=1, direction=None): 
    53         self.position = position 
    54         self.sine = sine 
    55         self.amplitude 
    56         self.frequency = frequency 
    57         self.direction = direction 
    58          
    59           
    60 class SineMoveAction(AbstractAction): 
    61     def __init__(self, direction, amplitude=0, frequency=1, random_start=0, random_direction=0, random_amplitude=0, random_frequency=0): 
    62         self._data = dict() 
    63         self._direction = direction 
    64         self._amplitude = amplitude 
    65         self._frequency = frequency * math.pi * 2 
    66         self._random_start = random_start 
    67         self._random_direction = random_direction 
    68         self._random_amplitude = random_amplitude 
    69         self._random_frequency = random_frequency * math.pi * 2 
    70          
    71     def process(self, particle): 
    72         if particle not in self._data: 
    73             self._data[particle] = _SineData(particle.position.clone(), ) 
    74             #TODO: a finir 
    75         particle.last_position.x = particle.position.x 
    76         particle.last_position.y = particle.position.y 
    77         data = self._data[particle] 
    78         pos  = data.position 
    79         norm = data.direction.clone() 
    80         #TODO: PointUtils.scale( norm, data.amplitude * Math.sin( data.sine ) ); 
    81         pos.x += particle.velocity.x * self._time_step 
    82         pos.y += particle.velocity.y * self._time_step 
    83         particle.position = pos + norm 
    84         data.sine += data.frequency *self._time_step 
    85          
     71#class _SineData: 
     72#    def __init__(self, position, sine=0, amplitude=1, frequency=1, direction=None): 
     73#        self.position = position 
     74#        self.sine = sine 
     75#        self.amplitude 
     76#        self.frequency = frequency 
     77#        self.direction = direction 
     78#         
     79#          
     80#class SineMoveAction(AbstractAction): 
     81#    def __init__(self, direction, amplitude=0, frequency=1, random_start=0, random_direction=0, random_amplitude=0, random_frequency=0): 
     82#        self._data = dict() 
     83#        self._direction = direction 
     84#        self._amplitude = amplitude 
     85#        self._frequency = frequency * math.pi * 2 
     86#        self._random_start = random_start 
     87#        self._random_direction = random_direction 
     88#        self._random_amplitude = random_amplitude 
     89#        self._random_frequency = random_frequency * math.pi * 2 
     90#         
     91#    def process(self, particle): 
     92#        if particle not in self._data: 
     93#            self._data[particle] = _SineData(particle.position.clone(), ) 
     94#            #TODO: a finir 
     95#        particle.last_position.x = particle.position.x 
     96#        particle.last_position.y = particle.position.y 
     97#        data = self._data[particle] 
     98#        pos  = data.position 
     99#        norm = data.direction.clone() 
     100#        #TODO: PointUtils.scale( norm, data.amplitude * Math.sin( data.sine ) ); 
     101#        pos.x += particle.velocity.x * self._time_step 
     102#        pos.y += particle.velocity.y * self._time_step 
     103#        particle.position = pos + norm 
     104#        data.sine += data.frequency *self._time_step 
     105#         
    86106 
    87107class MoveAction(AbstractAction): 
     
    177197        PonctualForceAction.process(self, particle) 
    178198 
    179          
    180 #class MouseGravity(AbstractAction): 
    181 #    def __init__(self, power, epsilon=100): 
    182 #        self._power = power 
    183 #        self.set_epsilon(epsilon) 
    184 #         
    185 #    def set_epsilon(self, epsilon): 
    186 #        self._epsilon = epsilon * epsilon 
    187 #         
    188 #    def get_epsilon(self): 
    189 #        return self._epsilon 
    190 #     
    191 #    def set_power(self, power): 
    192 #        self._power = power * 10000 
    193 #         
    194 #    def get_power(self): 
    195 #        return self._power 
    196 #     
    197 #    def process(self, particle): 
    198 #        mouse_x, mouse_y = pygame.mouse.get_pos() 
    199 #        x, y = mouse_x - particle.position.x, mouse_y - particle.position.y 
    200 #        dsq = x * x + y * y 
    201 #        if dsq != 0: 
    202 #            d = math.sqrt(dsq) 
    203 #            if dsq < self._epsilon: 
    204 #                dsq = self._epsilon 
    205 #            factor = (self._power * self._time_step) / (dsq*d) 
    206 #            particle.velocity.x += x * factor 
    207 #            particle.velocity.y += y * factor 
    208          
     199 
     200class BoundingBox(AbstractAction): 
     201    def __init__(self, position, size): 
     202        self._position = position 
     203        self._size = size 
     204         
     205    def process(self, particle): 
     206        if particle.position.x > self._position.x + self._size.x: 
     207            particle.velocity.x *= -1 
     208            particle.position.x = self._position.x + self._size.x 
     209        elif particle.position.x < self._position.x: 
     210            particle.velocity.x *= -1 
     211            particle.position.x = self._position.x 
     212             
     213        if particle.position.y > self._position.y + self._size.y: 
     214            particle.velocity.y *= -1 
     215            particle.position.y = self._position.y + self._size.y 
     216        elif particle.position.y < self._position.y: 
     217            particle.velocity.y *= -1 
     218            particle.position.y = self._position.y 
     219 
     220 
     221class MutualGravity(AbstractAction): 
     222    def __init__(self, force_radius=0, force_strength=0): 
     223        self.set_force_radius(force_radius) 
     224        self.set_force_strength(force_strength) 
     225 
     226    def set_force_radius(self, force_radius): 
     227        self._force_radius = force_radius 
     228         
     229    def get_force_radius(self): 
     230        return self._force_radius 
     231     
     232    def set_force_strength(self, force_strength): 
     233        self._force_strength = force_strength 
     234         
     235    def get_force_strength(self): 
     236        return self._force_strength 
     237     
     238    def process(self, particle): 
     239        for other in self._system.get_particles(): 
     240            if other != self: 
     241                force = particle.position - other.position 
     242                dist_length = force.get_length() 
     243                if dist_length <= self._force_radius: 
     244                    l = self._force_strength * self._time_step 
     245                    try: 
     246                        force.normalize(l) 
     247                    except: 
     248                        pass 
     249                    particle.velocity -= force 
     250                     
     251                     
     252class SpeedLimit(AbstractAction): 
     253    def __init__(self, speed, is_minimum=False): 
     254        self.set_speed(speed) 
     255        self.set_is_minimum(is_minimum) 
     256         
     257    def is_minimum(self): 
     258        return self._is_minimum 
     259     
     260    def set_is_minimum(self, is_minimum): 
     261        self._is_minimum = is_minimum 
     262         
     263    def get_speed(self): 
     264        return self._speed 
     265     
     266    def set_speed(self, speed): 
     267        if speed < 0: 
     268            speed = 0 
     269        self._speed = speed 
     270        self._speed_sqrt = speed * speed 
     271         
     272    def process(self, particle): 
     273        speed_sq = particle.velocity.x * particle.velocity.x + particle.velocity.y * particle.velocity.y; 
     274        if ( self._is_minimum and speed_sq < self._speed_sqrt ) or ( not self._is_minimum and speed_sq > self._speed_sqrt ): 
     275            scale = self._speed / math.sqrt( speed_sq ) 
     276            particle.velocity.x *= scale 
     277            particle.velocity.y *= scale 
     278 
     279 
  • project/trunk/src/pyxoo/particle/initializer.py

    r34 r35  
    2727         
    2828    def initialize(self, particle): 
    29         particle.max_life = self._life + round( random.random() * self._rand - self._rand / 2
     29        particle.max_life = self._life + round(random.random() * self._rand - self._rand / 2
    3030 
    3131 
     
    3535         
    3636    def initialize(self, particle): 
    37         particle.last_position.x = particle.position.x = self._area.x + random.random() * self._area.width 
    38         particle.last_position.y = particle.position.y = self._area.y + random.random() * self._area.height 
     37        particle.last_position.x = particle.position.x = self._area.left + random.random() * self._area.width 
     38        particle.last_position.y = particle.position.y = self._area.top + random.random() * self._area.height 
    3939 
    4040 
     
    4747         
    4848    def initialize(self, particle): 
    49         #TODO: A implementer 
    50         pass 
     49        p = self._segment.clone() 
     50        p.scale(random.random()) 
     51        particle.last_position.x = particle.position.x = self._a.x + p.x + pyxoo.structure.random_balance(self._rand) 
     52        particle.last_position.y = particle.position.y = self._a.y + p.y + pyxoo.structure.random_balance(self._rand) 
     53 
    5154     
    5255 
     
    9194         
    9295    def initialize(self, particle): 
    93         particle.image = self._image(*self._args) 
     96        particle.image = self._image(*self._args).convert() 
  • project/trunk/src/pyxoo/particle/renderer.py

    r34 r35  
    3030        self._canvas.lock() 
    3131        for particle in particles: 
    32             self._canvas.set_at(particle.position.to_sequence(), particle.color
     32            pygame.draw.rect(self._canvas, particle.color, pygame.Rect(particle.position.to_sequence(), (1,2))
    3333        self._canvas.unlock() 
    3434         
  • project/trunk/src/pyxoo/particle/system.py

    r34 r35  
    111111    def set_action(self, action): 
    112112        self._action = action 
     113        self._action.set_system(self) 
    113114         
    114115    def get_action(self): 
  • project/trunk/src/pyxoo/structure.py

    r34 r35  
    33__version__ = pyxoo.__version__ 
    44__licence__ = pyxoo.__licence__ 
    5 __url__     = pyxoo.__url__ 
    6 __author__ = "Alexis Couronne" 
     5__url__ = pyxoo.__url__ 
     6__author__ = "Alexis Couronne" 
    77 
    88import math, random 
    99 
    1010def distance(p1, p2): 
    11     return math.sqrt(((p2.x-p1.x)**2) + ((p2.y-p1.y)**2)) 
     11    return math.sqrt(((p2.x - p1.x) ** 2) + ((p2.y - p1.y) ** 2)) 
    1212 
    1313def random_range(range): 
    1414    return range.min + random.random() * (range.max - range.min) 
    1515 
     16def random_balance(value): 
     17    return random.random() * value + value / 2 
    1618 
    1719class Point: 
     
    2325     
    2426    def __str__(self): 
    25         return '<Point (%d, %d)>'%(self.x, self.y) 
     27        return '<Point (%d, %d)>' % (self.x, self.y) 
    2628     
    2729    def __repr__(self): 
     
    2931     
    3032    def __add__(self, other): 
    31         return Point(self.x+other.x, self.y+other.y) 
     33        return Point(self.x + other.x, self.y + other.y) 
    3234         
    3335    def __sub__(self, other): 
    34         return Point(self.x-other.x, self.y-other.y) 
     36        return Point(self.x - other.x, self.y - other.y) 
    3537     
    3638    def get_length(self): 
     
    4749        self.x *= value 
    4850        self.y *= value 
     51         
     52    @staticmethod 
     53    def polar(length, angle): 
     54        return Point(length * math.cos(angle), length * math.sin(angle)) 
    4955         
    5056    def clone(self): 
     
    7379     
    7480    def __str__(self): 
    75         return "<Range(%d, %d)>"%(self.min, self.max) 
     81        return "<Range(%d, %d)>" % (self.min, self.max) 
    7682     
    7783 
     
    94100        self.a = math.cos(rad) 
    95101        self.b = math.sin(rad) 
    96         self.c = -math.sin(rad) 
     102        self.c = - math.sin(rad) 
    97103        self.d = math.cos(rad) 
    98104