jack: (Default)
[personal profile] jack
Last week I started learning python and seeing if I could code a proof of concept for a tile-based adventure[1] game with a branching undo and redo tree.

So far I'm liking python and pygame a lot :)

I'm slightly embarrassed, I spent essentially all this weekend hacking on it, which is a lot of time, and although a bit was spent on sunshine, shopping, tidying, and replying to emails, I should have made sure a bit more was. And it means that my estimates for "how much work there is to do" are still off. I spent most of the weekend tweaking interface stuff, which now looks quite good but always absorbs a lot of effort.

But hearteningly, I think I'm getting better at leaving stuff in a working state so it's easier to leave it for a bit then pick it up again.

It's surprisingly theraputic to be able to refactor as much as you want without any fixed deadlines, so the code is the way it "ought" to be.

I don't know if the project will actually go anywhere, but for the record, what's complete is:

  • Draw a tile-based map, with walls that obscure tiles behind
  • Placeholder creative commons graphics
  • Different object types (walls and floors don't have pop-up menus, pickable objs can be moved, etc)
  • Room description file (with initial layout, initial objects, rules, etc as a simple python file, so most stuff is pre-included, but you can add one-off object logic if you like)
  • Hover the mouse over an object for 200ms, and a short description and a context menu appears. It has a list of verbs ("Use lever", "Examine lever") and a list of most recent undoable or redoable action ("Undo use lever")
  • Context menu items are highlgihted as you move the mouse over them. If you click an intransitive verb "Use lever", the verb happens.
  • If you click a transitive verb, "Use bucket with ...", you will get "Use bucket with ..." following your cursor, and when you hover over an object you will see "Use bucket with floor", "Use bucket with plant", "Use bucket with itself", etc. When you click, you will fill in the ... and the verb will happen. (If there's more than one ... it will just fill in the next one.)
  • Default verbs, "move", moves a moveable object to a floor tile on the screen (breaking the paradigm that in order to put an object down, you need a special interactable floor that's sort of a giveaway) and "examine" which displays text which is stored as a property of the object
  • Other actions are defined explicitly in the room definition file, eg. "room.add_rule('use',room.bucket,(room.seedling,room.beanstalk))" means "if the player "use"s the bucket on the seedling, the seedling becomes the beanstalk".
  • These actions are automatically added to the undo tree, though undoing isn't actually implemented yet.



I'm not sure about it, but I decided an object should have four text fields:
- a key, only used to identify it internally, eg. bucket1_water)
- a short description, shown by default, eg. "A leaking bucket of water"
- a name, used in sentences, eg. "Use bucket with plant" (not "Use leaking bucket of water with plant")
- text shown when you specifically examine something, may be empty

I'm not sure if separating those is necessary, but it seemed useful. The short description should include anything which is obvious looking at it, eg. what it says on signs, on the cover of books, what's in the mug, etc. You shouldn't need a special verb to do that. You only need examine when there may be something hidden, and it's ok if examing mundane objects doesn't reveal anything. In normal games, it's frustrating when it says "you don't see anything special", but that's natural if you examine a mug, if you don't usually have to examine everything. And if not, it means it can be a minor puzzle knowing when you _do_ need to.

Likewise, sentences flow more naturally if the short description and name are different.

And what's not done:

  • A main character
  • Scrolling/multiple rooms
  • Fill in rest of graphics
  • Implement undo and redo
  • Script a proof-of-concept puzzle
  • Make sort of distribution so people can run the game on their computer (on windows and linux)

[1] lucas-arts "verb object preposition object" style