This is the third post of my Fondusi’s Development Blog. Click here to check out the previous post or start at the beginning.

Week 2 – August 8th – 14th

The second week of development was spent reorganizing the map editor and fleshing out more-or-less how we wanted it to look and function. We added a basic pixel shader effect file and changed how players move across tiles.

2D Pixel Shader

I’ve never used HLSL before and it took me some time to find a working pixel shader that didn’t include a vertex shader as well. Fortunately, I found this site which outlined some neat effects and a simple pixel shader with no vertex shader code. Using this and some other tutorials I found, I managed to put together a pixel shader that accepts two colour’s as parameters. One colour multiplied was multiplied into each pixel, the other colour was added to each pixel. I hooked these colours up to the keyboard and it made it easy to test different colour effects. The original pixel shader code didn’t end up staying in the tile engine, but it was a great start to see how it works.

For anyone looking for a basic pixel (only) shader in HLSL for XNA, here’s a starting point:

Just put this in an effect file, load it into a variable through the LoadContent method and then pass it into the spriteBatch.Begin call (e.g.

).

Player Movement

With the way that the engine is set up, players occupy a specific tile. Originally, when moving between tiles, the players were considered to be on the tile they were moving from. The movement system worked like this:

  1. User presses movement key
  2. Target tile is checked to make sure it’s open
  3. If it’s open, the player in game begins moving onto the new tile (using a pixel offset)
  4. Once the player has fully moved onto the new tile, the player’s actual position is updated to be on that tile.

The problem with this system is that two players could both move onto the same tile at the same time. We changed this so that the player is first moved, and then the opposite offset is applied. Now, a player can move onto a new tile and another player won’t be able to go there before they make it. This also means another player will be able to walk onto the tile a player is moving off of.

The Rest

That’s about everything that went on this week. The rest of the changes are listed below:

  • Changed how players transfer tiles
  • Added test pixel shader effect file
  • Added the ability to hide individual layers on the controls form
  • Added ability to right click tiles to delete them
  • Added test particle engine
  • Made the camera class static
  • Set up tile behaviours
  • Started work on rain
  • Began loading regions
  • Added a menu to the controls form
  • Added ability to switch between camera and player control
  • Created a map loading list so we can choose what map to edit
  • Added ability to create new maps
  • Re-organized the main map editor class to handle the states a bit better
  • Added eyedropper for selecting a tile already on the map
  • Added block tile editing
  • Added delegate events into the tile engine so we can add custom code from the map editor class

That sums it up. Hopefully I’ll get another post up this week. Week 5 just ended so I have a few more to go before I get caught up. Until next time, program on!