Saturday, January 24, 2009

Progress report: Jan 25


I've totally disregarded the goals I outlined for this week. The good news is that I have made progress, and some of the things are pretty cool! Introducing:


XML loading



Pretty much everything is now loaded from XML files. 1 goal achieved. :)


Intelligent tile rendering based on adjacent tiles



No need to specify whether you're defining a top-left corner tile, a bottom tile, etc. The tile engine looks at all adjacent tiles and automatically determines which sprite to render, so I only have to deal with a handful of truly distinct tiles rather than 16 separate sprites for each.


In the absence of a level editor, this makes the grid definition easy to read and to change. Did somebody say ASCII art? Check out the sample definition below.


<TileTemplate
IsLeftSolid="false"
IsTopSolid="true"
IsRightSolid="false"
IsBottomSolid="false"
>
<Acceleration Horizontal="-0.25" />
<TileSize Width="40" Height="40" />
</TileTemplate>

<TileGrid IsActive="true">
<TileSize Width="40" Height="40" />
<GridSize Width="16" Height="9" />
<TileTemplates>
<TileTemplate
Path="Object/Tile/SolidTile"
GridSymbol="1"
/>
<TileTemplate
Path="Object/Tile/PlatformTile"
GridSymbol="-"
/>
<TileTemplate
Path="Object/Tile/WindLeftTile"
GridSymbol="("
/>
<TileTemplate
Path="Object/Tile/WindUpTile"
GridSymbol="^"
/>
</TileTemplates>
<Rows>
<Row Tiles="1111111111111111" />
<Row Tiles="1111000000001111" />
<Row Tiles="1100000110000011" />
<Row Tiles="110(((^110000011" />
<Row Tiles="1--(((^110011001" />
<Row Tiles="1(((((^110000001" />
<Row Tiles="100----110001111" />
<Row Tiles="1000000110000001" />
<Row Tiles="1111111111111111" />
</Rows>
</TileGrid>

Wind



If you were paying attention, you would have noticed that the tile template above includes an Acceleration tag. When a character's position is updated, acceleration from the tile at the center point of that character's position is also applied.


Terrain



In my last progress report, I toyed with the idea of modelling terrain using a very simple technique of enforcing a minimum and maximum height at each point in a level. It is now working, albeit with some limitations.


In order to be able to draw terrain that transitions smoothly from each point to the next, I decided that each terrain would have a fixed number of available increments to choose from, and each of these increments would have an associated sprite. This could mean having to create a lot of sprites, but I'm leaning towards each segment in the terrain being very small (~10 pixels), in which case I shouldn't need more than 10 sprites for every terrain. I'm also planning to use the effect sparingly, partly to limit the amount of art I need to create.


Sound effects



Making sound effects should be a crime. It is ridiculously fun!


Microsoft has a tool called XACT, that can be used for managing sound effects and music. It is the same tool they give to AAA game publishers for the Xbox 360. You don't have to use it, but it gives you a lot of flexibility.


The general approach is that I fire off an audio cue from my code, and the audio system responds with a sound or set of sounds. For example, if I was making a tennis game I might fire off a "HitBall" cue, and the audio system would play the sound of a ball hitting a racquet (and possibly also a grunt, if it was a womens' match).


Where it gets really cool is that you can provide multiple sounds for a single cue, and specify the probability of each sound playing. In testing my code, I had the main character saying "Jump!" whenever he jumped. But very rarely, he would instead yell out "I'm flying!!!". You probably had to be there.


Anyway, here is an example of how to hook in an audio cue to an animation:


<Sprite Name="JumpRight">
<SpriteAnimationFrames>
<SpriteAnimationFrame
Duration="0"
AudioCue="MainCharacterJump"
>
<TextureRegion
Left="0"
Top="50"
Width="50"
Height="50"
/>
<DisplayOffset
Width="-3"
Height="-2"
/>
</SpriteAnimationFrame>
</SpriteAnimationFrames>
</Sprite>


In my code, every sprite is also an animation, so I could create a singing, dancing tile if I wanted to. That might sound silly, but I am considering building a grass tile where the blades of grass slowly sway in the wind.



Here is a short video of some very basic terrain and wind effects:




No comments:

Post a Comment