2012/08/03

grid-based game logic

Another video tutorial, howing how to use grid-based game logic in a puzzle game. This is the tutorial for the lights-out game I mentioned before and which has been included with the package.
This tutorial is written in C# because it uses delegates and events. The reason why is so that no single tile needs to know about the other tiles, making this code extremely flexible, you culd even change your scene during runtime. If you don't know about delegates and events I really recommend you to check out prime31studios' video. Their video series really got me into C# development.
To give you the basic idea, events and delegates mean that somewhere somehow something happens and some other objects react to that. The object that triggered the event itself has no idea who (if anyone) is listening and how they will resond. For example you could have an RPG where when you draw your sword it makes villagers run away and guards draw their own weapons. Your hero would not need to know how many villagers and guards (if any) are around, he just needs to fire the event and all listeners will react accordingly.

2012/08/01

Release!

Grid Framework has been approved and is fom now available on the Unity Asset Store for 15$
This is the price for the initial release, it will go up as the amount of features increases, but all existing customers will get all updates for free. Please feel free to visit the support thread and drop me a line if you have any questions or suggestions. Once the first wave of purchases has passed and if there are no issues I will start working on either hex grids or grid rendering, whichever you guys might find more important.
http://forum.unity3d.com/threads/144886-Grid-Framework-scripting-and-editor-plugins

And to think that is has already been four months since I started this blog... the framework has gone quite a long way from a quick&dirty solution I rolled up in two days to something I can proudly announce. I am looking forward to an even brighter future for Grid Framework.

2012/07/29

grid movement and runtime snapping

Well, I just sent my second submission. There are three examples included, one showcasing grid-based movement, one showcasing how to place objects on a grid during gameplay and the lights-out game mentioned below. i also made tutorial videos for the first two, showcasing how you can accomplish these tasks in a simple manner on your own:


2012/07/27

a quick update

I have been contacted by an Asset Store admin, who recommends me to include a demo scene so users could see an end setup. I thought dragging a script onto an object is pretty straight-forward, but I agree, a demo scene would be a really good idea. The tricky party is coming up with good ideas; don't get me wrong, I have plenty of ideas for actual gameplay examples, but for a demo scene I need something more basic and at the same time more catchy. I already made a little sphere that randomly roams a grid face by face, stays within limits and immediately adapts to changes in the grid, all with just 32 lines of code total (not counting whitespaces and comments). I'll come up with two or three more nice demos, that should give a good impression of Grid Framework  in action.

2012/07/22

Almost there...

Well, it's alsmost done. Again. Turns out that making an asset is only half the job, you still need to hammer out any ugly dents, polish the thing and then change your job to become a graphic designer, a video commentator, a writer and a salesman! What good is the best asset if you present it in such a way that makes people not even want to take a look? I'm not claiming that I'm an expert in any of those fields, but I believe I did a pretty good job (well, maybe my voice work for the video could use some improvements). In a way I'm glad the old "images" I had prepared for the first version are now lost forever, that was something to turn people away forever. You cannot imagine how awful those looked.

Anyway, I finished the videos, I made the drawings for the asset store and I wrote the documentation. The only things left now are uploading the videos (which will take quite a while with my connection), writing a description text for the asset store (shouldn't be too much, so it won't take too long) and then sending the files over to Unity. In the meantime, please enjoy a small teaser:

Unfortunately clicking this won't do anything. Yet.

2012/05/29

Turn off the lights!

Here is a nice little puzzle game made using the grid framework. When you click a square that square and the four adjacent squares flip their color. Your task is to turn them all off.

The entire game uses only two scripts with a total of 70 lines of code. Sure, that may not seem like a small amount, but keep in mind that almost half of that is just whitespace and comments for better readability. The other half is mostly just to handle the user's input and only two lines are used for grid-based operations, i. e. finding out which tiles to flip. What's even better is that this works for any setup, you can even have holes and weird apendages like in the above picture. You could even move tiles during gameplay or generate the puzzle dynamically rather than by hand every time. Grid framework always finds the right tiles for you.

I will put up a video tutorial eventually once the package is released. I used delegates and events, so if you don't know what they are take a look at prime31studios' video tutorial:

2012/05/14

State of the Game

It has been over a month since I posted the introductory video and sent my application to Unity. I never received any confirmation, so I assume it got lost somewhere along the way...
Anyway, that doesn't mean I have been sitting here for over a month staring at the screen and refreshing my mail. I started working on this project because I needed a simple solution for one certain problem, that's how I started working and over time more and more ideas came to my mind. It was clear that I would need a complete rewrite sooner or later, so I decided to release a simple version first and then start the rewrite instead of throwing everything up to that point out the window.

When I sent my submission to Unity I was done with the old concept and started working on the new, more robust concept that would allow for far more features to be implemented cleanly. This meant switching to C# (since some things just aren't possible in UnityScript) and diving deeper into the documentation than ever before. I like the results. I set myself a few goals and so far I have achieved most of them. This includes:

  • grids as components instead of plain classes
  • fully support 3D grids and rotation
  • functions to find vertices, faces and boxes with just one line of code
  • a nice panel for aligning and scaling instead of that dirty workaround
  • switch between grid coordinates and world coordinates (and vice-versa) with just one line of code
  • every kind of grid (quare grid, hex grid, triangular grid) inherits from one common Grid class
Most work has been done under the hood to keep the code clean. It's easy to insert a new feature into clean code where I can leverage already existing methods instead of having to write the same thing several times (copy-pasting chunks of code is an awful idea!).
The one thing that still needs a good look are the methods related to the vertex matrix, it's one of those things that are easy to break if you aren't careful.

That said, once it's done the (hopefully now) first release would be ready to ship. I'd also have to rewrite the entire documentation and draw new logos for the Asset Store (in a way I'm glad my first submission got lost, those "drawings" were just aweful)
The fist release would only cover rectangular grids with hex grids added next, then finally triangular grids. I haven't started implementing them, but I have already done the math and I know how to do it, I just need to finish this first. The one last thing I can think of is grid pathfinding, but I won't even waste a thought on that until I get the other stuff done.