Sections
Timeline
Sub-Sections
Download
Unified Diff
Zip Archive
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

Changeset 46

Show
Ignore:
Timestamp:
04/05/08 00:35:57 (8 months ago)
Author:
gak
Message:
 
Location:
muckaround/cython-getting-started-tutorial
Files:
2 added
1 modified
1 moved

Legend:

Unmodified
Added
Removed
  • muckaround/cython-getting-started-tutorial/main.py

    r44 r46  
    55from pyglet.gl import * 
    66 
    7 from circles import Circle, Circles 
     7from fast_circles import Circle, Circles 
    88 
    99WIDTH = 800 
     
    2626 
    2727    for a in xrange(100): 
    28         circles.add(Circle.new(WIDTH, HEIGHT)) 
     28        circles.add() 
    2929 
    3030    while not win.has_exit: 
  • muckaround/cython-getting-started-tutorial/slow_circles.py

    r45 r46  
    1313        self.dy = dy 
    1414        self.radius = radius 
    15  
    16     @staticmethod 
    17     def new(max_x, max_y): 
    18         """Selects a position, movement and a radius and returns a new Circle 
    19         object with these properties.""" 
    20         rad = random.uniform(5, 10) 
    21         x = random.uniform(rad, max_x - rad) 
    22         y = random.uniform(rad, max_y - rad) 
    23         angle = random.uniform(0, math.pi * 2) 
    24         speed = random.uniform(1, 50) 
    25         dx = math.cos(angle) * speed 
    26         dy = math.sin(angle) * speed 
    27         return Circle(x, y, dx, dy, rad) 
    2815 
    2916    def think(self, dt, max_x, max_y): 
     
    6047        self.max_y = max_y 
    6148 
    62     def add(self, c): 
    63         self.circles.append(c) 
     49    def add(self): 
     50        rad = random.uniform(5, 10) 
     51        x = random.uniform(rad, self.max_x - rad) 
     52        y = random.uniform(rad, self.max_y - rad) 
     53        angle = random.uniform(0, math.pi * 2) 
     54        speed = random.uniform(1, 50) 
     55        dx = math.cos(angle) * speed 
     56        dy = math.sin(angle) * speed 
     57        self.circles.append(Circle(x, y, dx, dy, rad)) 
    6458 
    6559    def think(self, dt):