Thursday, 5 July 2012

Defining a game

The way Rye displays a game layout is defined in a text file. Each block or object is defined in the file by a single character. When Rye loads it tries to open a file called default.rye. A rye file can have lots of pages in it. All of the file is read at once, parsed into pages which get stored until a page is displayed. At that point the page is expanded into a specialised object that handles all of the interaction and movement. Rye pages can be different sizes, the original Kye game that inspired Rye had fixed size pages. Having variable sized pages makes the games much more flexible.

I designed a simple start up page. You can see a few different objects on the page but the whole thing gets created with simple lines in a file.  The layout for this page is

A small start
5p G  5p 5
5555e55 55
5T 5 15b55
5be5     5
5    s   5
5        5
5   45v555
5   e e p5

The first line has three parts, Beginner is the name of the page, 10,10 are the width and height of the page. The second line is a hint or message for the page. The size of the remaining section is defined by the width and height. This has 10 lines (height = 10) and each line has 10 characters (width = 10). Each character in this section defines a single block. It is usual to surround the whole page with solid walls, usually the '5' character which is a wall block with square edges. Walls with rounded edges are created with numbers laid out like this:


So, the fourth line has a rounded corner defined by '1' and the eighth line has a rounded wall end which is defined by '4' . Every page must have a 'G' which is Rye and at least one 'p', a prize. You would expect to see one or more beasts, 'T', to increase the jeopardy.

Next we need to load the file and display pages.

No comments:

Post a Comment

Thank you for taking the time to add a comment.

I have decided, regrettably, to review comments before they are published to ensure that offensive or inappropriate comments do not get shown.

Genuine comments are always welcome and will be published as quickly as possible.