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

Changeset 48

Show
Ignore:
Timestamp:
04/05/08 01:16:08 (8 months ago)
Author:
gak
Message:
 
Location:
muckaround
Files:
1 removed
4 modified
4 copied
1 moved

Legend:

Unmodified
Added
Removed
  • muckaround/blobworld/source/game.py

    r43 r48  
    1414        self.video = Video() 
    1515        self.video.init() 
     16        self.video.window.on_mouse_press = self.on_mouse_press 
    1617 
    1718    def think(self, dt): 
     
    2122    def input(self): 
    2223        self.video.window.dispatch_events() 
    23         x, y = self.video.window._mouse_x, self.video.window._mouse_y 
     24 
     25    def on_mouse_press(self, x, y, button, modifiers): 
     26        self.level.add_blob((x, y), 10) 
    2427 
    2528    def render(self): 
  • muckaround/blobworld/source/level.py

    r43 r48  
    44from pyglet.gl import * 
    55 
     6from blobs import Blob 
    67 
    78class Level(object): 
     
    910    def __init__(self, game): 
    1011        self.game = game 
     12        self.blobs = [] 
    1113 
    1214    def think(self, dt): 
    13         pass 
     15        for b in self.blobs: 
     16            b.think(dt) 
     17 
     18    def add_blob(self, pos, radius): 
     19        b = Blob(pos, radius) 
     20        self.blobs.append(b) 
    1421 
    1522 
     
    2532        glLoadIdentity() 
    2633 
     34        for b in self.blobs: 
     35            b.render() 
     36 
  • muckaround/blobworld/source/video.py

    r43 r48  
    1515        glMatrixMode(GL_PROJECTION) 
    1616        glLoadIdentity() 
    17         glOrtho(0, 800, 600, 0, -1.0, 1.0) 
    18 #        glOrtho(0, 800, 0, 600, -1.0, 1.0) 
     17#        glOrtho(0, 800, 600, 0, -1.0, 1.0) 
     18        glOrtho(0, 800, 0, 600, -1.0, 1.0) 
    1919        glMatrixMode(GL_MODELVIEW) 
    2020 
  • muckaround/blobworld/test.py

    r43 r48  
    1414    game.level = LevelRenderable(game) 
    1515 
     16    last_think = time.time() 
    1617    t = time.time() 
     18    fr = 1. / 30 
    1719    frames = 0 
     20 
     21    for a in xrange(100): 
     22        game.level.add_blob((random.random() * 640, random.random() * 480), 1) 
     23 
    1824    while not game.video.window.has_exit: 
    19         game.think(1) 
     25        while last_think + fr <= time.time(): 
     26            game.think(fr) 
     27            last_think += fr 
    2028        game.input() 
    2129        game.render() 
     
    2432        if frames % 100 == 0: 
    2533            print frames / (time.time() - t) 
     34            t = time.time() 
     35            frames = 0 
     36 
    2637 
    2738if __name__ == '__main__':