Showing posts with label game creation. Show all posts
Showing posts with label game creation. Show all posts

Sunday, May 9, 2010

Design update !!

Hey, I told you all that I would take my time and post something eventually. Well now is the time !

I have been working on the way my main form looks like. I had a few problems: 
First I wanted to get rid of the ugly conversation panel I have. The idea of a form popping whenever you talk to someone is crap, and having to close it again and again is a pain sometimes. I wanted to have some kind of control that would show messages for me. I have recently learned to make my own custom controls and found the idea of having a portable "messages & communication" box quite good. And here is the control and the code: 

The images speaks for themselves. The messagebar has a sub named addMSG() used to send messages to the textbox. The textbox is readonly to prevent the user disturbing the text and because the keys I use to move are the arrow keys I have made a sub to replace the caret (the little horizontal line standing where you clicked) every time a key is pressed. That way you cannot scroll through the textbox inadvertently when moving, only with the scroll bar. 

I have also begun to look into the code involved in moving around. The same 4 subs ( one for each direction) are both used to move and initiate a transition and I think this is a flawed way of getting around since the complexity is very case-by-case and thus need a lot of if's to verify stupid stuff. Due to the complexity of the overhaul this could take some time but I am still working on other parts while I'm digging around for a better solution. 

I have downloaded some tiles on a website because I don't really have *that* much time on my hand for designing .jpegs, time that could be better used somewhere else. They look good and I plan to make use of them someday to showoff a better version of the game. 

The game now looks thus: 



As you see I have made some subs to handle conversation. Now every sprite has an NPC class that is used to store conversation and other relevant stuff. I'll explain it in a later post. On this note see you all at the next post !


Saturday, April 17, 2010

Blog is NOT dead.

Like I said in an earlier post. I won't be posting a lot these days. I have a shitload of work to do for school and friends to take care of, so the little time I get to program stuff is spent in fruitless attempts to re-engineer my movement system. That or creating sprites or tiles. I'm hoping to be able to post a bit more in the coming weeks, I just need some new material to blog about. I'll find something new to implement in my game and work on it.


Until then, take care !

Thursday, April 8, 2010

Ha, been a week already !

Yeah no kidding, more than a week without post. You guys must be really bored. Well as you know I've been doing design lately and since I'm doing this on paper ( with a pen yes ! Like old times ) because it illustrates ideas better when you can freely draw and cross things out.


I have nearly a page of story and some pages of mechanics for the game that I'd like to implement. The story will be put in a .doc format and sent online so it can be browsed. Its NOT finished yet and I might just take another story that I started from scratch.


Beside that I'm pretty busy with other stuff, school and friends have successfully managed in keeping me away from concentrating on programming ( or sprite creation ), I'll be sure to make a couple big updates when I get a breather.


I'm also looking for books to read on subjects like A.I. , game design, story writing ( for games), graphical design ( Pixel art preferred, I don't do 3d ) and programming ( vb.net, of course ^.^ ).

Monday, March 29, 2010

Big Update is finished.

I have finally finished the overhaul I was talking about couple of days ago. And I think I managed to create some good stuff, albeit messy and hard to understand. 


Part 1: The Problem


The problem I had was the arrays. At first I wanted to be able to store them in a class, or a structure or even inside a text file that I would load. I rejected the first two, because making a class directly for a single array would be contrary to Object Oriented Programming and text files were useless since placing them outside my program was just as bad as bluntly dropping them in the middle of my main form, which was what I wanted to change. 


At first, I had arrays. My procedures would activate themselves with the arrays I needed by parameter and would fix the matrix accordingly. The problem with this approach, is that I need to know exactly what arrays to load when executing my procedures. This is chaotic because of transitions, going from map to map, as my game is not linear. I know not if the player will take a turn right or left. How can I decide what tile array to load in my functions ? This could have been hell...


Part 2  The Solution


 Instead I made a Terrain class. This class would have several parameters to hold the various arrays such as the tile and sprites arrays. As well as track which map is to its right, left, bottom or top. So instead of giving my sub several arrays. I would give him an instance of the clsTerrain class that represented a map. For example BasicRoad. I can them access its parameter inside the matrix such as BasicRoad.Spritemap or BasicRoad.TilesMap.  I would have a block of code on top that job would be to instantiate each map and give them the geographical location in relation to the other maps. 


The clsTerrain class:

So now that all our maps are there, we need to make our player able to switch maps. This is called a transition, it is triggered by stepping in a tile and pressing the according button. If you are at the top tile and you press the top arrow you get to the map that is right on top of the current one.But then we need to identify which tile is a transition, I could just leave it like if you are standing a tile in the border and you press the according button you get thrown to the next map. But then what would I do with doors and such ? I chose to make transition recognition  as early as I can. For this I had a couple of choices: I could just programmatically make them by telling him which tile to mark as such by hand. That is tedious and stupid. Instead I choose to add a third array and in there marking the transitions myself once and let him do the work. But how can a tile remember that it is a transition ? By adding a property, so I created a Tile class that inherits from picturebox and I added a couple of properties like IsTransition, a boolean value that marks a tile as one used as transition.

The clsTile class



This being done, I only need to configure the movement sub of each direction to respond if they are on a transition.  So the procedure is now ( in two parts ):

The moveRIGHT subroutine

Pretty big procedure. Theres 4 possible choices:
  • You are NOT on the border and NOT on a transition tile: You walk normally
  • You are are ON the border and ON a transition tile: Switch to next map
  • You are ON the border and NOT on a transition: Walk as long as the direction you're going is not out of bounds
  • You are NOT on the border and ON a transition: This is a "Door-transition", this will teleport you somewhere else. Not yet implemented
There IS a lot cleaner way to do it, but this is just a project to "make it work". The really big thinking process will be done in the final version of the project. Until then I just hack my way through my game and I will optimize later on. This is to keep me from falling out of morale. Since this is my first project that has a slightly bigger scale than normal ( for me ), I think that If I was to take 3 weeks to think out a single perfect function I would drop the project after 3 days. Now I can see my progress clearly, establish goals and accomplish them with relative ease, giving me the satisfaction needed to go forward.

Part 3: What's next ?
Right now, I have no idea. I'd like to take some time to create some more tiles to make rather more complex maps to bring me to the next features. The next logical course of action would be to make "Doors transitions", basically when I am walking on a door transition I get "inside" the building. Which is a map by itself. To do that I first need to create some kind of house tiles and that means a lot of work since all I did yet was some crappy grass and patches of road. And I was lucky with those, I just happened to arrive at a really good result on my 2nd try. I tried to make some mountainside tile a few days ago and it was really crappy. So lots of studies and practice incoming. I'd welcome any kind of suggestion, I understand that since this is not my final product I could just go to some website, rip some sprites and use them like some of my colleagues are doing. But what would be the point ??? I'm going to end up doing all the work anyway, might as well do it now and gloat the power of my magnificent tiles for a while. I would agree with the person that tells me that since they're nowhere near done yet that my tiles are "un-gloatable" but its a work in progress ! At least I can be happy in the fact that I don't need to steal all my shit. Anyway. I should also start thinking about the music and the game-atmosphere like the story and characters, in short the non-VB stuff. I'll be sure to keep you posted with updates. I still have a couple posts about problems that needs some explaining. I would like to explain in details how the transitions work because I think my system is pretty damn well though ( without wanting me to give myself too much credit ). 

I'm pretty happy with my progress so far. In ONE month I went from a corpse-less form with nothing at all on it, to a corpseless form with nothing at all on it BUT at least now I can make characters pop on the screen and move around. OK OK, I admit. Some people could do that in a day and do it better. I am not one of those people, I am studying in my second year. This is some pretty heavy stuff for the amount we learned in class. And I plan on making a LOT more with increasing complexity. I am talking of course about the battle system, and inventory and menus and all. I have yet to know what and how I will do this, but it will be grand I think. 

Until then ! See you on top of the next article.

Tuesday, March 16, 2010

A brief intermission.

I haven't been active a lot these days due to a couple things. First off I hit a problem on my project that is rather frustrating and I chose to take a break to get my mind off. I don't particularly mind problems when they're solvable. Like, the problem I had with the For Each that I will explain here is that kind of problem. Its possible to solve them using logic and a couple of tests. But there are problems that require a little bit more patience and hacking to solve.


The problem I have is related to the debugging phase. You get a bug, you yell "WTF !" you look in your code: nothing. You check the logic of your reasoning, the way data is handled: nothing. Then you decide to put a break point somewhere and run your program. Execution stops, you take a peek at the data, you see what the problem. you go back the code, you change a line or two and TADAM. Magic, problem solved ! But I did that, and nothing at all. Heres a sample of the broken code ( I thought I had it saved somewhere but it seems that part of code was deleted, here is something that should look like it. )

Sub something()
For Each c as heroTile in Me.Controls
       Me.controls.remove(c)
Next   ' Breakpoint right at this line. 


msgbox("Test Test Test")


End Sub
I inserted a break point at the Next keyword. And the msgbox method is for testing purposes, you will see why in a moment. After execution, the loops go through the controls and removes them. ( This will actually return an error, but this is just a sample to illustrate my problem ) When he hits the next, after every iterations are finished or while he is doing it. Execution stops. You heard me right, it just stops !! It will not budge, I can't make the execution go forward because he will NOT go to the next line. The compiler just waits there and looks stupid. I repeat, msgbox is NOT shown because execution will NOT go through that line. Which admittedly is weird. It might be something I'm missing or knowledge I don't have, but without a couple of hours of research I just can't see how I will solve this. Meanwhile, I thought of something for you guys:

For Next "Remove control" error.
Lets say I have this piece of code in a procedure:
Your guess is a good as mine, is scrolls through every control inside the form, and removes every pictureboxes. One by one, pictureboxes will be removed. From the first to the last. Unfortunately, you will find yourself with this result:

Can you spot why ? I'll tell you why. Because the Remove() function works in a special way. I made up a little .png to explain how it works. Image looks like crap but at least I can explain what it all means.
First lets say I have 10 picture boxes numbered 0 to 9. I want them all dead. I invoke the Remove() function inside a loop and I'm done. Actually, its otherwise. First, during the very first iteration of the loop ( lets say a For Each ) he will "plug" himself on the first picturebox he sees. He will then delete the control. BUT he will take every other control in the collection and move them one place up the collection. So element 1 will be element 0, element 2 will be element 1 etc. But a For Each works in ONE way and its numerically from the first control to the last. After deleting what was contained in the first address, he will move to the second EVEN IF THE CONTENTS OF THE FIRST ADDRESS WAS FILLED UP. At the second pass, he will remove the second element ( which is originally element #3, the second one is replacing the #1). This will create the blanks you can see in my output. Each one he removes, the next one is skipped. The problem is easily resolved by using a Do Until or another mechanism to check if there is a pictureBox remaining and delete it until there is none on the form.      

I'm hoping this piece will help some people when they see the same problem. This information was found using MSDN, never forget to hit the f1 key when you need help !

Thursday, March 11, 2010

Milestone achieved !

The Proof
Well I finally have something to show as a proof of concept:

Isn't that awesome ? Megaman standing on a map full of road and grass ! I made the image extra large so you all could see it. The simplicity of this piece of program is more complex than you can image. I will deploy a few images to explain what code I used to piece this up.

First I used both the "ArrayMap" and the "GridMatrix" technique from earlier posts. I have two arrays - BasicRoad and SpriteMap, that contains the values of which tile and sprite to apply in which position of the matrix ( as seen on the left ).

Then I created a method to take the values in the BasicRoad array to decide which image to place in the tiles matrix.
Afterwards I took the images from the matrix and put them inside a picturebox-like class and placed the tile on the form.
Next I had to do the same with the sprites, but unfortunately I had a problem. My idea was to place the sprite in a picturebox and put that picturebox on top of the tile he's resting on. But there is no opacity property on pictureboxes so wherever I put the sprite he was hiding the tile under him. Making an ugly hole in the map. to solve this problem I used the backgroundImage property and took the image of the tile he's resting on and applied it as background.

I created two classed derived from picturebox: GridTile and SpriteTile so when I scrolled through the form I could use their type to get only the tiles or only the sprites.
 
You can see that I am passing quite a few parameters to these classes, instead of giving them their values after I created them. I made a New() so I could give them their values directly when created. Much cleaner that way. You can see where I use the me.backgroundImage property and used the coordinates from the matrix. 

I'd like to stress that this is NOT a representation of the final project. This is from the vbProject that I made to explore the mechanism that I will use in my game. I still haven't done a single line of code regarding the game itself. The sprite I used are not mine and property of their respective owner. But I can take credit for the tiles since I made them, and they are awesome.

Wednesday, March 10, 2010

The "ArrayMap" technique.

The Basics
This technique is another way of representing a map created from a set of tiles. With the GridMatrix technique, I created a matrix with the exact size of my window and applied and scrolled through the matrix generation pictureboxes and applying them a specific tile ( a 32x32 picture ). 


There are a few weaknesses with this techique. First if you look my code closely I AM NOT EVEN inserting values inside the matrix, I am merely strolling through its dimensions and using this to represent rows and columns. This strikes me as the first big weakness. The second one is that: what if I need to access the tiles afterward ? Lets say my caracter is at the right edge of the screen and goes right, supposedly to make the map scroll to the right. Well because I did not store the location of the tiles and images somewhere, I have to re-scan the whole window and somehow code a way to remove the leftmost column and add one at the right. This is a would-be pain in the ass.


And here comes the ArrayMap technique:



This is an array. It signifies that the letter A represents all those numbers at once. And that we can get their values easily. 

An array is declared just like any other value:

Dim tileset as array

And to populate this array:

tileset = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3 }

Tileset will now have those values stores inside him. To retrieve them we can make a For Each loop and write each in a console

For Each x as Integer in tileset
        writeline(x)
Next


The Method I use

So I made a couple of arrays and planned to make picturebox images from the value contained in the array. Say the first value in the array would be 0 so the tile at (0, 0) is going to be say, grass. The 14's value would be the code for (14, 0) and the 16'th would be (0, 1)  (because we are scrolling left to right and then go to next line after the 15'th element ). 

Those are my arrays
The code I used to turn values into tiles:


And the result of using the BasicRoad tileset is: 



This is pretty much like the GridMatrix technique but instead of looping through a matrix we are using a For Each to cycle through the values of the array and using a Select Case to decide which tile to use as the image. 

Wednesday, March 3, 2010

Design UPDATE !

Yes, an update already. I've been messing around with my IDE and decided to give a go to the design of the game. What I did here was to generate the grid of the game window. As you know in earlier RPG's, the world was a series of tiles aligned in a matrix pattern ( Meaning for example: a 16x16 grid, showing 256 tiles total ) and your character and anything in the game world occupied a single tile. I made a few samples to give me a better idea of what I wanted my game grid to look like.


I had a choice between placing each individual tile on the form, or programatically add them after the form loads. The advantage in adding them after the form has loaded is that your form can be easily modified. As well as giving a greater number of design tweaks. I tried both method thought, placing them manually and automatically. And here are my results:


The one on the left is the automatic, right now is manual.

I chose the colors at random just to give me an idea on the output. Not a lot of difference you might say ? Well when you look at my design form, you can see it is a lot less cluttered. 

Automatic generation yields a much cleaner form designer.


The one on the left is the auto-generated window, the one on the left is the one I added every single tile by hand ( with the help of CTRL+V of course ). You can see the absence of picture boxes on the one on the left because there is currently no tile alive yet. They have yet to be created. Also, the code for autogeneration is MUCH smaller than the manually added at start. 

Let me explain why: When placing controls on the form, even thought you cannot see the related code, some is still created. For a single picture-box, is looks like that
      Me.PictureBox195.Location = New System.Drawing.Point(288, 372)
        Me.PictureBox195.Name = "PictureBox195"
        Me.PictureBox195.Size = New System.Drawing.Size(32, 32)
        Me.PictureBox195.TabIndex = 213
        Me.PictureBox195.TabStop = False
Multiply that by 256 times, and you get quite a big file to load already at start. Meanwhile, when adding them automatically when the form loads, they are added one by one with much cleaner code thus making your source code smaller and lighter. The code I used for both forms is thus:

The first one is for the auto-generate, and the second one is manual. You can see on the second image that the only code running is the color-chooser, thats be cause there IS NO code needed on the main() procedure for showing all the picture boxes. But when you compare the first to the second, one simple method is much cleaner than 265 chunks of designer data.


All in all, auto-generation is a much better choice for the purpose of making game because the grid is not static. As we move to the edge of the screen I have to be able to change the map very quickly and efficiently .

Monday, March 1, 2010

Design 1.0

I'm going to be hitting the design phase sometime soon, due to the length of simultaneously learning and making. My posts will be less about a resume of my progress but a show of the progress itself. I will first try to make tiles and apply them to the game world. The game world will be a matrix of tiles put inside the panel you saw couple of posts ago ( in the image folder of my album ), 16x16 tiles generated with some kind of technique I still have to fathom. I plan on developing my own technique for doing this ( instead of just hitting the forums and asking how to do it ) because I feel like I can find it myself and thus will be better at applying it. It won't be anything revolutionizing  but fun to make out.


On my list right now there is:
  • Figuring how the hell to make a map and apply tiles to it.
  • Make said tiles using paint and the tutorial I got.
  • Make individual functions that I will be able to use throughout the game. ( Wait functions, timers, showing menu's, combat etc. )
  • Start thinking about music effects.
More will be added as I go. For now I have to study about my exam coming tomorrow morning. Hell I hate exams, nothing worse than theory. Give me practical exams for fuck's sake. 

Saturday, February 27, 2010

Requirements of the Game Project

This is the requirements I've been working on for the game projects. I tried following a Waterfall software development approach, but unsure if I'm doing it right. I tend not to care very much if I'm not doing it EXACTLY right because I mainly do this for fun. 

Requirements 1.0
What purpose does the game serve ?
        Be entertaining to a technical degree


What graphical content is expected ?

        Sprite and Pixel art textures.
        Sprites with different phases to represent movement.
        Top down perspective at about 70 degrees

What audio content is expected ?
        An 8-Bit music track.
        Ambiance tracks, combat tracks, indoor tracks. 


What amount of content is to be expected ?
        Have at least 30 minutes of content.
        Single storyline
        Immersive story


What kind of interactions will be possible with the world?
        Conversation with multible options
        Turn by turn combat
        Inventory system


These are the expected things I hope to fulfill with my game. I might not be able to get everything working but I will update the post to add or remove items as I go. Next in line is the Design part. 

Software Development Process

So I've been reading a few wikipedia articles ( namely this one, and that one ) about software development planning. For it has always been a problem for me, I never finish any project I start because I have no plan to stick to and always find that I can do "that part" in another way and want to re-write the whole thing. 


Now, things will be different. After those articles I managed to grab the essential of the concept of making a plan and sticking to it and not jumping to the implementation process too soon. And so I have chosen the waterfall model for my process.






So I am now jumping into the "Planning the requirements and specs" stage. What purpose will my game serve? Whats the point of it ? I will make a post about this stage when I am done or simply to update.

The websites I'm reading

Last post I mentioned websites that I was reading to give me ideas for my game and learn a thing or two about creating them. I feel like I should share those websites for anyone who wants to peruse them in search of knowledge. Here's a couple of links:


GAS 13: Tips about Pixel Art
GameDevs: Game Development
AlanHipps.com: Creating games with the XNA platform
Pro VB 2008 and .net 3.5 platform: A very good book I'm reading.


I also watch amazon.com a lot for interesting books that I might buy. I will probably compile a list of the best of them along a quick review if anyone is interested in such reading.
These are only a few links, I'm still sorting through my bookmarks after switching from firefox to chrome and the bookmark management is not that great. Will post updates.