Thursday, 29 July 2010

Moving at the speed of a striking slug

Well things are moving verrrrrryyyy slowly. Mainly due to the release of starcraft 2. Watching 'the story so far' as the game installed got me wondering exactly what had happened in the first game. So for the past 2 days I have been playing the original starcraft rather than programming. Now I just need to finish the expansion pack and I can play starcraft 2...

That's a lot of hours spent gaming and not programming! Hence the title. Things will quicken in pace after a few days but as it stands the Tileset class and TilePlacement class are complete (in theory). The good news is that after I completed these classes I got a better idea of how things are going to come together, which gave me a bit of umph! But until I've had my fix of games, expect not a lot to be happening.

Update:
Ok after writing that it seemed my head kicked into work mode and I seem to have done quite a bit tonight. I have a few ideas for optimization as well...Who knows, by next week we may be seeing some tilesets being loaded!

Sunday, 25 July 2010

Thinking ahead...

Yet another reason I don't plan things. I'm constantly changing my mind. Originally the idea was to save maps in XML. The only reason for this was that it would make it easier to mod the game once it had actually been completed. However, now that I've started making things it had dawned on me that I will be needing to store various instances of the same object with various properties. By this I mean: on any particular map I may use a tree. On the same map I may make another tree...which is actually the same tree I used before, just scaled to look slightly bigger. Saving this sort of information in XML is simply not as easy or convenient as saving it inside a custom file type. For this reason I have started making the Tileset, Tileset Manager, Object and Object Manager classes with this in mind.

This is the bit I hate the most. I'm constantly coding and there is nothing to show for it until the whole lot is done and they start working together. Nothing to see as of yet, but rest assured I'm doing stuff ;)

Thursday, 22 July 2010

Sizing things up

I don't believe in plans. Never have and can't imagine I ever will. I think they are the most pointless things I've ever been constantly told to do by teachers, lecturers, employee's, parents, etc. Why confine yourself to a single course of action? But hey, there's always Plan B right? Forget it...You can't possibly know what will go wrong with Plan A and therefore you can't possibly know if Plan B is a viable option. Forget plans, just think dynamically or "on the fly". The point of a plan is to be prepared for the future, which changes with every act you take. That's a pretty hard thing to be prepared for! Screw it, if you can come up with a plan for something that hasn't happened yet, then you can most definitely come up with a plan for something staring you in the face.

That being said, I do believe in blueprints. You can't build a house without blueprints. You need to know what size the plot of land is, just like you need to know the size of the house and every room in it. Try making a house without a blueprint and the whole thing comes tumbling down. Same goes for a program.

In the map maker I am building there are a lot of things going on inside the form and they're all different sizes. Worse still, my plot of land (the size of the screen) varies from monitor to monitor. I have two monitors, one uses a "1768x992" resolution while the other uses a "1280x1024" resolution. I know some people still use "1024x768" resolutions and not knowing which one to cater for is a real problem. But like plans, we shouldn't restrict ourselves to one line of thought. I have just made the blueprint of the map maker, and things will shift around depending on the size of the screen...or on the size of the window if you don't want it full screen.


























As you can see there will be a typical menu bar at the top. Currently holding "File, Edit, View" others will be added as features are implemented. Below that is a toolbox holding the bog standard "New, Open, Save" icons and a few others. Again this toolbox will grow with features as they are added.

The panel taking up the majority of the screen will be where the map is viewed and made. The blue colour indicates that this panel is an XNA panel (this means that what is seen in this window will be identical to what is seen in the game). Also notice the scroll bars to the left and bottom of this panel. These scroll bars ensure that the map is not restricted to the size of the panel. Maps will be saved using the XML format and you can just about see the tab labelled "XML" to the top left of the panel. Choosing between the "Map" tab and the "XML" tab will switch between the graphical representation of the map and the XML code which can be altered directly.

The blue panel to the right of the screen is essentially the "pallet" of the map maker. From here we will be able to import tilesets and create objects. This panel will have a great number of modes, some of which are: importing tilesets, creating new objects and selecting existing objects.

The long white panel at the bottom of the screen will show the projects working directory. By this I mean all maps created by the user under a single saved file. Maps can be organised into folders and this panel will show the hierarchy in a tree format.

Finally, the small box located to the bottom right of the screen will show the properties of the currently selected item. Whether this be the map itself or an object from the list of available objects, you will be able to change it's properties and see the results in the map window. This will allow features such as adding weather, resizing objects, rotating objects, naming the map or objects and a lot more. All at the touch of a button.

Wednesday, 21 July 2010

"Could not load file or assembly" - Solution

Today's task had just been completed...finally. I'm going to start talking compucrap for a while now so if your just interested in the RPG scroll down to the bottom of this post!

What should have taken an hour has taken me the best part of five hours. The aim of today was relatively simple: create the classes needed to work with XNA inside a windows form. "What the hell does that mean?" I hear you cry.

Well to avoid a lecture on what's what, for now just imagine that I'm trying to make a game run inside the "My Documents" browser. As you can imagine; this type of thing isn't meant to be done and requires a bit of work around to get these types of results. A game needs to be updated as quickly as possible (a minimum of 30 times every second to keep up with the human eye). A windows form sits there idly until it is moved or interacted with.

After an hour and a half I had written code that would enable me to have as many games as I wanted running in a single window. Upon testing the code all I saw was a window that showed a big red cross. It was like the computer had just looked me dead in the eyes and said that all to common word: "Denied!"

Obviously something was wrong, but what? I had hundreds of lines of code and the only hint of error the computer showed me was:

Could not load file or assembly 'Microsoft.Xna.Framework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d' or one of its dependencies. The system cannot find the file specified

You what? What the hell does that mean? I sifted through the code for hours, thinking I must have made a mistake. But no, apparently I do know what I am doing, but my computer does not...

Here's the solution for all those directed to this page by google while trying to fix the same problem, because lord knows there's a lot of you!
If you are running a 64bit system, be sure to compile the program for a 32bit platform. By default visual studio selects the Debug folder and "Any CPU" as it's build preferences. You need to change "Any CPU" to "x86". This can be done by clicking:

Build -> Configuration Manager
Click the combo box under in the 'Platform' column
Choose
Under 'New Platform' choose 'x86'
Copy settings from AnyCPU

Well that didn't take long for the first tutorial...

As for the RPG:
As mentioned, I can now run multiple XNA games inside a windows form. This means that I can run a simulation of the game while the map is being created. No need to save the map, no need to compile anything. I can start walking around the map as soon as I place the very first object (preferably the ground, else I won't be walking far)

Better still, I have also implemented something that allows XNA to compile resources after the programs initial compilation. This means I can use any tile set at any time to create anything. This may not sound amazing, but if you know how XNA works with resources, I think you'll agree, that's pretty nifty! Next step is to start creating the code that will let me import tile sets and draw to the screen. I'm hoping for less trouble with that...

Saturday, 17 July 2010

Old ideas, new methods

"I'm going to make a game!" - Marc Stoate (2001)

Ah yes, those six words that I would say over and over again for the next nine years without them ever coming close to reality. Until now! Nine years on and I have finally got the knowledge and mindset to make anything my mind can conjure up. Through this blog you will witness the birth, life and death of my first ever game. You will see my triumphs and failures. My high's and low's. My problems and their solutions. Not only is this blog intended for those whom I promised this game to all those years back, but also for any C# and XNA developers out there looking for inspiration or a few quick 'how to' guides for some not so common problems.

The game itself will be an RPG starring myself and as many of my friends as I can logically fit into it. Seeing as this is my first project (or at least the first one I intend to finish...) I'll be keeping it simple and using the style of ye olde RPG's. By this I mean it will be a 2D top down sprite based game, similar to that of the original Final Fantasy's or Chrono Trigger. Naturally I'll be throwing in particle effects and maybe a few shaders for good measure but if your looking for mind numbingly good graphics and advanced shader techniques, you're in the wrong place!

As of next week I'll have six weeks holiday to start my tinkering! First up on the agenda: the map maker. May the madness begin!