RSS
 

Archive for the ‘Development’ Category

Birth of a game

08 Dec

New blog post on the Spellcaster Studios website, this time about the genesis of the idea for Grey.

 

More “Grey” updates…

06 Dec

I’ve been spending all my off-hours working on “Grey”, and as such I have little time for my personal blog posts, etc…

Just head on to http://www.spellcasterstudios.com for a new post about what the game is really all about!

 

Announcement!

02 Dec

grey_01

Head on to http://www.spellcasterstudios.com for the announcement I’ve been promising for a while!

We’ll have more to add in the next weeks!

 

Bah, stupid capture applications…

25 Nov

I did a nifty 10 minute video walking people through the material system of my editor, but the encoding application decided to blow up and corrupt the files… Disappointed smile

Need to find a better way to do this kind of video captures… for fullscreen applications, I have Fraps, which works like a charm, but for “desktop” applications, I don’t have anything good… Any suggestions?

Anyway, this will be the post before the weekend… it still wasn’t this week that we did the “big announcement”, but we’ll do it next week for sure!

Have a nice weekend everyone!

 

LiveLink

09 Nov

Although I got Uncharted 3 to play, I managed to get some time to add the live-link feature into SurgeEd!

Now, each time I change a shader file (or any of its dependencies), the editor reflects that when the window regain focus. Hopefully I’ll be able to iterate shaders faster, and do some more effect shaders as well.

I still need to add the material edit options, but I’m struggling a bit with it, from a conceptual standpoint.

We are editing objects on the editor, and those objects have (simplifying) a position, orientation and mesh. And the mesh has materials, shared by all the instances of that mesh… We can think of an object as an instance of a mesh. Now, I have to add materials to the object itself, and these materials have to be children of the mesh (with names generated from the object name). Then, every time the mesh of an object changes, the materials have to be deleted and re-added from the mesh materials. There are also other problems associated with the drag/drop/copy/undo/redo systems.

After I solve this, it comes the time for the properties of the material itself, which has a dynamic component, based on the shader selected for the material.

None of this will be simple, but it sounds like a neat system! Open-mouthed smile With both the live-link and the material editing, I’ll be able to work on shaders in a more efficient way!

On another note, found a cool game to spend some time:

 

It’s very cool there’s still new concepts for platformers, and although I’ve seen this concept before in other games, this one uses it very well associated with the ninja concept!

 

Something fonty…

07 Nov

option_menu

Didn’t have much time lately to do any real work on my games, but managed to finally fix the text system on “Something Fishy”. It got screwed up some point in the near past, with the upgrade to the font system (that allowed for variable spacing between characters, etc).

I managed to patch it up, which made me have to rebuild the main font for the game, and in. the process I found a bunch of small bugs in Something Fishy that I took the opportunity to solve.

So, finally I have a working build of Something Fishy for the PC (although the “Kids” and “Easy” difficulty levels need some tweaking).

Now I can think seriously on porting the game for tablets and (hopefully) for Linux and Mac. This will make me have to solve some small issues, namely the sound engine, vibration and interface issues.

The sound engine is just a straight implementation issue. The current port of my sound system on Marmalade only supports fixed bitrate RAW sounds. To really be able to port this game, I’ll need to add at least a WAV loader (and maybe an MP3/Ogg streaming system).

The interface is much more complicated. Currently, Something Fishy works with the mouse controlling the hook in which a worm of a specific color is caught

ocean_level

This obviously doesn’t work on an iPad, since we don’t have a cursor… So, we currently have a “point and click” mechanic, and that has to be translated into a working “tap” mechanic, which changed the game overall (not dramatically, I think).

My current idea is to replace the fishing pole for an “attractor ray gun”. The player taps the screen in a specific position and a beam will grab the fish at the target position. The color of the sparks in the gun’s muzzle indicates the necessary color. Players have to grab the fish in succession (from smallest to largest), and the first two sizes serve to power the gun, so it can grab the larger one, which Ernest actually uses as food.

This will require some new art (and my artist is still on leave), some new testing (difficulty levels will need to be adjusted), so it might be a good idea to start porting to Mac/Linux first (in which we can use the mouse).

Work is not something that’s actually missing in my small hobbies, so I’ll probably do a detour I’ve been planning for sometime, converting the shader system on Spellbook to use the new XML format, and add a live-link option (changing a shader on the file makes the change visible on the game instantly).

 
 

SurgeED–Image Bank Editor

28 Oct

After a couple of weeks, I’ve finished the Image Bank editor on the SurgeED tool… Took a bit longer than I was expecting, mainly because I had to add to the editor system the concept of child entities, with all the copy/delete/undo/redo/explorer issues associated with it…

But first of all, what’s an image bank (IB) and why do I use them?

Well, one of the main things you can do to increase performance in any engine (be it 2d or 3d) is to reduce the number of primitive drawing calls… I’m not talking about actual primitives, but calls to the function that draws them… That requires a call to the low level system, and that call has a fixed setup time, no matter how many primitives you render in that call…

So, it’s better to create a single buffer with 1000 primitives (sprites in case of 2d) and draw that, than have 1000 buffers and draw them all… The performance increase is in several orders of magnitude…

This process is called “batching”…

But to draw 1000 primitives in a single draw call, they have to share every render state (which includes all the like render properties, more importantly, the textures).

So, to draw 1000 primitives, they have to share the same texture, and this is done through creating an atlas, which is a single texture that has loads of images in it. Then, using UV mapping, we can index the separate images and use them in a single draw call to draw different objects… Below you can see an example of this:

BM_gui

This is accompanied by a file that describes where each of the individual images is:

<image_bank name="bm_gui_ib" delete_textures="false" normalized_coords="false" read_textures="true">
    <source>
        <layer type="diffuse">bm_gui</layer>
        <images>
            <image name="b_inv_arrow_s" x="703" y="0" sx="32" sy="95" hx="0" hy="0"/>
            <image name="b_inv_arrow_u" x="639" y="0" sx="32" sy="95" hx="0" hy="0"/>
            <image name="b_inv_btn" x="191" y="288" sx="61" sy="71" hx="0" hy="0"/>
            <image name="b_inv_combine" x="795" y="152" sx="184" sy="85" hx="0" hy="0"/>
            <image name="b_inv_exit_s" x="639" y="320" sx="73" sy="31" hx="0" hy="0"/>
            <image name="b_inv_exit_u" x="543" y="320" sx="73" sy="31" hx="0" hy="0"/>
            <image name="b_inv_menu_s02" x="319" y="32" sx="142" sy="25" hx="0" hy="0"/>
            <image name="b_inv_menu_s03" x="319" y="57" sx="142" sy="23" hx="0" hy="0"/>
            <image name="b_inv_menu_s04" x="319" y="80" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_s05" x="319" y="104" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_s06" x="319" y="128" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_u01" x="0" y="0" sx="142" sy="32" hx="0" hy="0"/>
            <image name="b_inv_menu_u02" x="0" y="32" sx="142" sy="25" hx="0" hy="0"/>
            <image name="b_inv_menu_u03" x="0" y="57" sx="142" sy="23" hx="0" hy="0"/>
            <image name="b_inv_menu_u04" x="0" y="80" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_u05" x="0" y="104" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_u06" x="0" y="128" sx="142" sy="24" hx="0" hy="0"/>
            <image name="b_inv_menu_u07" x="0" y="152" sx="142" sy="33" hx="0" hy="0"/>
……………

The hotspot describes where is the “grip point” of the image, which is helpful for rotations and just general positioning.

An image bank then gives “names” to the images and says to the system where it can go get them (in terms of texture and positioning). A single image bank can use several textures:

afonso0400afonso0401

This helps with the organization of the image banks…

One thing I added in the process of adding an editor for this (more on this later) was the ability of a single image have different layers (like diffuse, normal, etc). This will be helpful to define a decal system later, since I need both textures to create a really good decal, and I didn’t want to create separate systems…

Basically an image can have multiple layers, the only restriction being that all the layers have to have the same size.

Up until now, the artists would create these Image Banks by hand, positioning images in a big image and creating a text file by hand, specifying where each element was. This was time consuming and very error-prone, and this was one of the motivations for the image bank editor.

The way the image bank editor works is very straightforward… You create an image bank component, and add pages to it… Each page can have different sizes and support different layers. Then you import images to a specific page (with all layers being a different source DDS image). Then you can move the images around, using the normal tools of the trade (snaps to grid, to other objects, padding support with visual warning where two images are overlapping, etc)…

When the artist is satisfied with the image bank, he can “Generate” it and the system will create the atlas and XML file, and it becomes available to all the editor system. The component can then be deleted (it can always be created again from the image bank), or left alone.

You can also add mountpoints on the images. On the sample above, you can see the character has a sword on his hand, but if we had a character that could yield a sword or an axe (for example), we could add a mountpoint to his hand and in the game run time, attach another object to a specific mountpoint.

I’m very proud of the editor as a whole, and this component is very cool in action, since I believe it will cut down development time for 2d games a big deal (artists could lose up to 3 or 4 hours creating an atlas by hand, and add 2 more hours or so due to small errors, like a wrong position (easy to spot) or a wrong hotspot (harder to spot)).

 

You can see the editor in action above… the frame rate is crap, think it is because of the on-the-fly encoding… This component doesn’t perform as well as I’d want, but it’s easy to understand, considering that each image has to be drawn separately (in its own draw call), because we’re trying to create the image bank that will solve that problem in game…

Next stop in my travels in game development land will take me to rebuilding the fonts for Something Fishy, so I can start trying to port the game to tablets.

 

Sub-entities

03 Oct

Some more work on my SurgeEd…

The next step on my editor is the decal system… Although Spellbook already supports decals, I want to make the system better for authoring and for resource management.

At the moment, a decal references a decal sheet, which is a structure that defines UV coordinates on multiple textures (for normal mapped decals, etc), but I want to collapse the decal sheet and the image bank into a single structure, since it’s easier to manage.

To do so, I’ve decided to build into the editor a “Image Bank Editor” component, which will enable me to place images in a series of layered “texture sheets”, and after some consideration, I’ve started building a system with support for sub-entities, that is, entities that can only be bound to a specific entity.

Easier said than done… I did some mistakes in the general construction of the base system which made this much harder, specially on the interaction of the Component Explorer (the tree-like view where you can see all the objects and select them, drag them around, etc) and the main component system.

The base system was pretty easy to get up and running, but creating the right hooks for the Component Explorer to work nicely with the overall structure, including the Undo and Clipboard systems proved a challenge…

Fortunately, I got it working, and the future expansion of the system will allow me to create very interesting things, like object properties that reference an entity in the scene.

Tomorrow I’m heading out to the Netherlands for some work (sadly, I have to have one of those to make a living), and hopefully that will enable me to make some blog posts for the future (so I don’t spend so much time “away” from you, my loyal readers!) Smile

 

Porting issues…

28 Sep

Since my artist is still out of commission (and probably will be for another month), I’ve been doing mainly technical things…

Since I was feeling lazy and didn’t want to add the tutorial code yet (since that’s GUI work, and I hate GUI work), I’ve decided to start porting “Cell.ection” (if I haven’t mentioned it yet, that’s the current name for the game, although we’re still arguing between “Cell.ection”, “Cell.Action”, “Cellection”, with different types of writing styles) to personal computers (Windows, Mac, Linux are the targets).

Decided to start with the easy one: Windows, and I partially succeeded…

Amoeba_PC

Found several problems:

  • A small bug: I deleted an object from itself (“delete this”), but I set the animation of that object to false afterwards… curiously enough, this didn’t raise an exception, but it crashed (or more precisely, Visual Studio raised an exception because it detected memory that should have been free altered) because of memory corruption… This behavior didn’t happen on the mobile version because apparently Marmalade doesn’t use the same trick to track this kind of problems.
    On allocation (and on debug mode), VS initializes memory to zero, and when a de-allocation occurs, it sets that space to a familiar pattern (like all bytes set to 0xAE or something like that). When an allocation occurs, the system verifies that all the bytes are set to 0xAE, if not someone messed with that memory address after it was released and raises an exception. It’s a neat trick… In this case, messing with the memory like I was doing wasn’t a serious issue (hence no big issue in the mobile), since I deleted the object and set a boolean value to false, so I couldn’t corrupt any new objects in the process, but it could mean something serious. Ah, obviously enough, the heap is all initialized with that mask (or else the first allocation would raise an exception).
  • If you look at the screenshot above, the GUI is all compressed… That was a trick to get it to render at all… I didn’t remember, but the D3D API doesn’t allow for negative values on the viewport settings, and that was what I was using to simplify my multi-resolution, aspect-ratio agnostic system… So I’ll have to change the way this works (probably by shifting the viewport to be all positive, and offsetting the objects there to reach the same visual result).
  • The fonts look terrible, due to the larger screen size… they probably look terrible on the mobile as well, but it doesn’t show because the screens are smaller. Need to work something out on this, probably change my bitmap font generator so that it does some multisampling on the fonts, or maybe integrate OpenType to build the fonts in real time from TrueType fonts, adjusting to the resolution.
  • No cursor… In mobiles, we don’t need/want a cursor, but in a mouse based system, it’s kind of necessary… Not only that, but some feedback on the buttons when the mouse is over them is also a bit necessary… This implies having some “ifdef/endif” blocks in the code, which is kind of ugly… Of course I could do this data driven, but sounds a bit like overkill for something like this.
  • File directory structure… Marmalade assumes that all files in a certain “data” directory will be packed into the package for mobiles… Problem is that if I use the same paths on the mobile and PC version, I need to have some DLLs on that directory (FMod, for example), which sucks big time… Probably need to think a bit better on the directory structure, specially to see if I can sort out some kind of override system so that I can have different assets for different platforms (more resolution on the fonts, for example), while keeping the common part together…

 

This is one of the reasons why this project is so interesting from a learning perspective… Although the code part of it was ported without needing many changes, just create a new VS project and dump the files there, there are still lots of small issues associated with multi-platform deployments that must be addressed (and now is a good time, since I can still change the way SurgeED works to do a better job at this multi-platform asset management).

I’ve also been working on a second port, this time from PC to mobile… An old (unreleased) casual game of mine:

MainScreen_2011

The game won’t work on smartphones, but it’s a good match for tablets… Currently, I’m just trying to get the old code compiled with the latest version of Spellbook, but even that’s been proving hard, specially because of the font, since I changed it a year and a half ago (so that includes the concept of character metrics). Problem is that the hand-worked fonts of Something Fishy were done with the old system and while they worked well with that, they miss information necessary to work nicely with current Spellbook…

Need to fix that, either by generating the missing information, reverting that component to an old state (if I can find an old version of Spellbook pre-change), or *shiver* adding by hand the information…

Finally, also been thinking a lot on the new Image Bank system for Spellbook… I need a way to make it “multi-layer”, so I can have normal maps with the images aswell (some nifty 2d effects and for use with decals)… To do so, I want to add an Image Bank editor/generator into SurgeEd, but I need to think if an Image Bank is a component or a resource (probably both)… I already have a Font Generator in the SurgeEd, but I don’t like the way that turned out, so I‘m thinking to handle any resource editing as a separate component of the editor, with its own specific subsystems, but I haven’t made up my mind yet…

So stay tuned for more developments!

 
 

LUA syntax

23 Sep

I love Lua for scripting… It’s easy to integrate with any C/C++ framework, powerful, fast, takes little memory, good debugging hooks, memory control, and (best of it all) it has coroutines, which is something that I utterly love in game development.

lua

But this is not an article praising Lua… To the contrary, it’s a rant about the stuff that annoys me in it and that I wish someone would fix… I know most of this could be fixed by me, since Lua is Open Source, but to be honest most of it would be a huge endeavor in the guts of Lua itself.

  1. Why 1-based arrays? Every language I know of has 0-based arrays (that is, arrays that start at position 0), but Lua had to be different… This is not a big problem per se, but the amount of times you do it wrong because you’re shifting from C/C++ to Lua is huge… Probably someone that sticks to Lua can do it without messing up a single time, but I’m an indy programmer!
  2. Why THEN and END? This is my main annoyance with Lua… All IFs in Lua have to have the keyword THEN after the condition, and END up when the syntax block ends… I understand being mandatory an instruction block (i.e. not allowing for a single instruction), since that leads to some ambiguities and tricky to spot bugs sometimes, but couldn’t they have used ‘{‘ and ‘}’, or even ‘[‘ and ‘]’, or something else but a clunky keyword that makes your code seem ugly? On the same note, the FOR and WHILE loops also require the DO keyword, which also sucks… is it that complicated to make a parser that doesn’t need those things?
  3. Use of doubles for numbers. This one I understand… numbers in Lua are expressed as doubles (which allows them to be fractional and yet provide a good range of integer numbers without loss of precision). But when you’re making games, you don’t want to keep switching between single and double precision on the FPU, and Lua kind of forces it (since you’re probably using floats all the time for everything else, like meshes). Adding an integer type and going for floating point numbers would help tremendously here (although I believe it wouldn’t be such a simple task as I’m stating, since the typeless nature of Lua makes it complicated, but I wouldn’t mind having some methods to work with floating point numbers, and others for integers for this purpose). The way I have it now, I do a compilation of Lua with numbers as floats for my game projects, and cross my fingers so that the precision doesn’t byte me in the future.
    What I do is when I want to treat a number as an integer (in comparisons and things like that), I round to the nearest integer… Hopefully that’s enough to stop some problems (which might be tricky to debug, since 3.9999999 != 4)
  4. Lack of types. This one isn’t really Lua’s fault (since most languages don’t do this), I would just really really really appreciate if I could have 2, 3 and 4 dimension vectors treated as internal types, so that I could use vector math in Lua (without the performance hit I get when I use arrays as vectors)
  5. Lack of pre-processor. Again, not Lua’s fault, but it would be nice to have a preprocessor in Lua’s parser… I can run stuff through the C preprocessor and feed that result to Lua, but that screws up debugging a bit, which is too bad…
  6. Lack of a class based system. I know I can use meta-methods and tables to mimic a class in Lua, but that’s not the same. Imagine that I return an object from C code. That implies that I “copy” the data from the C++ object to a Lua table, and push also some functions (C/C++ and Lua). This sounds terribly inefficient. It would be better to be able to specify some classes (with the methods associated to them), and just copy the data on top of the table. You might be able to do this with some trickery, but I haven’t found the trick yet, I admit. This one isn’t very serious, since Lua never pretended to be an OO language, and I can live just fine with passing some light user data values back and forth between Lua and C/C++.

 

I’ve looked into several other scripting languages (mainly Javascript (through the V8 engine) and Python), and they have more serious handicaps for my taste than Lua, and that’s why I keep using Lua.

Some of these seem pretty easy to fix for the developers (or someone that really takes the time to delve into the Lua source-code). Of course, changing these, will it still be Lua? I like to think that it would some sort of Lua+, different yet better. Maybe one of these days I’ll take the time to fix 1, 2 and 4 (well, 1 and 2, 4 might be too hard). If anybody knows someone that’s actually done some of this, feel free to give me a poke! Smile