Reference:FIFE:Minimal:Adding a Character to the Map

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Code reference.png This article covers outdated code reference information!

Code reference articles are stored at the wiki for legacy reasons. They are often outdated and duplicate Epydoc code documentation and department-specific tutorials. Code reference articles need to be reviewed by the programming department to see if they provide any useful information that is not available elsewhere at the wiki. After they have been reviewed and their unique information has been moved to more appropriate articles, the code reference articles should be deleted.


(Note: this article follows on from the earlier turtorials, part 1: Minimal Fife engine: An introduction and part 2: Loading a map and scrolling it around, and is highly recommended that you read those articles first)

The next stage is to add a character to the map that we can control. Once again, we will first have to grab some graphics from the Rio demo, so firstly create this folder structure:

/fife/clients/pdemo/objects/agents/girl

And then copy everything from

/fife/clients/rio_de_hola/objects/agents/girl

into it. We now have all the graphics we need. Our next step is simply to put her into the map, firstly as just another part of the map. We can do this by merely editing the map details, we don't need to touch our code. So grab your trusty text editor and load up map.xml. At the top after the import file line the base sand object, add the following:

	<import file="/objects/agents/girl/object.xml"></import>


Now a bigger addition, scroll down to near the end, after all the sand definitions to find </layer>. We are going to insert a new layer, this time not for the ground but for objects on the ground. Normally I'd use the map editor, but it doesn't seem very user-friendly for this sort of thing. Anyway, insert this XML between the </layer> and the <camera> tags:

	<layer x_offset="0.0" pathing="cell_edges_and_diagonals" y_offset="0.0" grid_type="square" id="Objects" x_scale="0.5" y_scale="0.5" rotation="0.0">
		<instances>
			<i x="0.0" o="girl" z="0.0" y="0.0" r="180"></i>
		</instances>
	</layer>


Now run the code again and this time you should see the map with our sprite going through a simple animation at the centre.

To be continued...

Personal tools