Sunday, December 11, 2011

Lack of updates

Sorry for the lack of updates ! But I have a reason. In one of my classes our teacher gave us an open assignment. He told us to learn asp.net MVC3 and make a project with it. Anything. So my team and I decided to make a browser game. It's called Battle For Lurnia (very original) and it's going to be very simple. Players register on the server and create characters who then fight between themselves for Xp and maybe gold. I'll post a link to the repository when it will be more tidy in there.

Monday, November 14, 2011

Progress !

Nothing beat fresh new progress ! Phase one complete, I've got my zone. It's not great but it works. But images speaks better than words so here goes :

This is the first try at my basic grid. It's not beautiful yet but at least I can shove things in the screen now. It's made of two classes, a Zone which is a "manager" of Tiles. A manager is a kind of Overlord that watches over the Tiles and assigns them values and executes action. The update and draw method are found here :
What this does is create an array of Tiles and loops through them in the Draw() and Update() method.

The Initialize() method is used to create the instances of Tile and put them in the array. All of this is done by looping through the the rows and then the columns. It's fairly easy but simple once you get the gist of it.

Now I updated it a bit by adding a spritesheet instead of single sprites and the random generation of the map. The functions are found in pictures of course, below :

It loops through the tileValues array(which is the array of integer values representing which tiles to grab from the spritesheet) and puts a random value in it. Then when I draw the tiles, the manager goes through the values in the tileValues and tells the Tile to draw a specific rectangle from the spritesheet.

The result is then :
It's messy but it's cool, I've got a small spritesheet I used in a previous project. I added the cool functionality of randomly changing the map again when enter is pressed. Fun little feature. As always grab a peek at the source here.

Tuesday, November 8, 2011

Title Screen !

Couple of days ago I messed around with Paint.Net because I wanted to have a nice cover for my game, like a splash-screen or a main screen.

It's certainly not final but at least it's a start.


Hehe, it's just an image I took from google image and I added some text. I especially like the font and the contrast with the font color.

I'm also not sure if it's "Nights of Lurnia" or "The Nights of Lurnia". Depending on which one sounds better.

Step one : Map

The first thing on my list if the map so lets get on to it.

And yes ! It`s time for another wonderful diagram :

And then :
Now the map is the first milestone of my little project. As said in my little graph the map is a grouping of classes that I call Tile. They hold a background sprite for the terrain they have room for an NPC or object to occupy the tile. I'm not sure yet if the tile has a reference to objects on top of it or the object on it has a reference to the tile, or both. Loading a sprite on a tile (and thus, loading the whole grid with tiles) is another thing I'm not sure about. My first reflex is to throw an 2d array at it and translate the integer values to images. Lets say :
{ 3, 2 }
{ 3, 1 }
3 is a road, 2 is grass and 1 is water. When the array is sent to the Grid it assigns a sprite depending on the value received. Of course this is a cheapo solution, a better way would be of creating a custom data structure that contains lets say an array of sprites. The way the sprite array is created is by using technique that I didn't figure out yet. Now that the structure is filled with images I send it to the grid at generation or I use a function to replace the current grid and render the grid again to reflect the changes. In the end I think that whatever technique I use I'll have to translate an array to images anyway. The big difference is what I send to the grid. If I send an array the grid needs to do the translation, if not an external module does the translation and send the already constructed structure to the grid and it simply replace the structure with the one I sent. I need an idea.

In my last game I used the array of int technique to create my maps. A simplified version looks like this :
{ 3, 3, 3, 1, 3, 3, 3, 3, 3,
   3, 3, 3, 1, 3, 3, 3, 3, 3,
   2, 2, 2, 1, 3, 3, 3, 3, 3,
   2, 2, 2, 1, 3, 3, 3, 3, 3,
   2, 2, 2, 1, 1, 1, 1, 1, 1,
   3, 3, 3, 3, 3, 3, 3, 3, 3,
   3, 3, 3, 3, 3, 3, 3, 3, 3 }

It looks pretty simple, lets say the 1's are roads, 3's are grass and 2's represent water. Just by looking at the array you can see a rough outline on how the map will look. Road starts from north goes to the center of the map next to a little pond and veers right to the east. The problem comes from the fact that there might be a hundred of sprites used and I need a number for each. After a while the map might look like this :
{ 33, 33, 33, 2, 33, 33, 33, 33, 33,
  103, 3, 3, 2, 33, 33, 33, 33, 33,
  6, 3, 3, 2, 33, 33, 33, 33, 88,
  33, 33, 33, 2, 33, 33, 33, 33, 33,
  46, 45, 9, 2, 2, 2, 2, 2, 2,
  33, 33, 33, 33, 33, 33, 33, 33, 33,
  33, 33, 33, 33, 33, 33, 33, 33, 33 }

Thats pretty much the same map as above exept I added a house and replaced the lake by a river. Can you make sense of this array now ? Not me, at least not with a quick glance. Last time I ended my project by trying to create a program, some kind of map-editor, on which I placed tiles and I it returned the array that I could copy & paste on my game and use. This was a semi-good idea in the sense that it kind of worked but it was a pain to create the external program and it took my attention off of the main project.

*Idea*
One way I could use is to create a .png of the map and import it to my game, the game will now take this image and turn it into a instance of a Grid readily available. Pros and Cons are:
Pros :
It's fairly easy to create a map in paint.
Importing it is extremely easy and fast.
Cons :
I need to make a custom content importer.
I need to make sure the map is 32 * MapSize.X and the tiles need to be spaced exactly on the right spot or the content importer will get the wrong tiles. For example if the first tile is at (0,0) and 32 in size, the tile to the right of it needs to be placed exactly at (33, 0) or I'll lose part of the tile. If my hand slips and I place the tile at (32, 0) I'll lose the one line of pixel. When the content importer takes the image and divide it by blocks of 32x32 it will not grab the right tiles, like everything's going to be offset by one pixel.

In the end I think I''ll try it, for lack of a better idea.

Monday, November 7, 2011

The man, the plan and the plan and the plan and more plans.

Since I want to do things the right way, I decided that the planning phase would take a greater amount of time this time than my usual projects. It's been 3 days since I started this project and I still haven't started programming. I think this is a new record.

I made a small Dev plan and here is what's included :


  1. Generate a map
  2. Make a character
  3. Create the camera system
  4. Implement movement
  5. Make NPC's
  6. Give properties to the tiles
  7. Integrate actions, that is actions you can execute on tiles or NPC's
  8. Start generating screens. The intro, the game scene, options...
  9. Make character screens, inventory/map.
I might shuffle things around so be prepared for an edit. Or just another post. 

Saturday, November 5, 2011

The tools I will use

Since my new project is starting and I aim to start it the right foot. The right foot being planning before jumping down in the mud. In this post I will document some of the tools I will be using during development. The list might grow and I probably will make another post in the end[sic] explaining the tools I ended up using after all.

First and most important : The very humble and well respected Visual Studio

It's simply the best IDE I've ever used. First because it is very complex (which I like) and when you get to know it it is very easy to use. The IDE really completes the programmer, IntelliSense works like a charm. You can also add extensions which can be very useful. In the screenshot above you can see I'm using ReSharper, this extension is a little manager that looks at your code and gives you advice on how you can optimize your code. It's a really good extension and really helps me when I need to refactor a piece of code or make it more readable. Check it out here, unfortunately it's a paid product and you need to pay a hefty sum to use it. I only have 8 days left on my trial, after that I'll have to get back to normal.

ZScreen, the screenshot application.

ZScreen is a very good application when you need to take screenshots on the fly. You don't need to press print screen and open paint, paste it and modify it. Just press the a hotkey and it will execute what commands you told him to do. I chose to save it automatically in a folder when I press [prt scrn] so I can browse my screenshots of the day and modify them. In the end, they probably get sent on this blog ! It's freeware so I encourage you all to give it a try.

GitHub and GitExtension

As you all probably know I usually use Git as my preferred source control provider. It's really useful to have a repository of code on projects, even the smallest ones, because it gives you an overview on what has been done and how. Having a complete history of the project's changes is awesome and being able to revert back any changes is always useful. I don't need to comment 200 lines of code just because I don't need it or might need it in the future. I can safely erase it and get it back from the repository when I need that piece of code.

Github is a host server of repositories and GitExtensions is my GUI of choice. I can see the timeline very clearly and any branches can be inspected at ease.

So there we go, those are the tools I plan on using immediately. Among them, not tools but technologies I should mention is that I am using C# now with the XNA framework. This makes creating games much easier and streamlined. Big change from vb.net I know, but it's for the best. Giving visual basic up was one of the best decisions I could have made. So keep up with me, I'll try to make the code as easy to follow as I can.

The makings of a new game

I've always wanted to make games, couple of years back when I was programming with VB.net I started to make a small RPG. It was just a small practice project because I wanted to build something much bigger but it was a start. Back then I didn't really fully understand the task at hand and I believe now I know enough stuff to create one damn game. Simple or not I'm ready for it, so here I am launching myself headfirst into another time-consuming, probably useless in the long run and a project that will probably be abandoned in a few weeks. why do it then you ask me ? Well theres always the off-chance that I will actually push it further this time and I believe it is a worthy endeavor. So wish me luck !

Also, this time I'll try to take more pictures alongside my work. I'll try to better document my work, I think it helped last time.