Changeset 14:d7f295c06a4b


Ignore:
Timestamp:
Aug 30, 2009, 4:42:44 PM (11 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@15
Message:

Split gameboard screen.

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r12 r14  
    4242        elif events_equal(e, GO_MAIN_MENU):
    4343            return MainMenuState(self.game)
     44        elif e.type is not QUIT:
     45            self.game.gameboard.event(e)
    4446
    4547    def paint(self, screen):
  • gamelib/gameboard.py

    r12 r14  
    11import random
    22
    3 from pgu import tilevid
     3from pgu import gui, tilevid
    44
    55import data
     
    1414        self.tv.tga_load_level(data.filepath('level1.tga'))
    1515
     16        self.tools = tilevid.Tilevid()
     17        self.tools.tga_load_tiles(data.filepath('tiles.tga'), self.TILE_DIMENSIONS)
     18        self.tools.resize((1, 2))
     19        self.populate_toolbar()
     20
     21    def populate_toolbar(self):
     22        self.tools.set((0,0), 2)
     23        self.tools.set((0,1), 3)
     24
     25    def split_screen(self, screen):
     26        leftbar_rect = screen.get_rect()
     27        leftbar_rect.width = self.TILE_DIMENSIONS[0] + 2
     28        main_rect = screen.get_rect()
     29        main_rect.width -= leftbar_rect.width
     30        main_rect.left += leftbar_rect.width
     31        return screen.subsurface(leftbar_rect), screen.subsurface(main_rect)
     32
    1633    def paint(self, screen):
    17         self.tv.paint(screen)
     34        leftbar, main = self.split_screen(screen)
     35        self.tools.paint(leftbar)
     36        self.tv.paint(main)
     37
     38    def update_vid(self, vid, subsurface):
     39        offset = subsurface.get_offset()
     40        return [r.move(offset) for r in vid.update(subsurface)]
    1841
    1942    def update(self, screen):
    20         return self.tv.update(screen)
     43        leftbar, main = self.split_screen(screen)
     44        updates = []
     45        updates.extend(self.update_vid(self.tools, leftbar))
     46        updates.extend(self.update_vid(self.tv, main))
     47        return updates
    2148
    2249    def loop(self):
     
    2653        self.tv.set((x, y), tile)
    2754
     55    def event(self, e):
     56        pass
Note: See TracChangeset for help on using the changeset viewer.