Friday, May 26, 2006

jrpg level editor works

The level editor (on the right) is able to load, edit and save maps in the new format supported by jrpg (on the left), so now the world and the story can become much more interesting. The snowy patch visible on both screens has been added from the level editor. The tiles in the editors are still square, I'll port the tile-rounding code later. For now the editor is still only able to edit the tile data. All NPCs, enemies, quests, events, decorations, portals etc. have to be edited from the map_setup_<XXX> functions in jrpg.py So each map is described in 3 places:
  • As entry in World object's map_db hash table
  • In foo.map file
  • In map_setup_foo function
Here are some examples:

# In the world constructor:
self.map_db["angel sanctuary"] = {
  "tiles": self.load_map("angel_sanctuary.map"),
  "setup": lambda: self.map_setup_angel_sanctuary(),
}

# Setup method for the angel sanctuary:
  def map_setup_angel_sanctuary(self):
    def angel_quest():
      if mhc.quest_is_done("reward for level 3"):
        ui.change_text([U"I am guardian angel of software development.",
                        U"I'm impressed that you finished all quests in jrpg.",
                        U"Please send your savefile to its developer,",
                        U"and he is sure to add some new areas ^_^"])
      else:
        ui.change_text([U"I am guardian angel of software development.",
                        U"If you actually finish all quests in jrpg,",
                        U"send the savefile to its developer,",
                        U"and he is sure to add some new areas."])
  self.wormhole((3,0),"world",(35,36))
  self.add_chara("angel-blue",
                 route=[(3,2),(6,2),(7,3),(7,6),(6,7),(3,7),(2,6),(2,3)],
                 event=angel_quest)

# This is how angel_sanctuary.map file looks like:
BBB<BBBBBB
B........B
B........B
B........B
B........B
B........B
B........B
B........B
B........B
BBBBBBBBBB
New jrpg code is slightly slower than the old one, but the different is not that big (at least on my hardware); it's also more or less debugged. The biggest problem and the reason I'm not releasing it yet is that the code assumed things will respawn every time they get out of the players' view. So you just had to walk around the mushroom forest and you'd find all requred mushrooms. In the new code they respawn only after you leave the map, so you'd have to return from the forest to the Elven town every time you want new mushrooms. That would be rather boring. I'll add some sort of respawn code or something and then release the improved jrpg on the jrpg website.

No comments:

Post a Comment