Archive for python


Posted in story with tags , , , on May 25, 2009 by Tau

I’ve decided to (possibly temporarily, possibly permanently) move away from an isometric view to a top down view. This is because of the dramatic increase in data filed entries, and the time to write them, that it would take for the isometric images. For a rectangular image, it’s a simple affair to decide whether a point (eg. the player) lies within a region which may be solid. If this region becomes a triangle of arbitrary shape and size, as it would be in an isometric case, the points of all of the triangles which make up the region must be stored, and deciding if a point lies with them becomes much more complicated.

This isn’t an unsurmountable problem, just one I feel is not worth tackling at the moment, especially when more efficient advances can be made. With the current code, and assuming a grid like layout of the maps, everything is ready for designing multiple linked maps. Along with the message and conversation classes, a simple, static demo could be written.

So that’s my plan, maybe finishing off the automation classes, and also writing something to make non-player characters move around the map. Then I can have something to show for my work.

Automating Game Events

Posted in code with tags , , , , on May 19, 2009 by Tau

One of the major things that’s been bothering me about the code as I look it over is the amount of hardcoded strings, and the requirement for data files to have a certain format. Previously, the events listed in the maps had to have two arguments because when the list of events was created in memory, both arg1 and arg2 had to be set (there would be an error that the input array was out of range without them) which lead to lots of NULLs in the map files.

I’ve altered this. Now the arguments for game events are filled into an array, rather than private variables, so that any number of arguments may be given. This is also advantageous as future event classes may need more than two arguments.

This being an RPG, there’s going to be a need to automate events; those wonderful parts of the game where the story runs off and the player has to do nothing but press ‘continue’ when they’ve finished reading. So I’ve started a class to manage this. All it does is execute an event, and then wait a given time before executing the next one. This is done with the pygame.time.delay() function. Something like:

for i in range(len(events)):

Although, it’s not finished yet. All the current events have player cancelling built in (like a conversation won’t end until you press ‘q’) which I’ll keep for the time being. Some people read slower than others..

I expect some form of this will be used for the non-player movement on screen eg. village people wandering around. That may be the next area of work for me, although I have started to think about the battle handling. Clearly though, an intensive graphics session is needed.

Isometric Solid Objects – Part 2

Posted in graphics with tags , , , , , on May 5, 2009 by Tau

Returning to the task of making the objects in the map semi-solid. The problem is that I want to draw the sprites as a whole, but define only certain regions as solid. This means I either have to make lots of sub-sprites and combine them, or define a list of regions that are and aren’t solid within each sprite/map object.

More text files to read in, or at least, longer ones.

Each Map Object now references another file which is the image file, this contains a link to the sprite and a list of co-ordinates which are the solid regions within the local co-ordinate system of the map object. These are then scaled to the global (screen) co-ordinates.

So far, all this is read in and the objects created, although they currently aren’t called in anyway. I haven’t gotten my head around how one decides if a given point (i.e the character) lies within a triangular region of undefined shape. Yes, it really shouldn’t be that difficult, I just haven’t got the envelope out to do it yet.

Story Ideas

Posted in Characters, story with tags , , , , on February 21, 2009 by Tau

I’ve been keeping my thoughts on story and characters at the back of my mind for some time, reluctant to write anything down through fear of trivialising the ideas, and because coding is a risk free alternative, which is to say, I can see then and there whether or not my code works; creative attempts can be judged much more subjectively, and can lead to disappointment.

I’ve been thinking about the protagonist, who will, of course, undergo some journey without a defined end, and be forced through trials along the way. Such is the RPG I intended  to make. Why does he/she do all this? It can be Fate, which is an easy way out, or coincidence, that they have some relationship with the events unfolding.

I like the idea that our protagonist is as much like a regular person as can be within the context of the game. They simply get swept along, and are incapable, whether physical or through conscience, to back out.

It is my intention to set the game against the backdrop of a political war between two human nations, a religious war between factions of the main character’s race, and further smaller conflicts. The other playable characters won’t be constant – they will come and go as they follow their own stories, which may themselves be occasionally playable.

Yet, I don’t want to think out loud too much here..

Screen Messages

Posted in code with tags , , , , , on December 21, 2008 by Tau

I’ve just finished the classes for printing messages onto the screen. It’s basically the same as the dialogue classes, but requiring fewer variables: the text is read in from a file given as the argument of the event type “message” and blitted to screen.

Coming back to the code after quite a while has made me realise how much I shouldve commented the first time around. I’m going to go through all the files and properly document them, drawing up a diagram of where all the classes and functions lead.

Isometric Solid Objects

Posted in code with tags , , , , , on August 24, 2008 by Tau

Now I had succeded in making the objects solid, although this worked only so long as said object was supposed to be a rectangle (because the method used the collide() function, checking to see whether the character’s and map object’s rectangles collided). However, with an isometric map the objects are far from recatngular; they’re rather pointy.

Now my plan to solve this is to create another type of input file, for each and every image. This would contain the name of the image file, plus a list of co-ordinates that map out the solid regions of the image. When the map loads, all of these could be fed into an array of solid areas, and the character’s position checked against these whenever it moves.

The code is nearly complete, although so far unchecked. I’ve found debugging tends to scale exponentially with lines of code.

Dialogue – On the Screen

Posted in code with tags , , , , on August 18, 2008 by Tau

Well, kind of. That which used to print in the terminal now appears as ugly text in an ugly blue box on the screen, and disappears when the conversation finishes. I moved the construction of the screen window to an external class that as a Get Screen function, which can be called by any other class, and thus drawn onto by any other class. It means all sorts of goodies can now be drawn whilst the main loop is running, such as dialogue, messages and menus. That said, my code is still ugly as sin.

I just need to create an image for the dialogue box to make it a little prettier, and it’ll be done, aside from writing the code for conversations generating gamekeys, by which I mean, for example, speaking with a NPC and getting some information from them allows you to proceed to a new area or whatever.

Next I think a few more events, such as finding items and attribute changes, and then really get going with the sprites, at least in order to finish this village and work towards some form of simple, wander around demo.