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.

Thursday, May 5, 2011

Turns out SQL server is awesome.



So I was introduced to databases earlier on this semester. The teacher started us with Oracle SQL. The results are seen on this post here. So yes, not much of an impact on my life. But I decided to start a side project with databases, with MySQL. I made a small login application to register games, never finished but I made the SQL part successfully. From MySQL I was introduced to SQL Server from Microsoft. I dismissed it at first because I thought it was just a jumble of toolbars and another VisualStudio-like application.












Well its not. I messed around with it a bit and I'm amazed. Being a feature crack addict I just can't resist the interface with all its menus and functionality toolbars.

The code editor is great and offers IntelliSense and bla bla, the usual Microsoft development'ish features you would find in any other product. You can schedule publications to subscribers and manage remote servers. 

So there goes my craze placing images. I'd like to get more code sample but with school killing us I won't be coding anything really fun for a while. Just 20 more days and I'm outta there. Can't wait.






Wednesday, May 4, 2011

Back from the dead ! (Again)

Yes I did it again ! I fled the clogging world and now I'm back ! Actually I've taken a detour at tumblr and since it sucked so much here I am again !

I've moved from VB.net to C# and overworked with school. So expect better and rarer posts (at least until school is over) so why do I bother to tell anyone at all ? Nothing really.

Tuesday, February 15, 2011

A small find : Labyrinth algorithms !

I've been looking at this guy's blog and it struck me as extremely interesting. He shows several algorithms to generate mazes, while fairly useful and fun. I don't know how to implement this kind of logic so I am researching hard on the matter. Expect a post about it soon !

Here is the blog I'm talking about, go check it ! http://weblog.jamisbuck.org/2011/2/7/maze-generation-algorithm-recap

Monday, February 7, 2011

Regex are AWESOME

So today in class we`ve seen regular expressions ( widely known as Regex ). They are expressions used to recognize if a piece of code follows a certain pattern. A regex is usually a string of character representing the expression. Regex'es are language agnostic, meaning they will work with whatever language you are using provided it uses the right libraries.

A regex looks like this : "^[a-z]\d[a-z][\s-]?\d[a-z]\d$" .
This particular regex is used to check a string to see if it represent a canadian postal code (they look like this H2Y 8D7 with a space, dash or nothing in the middle).

How does it works ? Like this : A regular expression is filled with special alphanumeric characters and symbols. How you place these characters determines how the target string will be evaluated. Rather like programming languages with keywords and expressions.

The first set of symbols is the [a-z] interval. An interval is used to represent any value comprised between those two. In this instance I mean any lowercase letter between a to z.

The second set of symbol is \d . \d is a pre-defined character. It means whatever numeric character. It is the same as [0-9] but shorter. Then is another a to z interval. These three expressions are used to check for the first three characters of the targeted string. The last three is checked the same way.

A simple problem we are faced is the middle space, or the absence of it. Indeed we have to check that the fourth character is a space, dash or nothing. Several operators are used to check occurrences of several characters.

  • * : The asterisk is used to check 0, 1 or several occurrences of the previous character. A* will return true to A, AA, AAA, AAAA and basically every A in the text.
  • + : The plus sign is used to check 1 or several occurrences of the previous character (or expression between brackets [ ] a "class" ).  H+ will return true to HH, HHH and every other series of two consecutive H. Not simply one though.
  • ? : The interrogation mark is used to check 0 or 1 occurrence of the previous class. It will test if a class is there or not. This what we need to test if there is a space, a dash or none.
The expression used to test this condition is [\s-]? . This checks if there is, or not, a white space or a dash. White space being represented by \s.

Lastly, you can see symbols in the first and last position of the regex. These are to make sure the value we check does not contain any other characters before and after the string. The ^ symbol is used at the beginning of an expression to check if the string *starts* with the tested expression and the $ is used at the end to check if it *ends* with the expression. Using both we make sure the tested string starts and ends with our pattern.

An example :
We want to check if a string is a Canadian permanent code. These codes are made of four letters and 8 numbers with spaces(or not) at the 5th and 8th position.

Regular Expression :
^[a-z]{4}[-\s]?\d{4}[-\s]?\d{4}$

Test strings : 
SIGH03129117
DUG712345673
SIGH 0312 9117
SIGH 03129117
SIGH0312 9117
1234DUGH9154

Using the expression above, we can see that the second and last expression does NOT fit and we did that only by checking it against a string of symbols. Much less hassle than going by letter by letter with a loop.

Here is the program I made in class today, it contains many good examples. Available with the .net framework 4, as are the majority of what I do anyway. Don't forget to grab the latest version.

EDIT : Testing a regex can be a pain in the ass. This is why I use a tool, its here if anyone would like to try it. It is an AWESOME regex testing tool and I recommended it to anyone interested. 

Saturday, February 5, 2011

We need a new prog post !

Ok well, since this is a blog about prog and I'm starting on a very boring and prog-less path. So ! My next post is going to be about some programming stuff, still in VB.net because I like it very much and its easy to explain.

Not sure when I'll make another post, probably in less than 6 months though.

First things first : I need a name

OK, I already have a name. MY name, and I'm not using it for this. I need a company/team name. Its not lerouxtechnologies anymore because it has to be a name to represent multiple people, I intend to make this a team. I have a few candidates I can choose from, this should be fun.

I only have a few choices yet :

  • Dragon Roost + Software, Team (Not sure which one yet)
  • Drunk Gamers
  • CodeHackers
  • Team Coders
As you can see the list is quite small, and I did not ask my future teammates about it. I could wait but it could take a while to choose a name we all want. Dragon roost software is my favorite to date, I took it from Zelda : The Wind Waker when I was listening to its soundtrack on ZREO. Its just such a good song.

The trouble of finding a new idea

They say ideas flow miles a second in our head. Thats probably why they get out so fast, and why we can't hold on to one. Its a shame really, having abandoned so many projects and having a hard time finding a new one.

So here I am, in search of an idea. One that I can, hopefully, complete in order to learn the right development process. It has been 272 days since my last post and I have created some many project stubs and samples. So many empty test projects. Of course I learned a lot in programming since then, learned new languages (or at least parts) and concepts. With that I hope to create another project with a tad more complexity, or at least something with fun features.

Also my urge to write some new stuff is growing again. So I'll try post my idea gathering here, maybe a couple posts a week. That'd be fun.