Changeset 69:e4089417766e


Ignore:
Timestamp:
Apr 3, 2011, 9:25:48 PM (9 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Message:

FPS counter and tile sprite layering.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • scripts/level-editor

    r54 r69  
    2727    level_surface = level.get_surface()
    2828    position = [0, 0]
    29     fps = 0
     29    fpss = [FRAMERATE]
    3030    while True:
    3131        events = pygame.event.get()
     
    6161        tilepos = (position[0] // 64, position[1] // 64)
    6262        text = Text("Level: %s.\nOffset: %r Tile: %r\nFPS: %.1f"
    63                     % (levelname, position, tilepos, fps),
     63                    % (levelname, position, tilepos, sum(fpss)/len(fpss)),
    6464                    color='white')
    6565        text.draw(screen_surface, (10, 10))
    6666
    6767        pygame.display.flip()
    68         fps = 1000 / clock.tick(FRAMERATE)
     68        fpss = (fpss + [1000 / clock.tick(FRAMERATE)])[-FRAMERATE:]
    6969
    7070def main():
  • skaapsteker/level.py

    r65 r69  
    11import json
    22
    3 from pygame import Rect, Surface, constants
     3from pygame import Rect, Surface
    44from pygame.sprite import Group
    55from pygame.locals import SRCALPHA, HWSURFACE
    66
    7 import data
    8 from sprites import enemies
    9 from sprites.base import TILE_SIZE, find_sprite, Geography
     7from skaapsteker import data
     8from skaapsteker.constants import Layers
     9from skaapsteker.sprites import enemies
     10from skaapsteker.sprites.base import TILE_SIZE, find_sprite, Geography
    1011
    1112
     
    3738
    3839
    39     def tile_factory(self, image_name, floor=False, block=False, foreground=False):
     40    def tile_factory(self, image_name, floor=False, block=False, layer=Layers.BACKGROUND):
    4041        image = data.load_image(self.dirname + '/' + image_name)
    4142        def _tilefac(pos):
     
    4344            tile.block = block
    4445            tile.floor = floor
    45             tile.foreground = foreground
     46            tile._layer = layer
    4647            return tile
    4748        return _tilefac
Note: See TracChangeset for help on using the changeset viewer.