Changeset 249:30ae3c681507


Ignore:
Timestamp:
04/07/11 20:20:58 (12 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Doors and stuff.

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • data/levels/level2.json

    r107 r249  
    3131    "enemies": [],
    3232    "sprites": [],
     33    "doorways": [],
    3334    "player": {"pos": [6, 2], "direction": "right"}
    3435}
  • data/levels/level3.json

    r125 r249  
    2121    "enemies": [],
    2222    "sprites": [],
     23    "doorways": [],
    2324    "player": {"pos": [2, 1], "direction": "right"}
    2425}
  • data/levels/level4.json

    r107 r249  
    2222    "enemies": [],
    2323    "sprites": [],
     24    "doorways": [],
    2425    "player": {}
    2526}
  • data/levels/level5.json

    r125 r249  
    3030    "enemies": [],
    3131    "sprites": [],
     32    "doorways": [],
    3233    "player": {}
    3334}
  • data/levels/temple.json

    r240 r249  
    2929        {"type": "RedOni", "pos": [15, 11], "direction": "right" }
    3030    ],
     31    "doorways": [
     32        {"type": "Doorway", "pos": [17, 16], "leadsto": "level2"}
     33    ],
    3134    "player": {"pos": [4, 17], "direction": "right"}
    3235}
  • data/levels/temple_grounds.json

    r240 r249  
    2626        {"type": "RedOni", "pos": [26, 11], "direction": "right" }
    2727    ],
     28    "doorways": [],
    2829    "player": {"pos": [3, 2], "direction": "right"}
    2930}
  • scripts/npc-test

    r246 r249  
    8989
    9090    if len(args) != 1:
    91         p.error("Must provide an npc json file")
     91        parser.error("Must provide an npc json file")
    9292    run(args[0], opts.game)
    9393
  • skaapsteker/engine.py

    r248 r249  
    3434                    return
    3535                if ChangeScene.matches(ev):
    36                     self.change_scene(ev.next_scene)
     36                    next_scene = ev.next_scene
     37                    if not isinstance(next_scene, Scene):
     38                        next_scene = next_scene[0](self.game_state, *(next_scene[1:]))
     39                    self.change_scene(next_scene)
    3740                    break
    3841                self._current_scene.dispatch(ev)
  • skaapsteker/level.py

    r248 r249  
    6161        self.build_tiles()
    6262        self.setup_enemies()
     63        self.setup_doorways()
    6364        self.setup_player(player)
    6465        self._background_music = None
     
    102103            self.enemies.add(enemy)
    103104            self.sprites.add(enemy)
     105
     106
     107    def setup_doorways(self):
     108        self.doorways = LayeredUpdates()
     109        for door_def in self.level_data['doorways']:
     110            doorway = find_sprite(door_def, 'base')
     111            self.sprites.add(doorway)
    104112
    105113
  • skaapsteker/sprites/base.py

    r248 r249  
    44
    55from pygame import Rect
     6import pygame.transform
    67
    78from ..physics import Sprite
     
    264265
    265266
     267
     268class Doorway(GameSprite):
     269    mobile = False
     270    gravitates = False
     271    collides_with = set([PC_LAYER])
     272
     273    image_file = 'torii.png'
     274
     275    debug_color = (120, 240, 120)
     276
     277    def __init__(self, pos, **opts):
     278        GameSprite.__init__(self, pos, **opts)
     279        self._layer = Layers.PLAYER
     280        self.image = pygame.transform.scale(self.image, self.image.get_rect().center)
     281        self.rect = self.image.get_rect(midbottom=self.rect.midbottom)
     282        self.collide_rect = self.rect
     283
     284
     285    def setup(self, leadsto):
     286        self.leadsto = leadsto
     287        print leadsto
     288
     289
     290    def collided_player(self, player):
     291        print "Player touched %s" % self
     292        from .. import engine, levelscene
     293        engine.ChangeScene.post((levelscene.LevelScene, self.leadsto))
     294
     295
     296
    266297def find_sprite(descr, mod_name=None):
    267298    """Create a sprite object from a dictionary describing it."""
  • skaapsteker/widgets/text.py

    r248 r249  
    11# -*- coding: utf-8 -*-
    2 
    3 import collections
    42
    53import pygame
Note: See TracChangeset for help on using the changeset viewer.