RSS
 

Archive for September, 2011

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!

 
 

Deus Ex: Human Revolution

26 Sep

vg79715_deus_ex_wall_adam1

I’m a big fan of the first Deus Ex… it was one of the first games to feature “emergent behavior” as part of the design. You had the feeling that all the problems had different solutions, and you could tackle them in a variety of ways, much like pen-and-paper role playing games.

Then I watched “Deus Ex: Invisible War” turn a beloved game into a mockery of his former self, with huge amounts of bugs, silly AI, and a dumbing down of the overall concept (to appeal to more people, I guess).

So I was kind of divided about “Human Revolution”… on one hand, I hoped they would go with the legacy of the first one, on the other hand, I was fearful they would turn it into a cover based shooter like so many others…

Thankfully, they went with the better choice: Human Revolution follows in the footsteps of the first one, which is great news for everyone that loved it!

The game has plenty of faults (which I don’t remember the first having, but that might be the age-goggles speaking):

  • Although this game is a prequel to the first Deus Ex, the game feels more modern that the first one, not just because of the graphics, but because of the general tech level of things… The augments seem more primitive than the first Deus Ex, but the overall environment seems more futuristic
  • Loading times are huge (on the XBox, at least)… that might be mitigated by installing the game in the HD, but since I have one of those old XBoxes, I don’t have the HD for it and I’m not buying a new one anytime soon… This is very noticeable since you tend to reload a previous savegame to try to get through an area without being detected, which implies some trial-and-error…
  • The voice of Adam Jensen is terrible… well, overall the voice acting is terrible… all characters seem to be stuck in just one emotion (whatever that one is) and it doesn’t match up to the graphics – for example, there was one woman crying and very disturbed by something, but her model was smiling! It didn’t seem the least bit distraught, and that kind of spoils the emotional bond… In the case of the main character, he seems to be pissed off at something, even when he’s trying to be empathic or nice to someone… It reminds me of someone that took lessons in the “Christian Bale School for Actors”… It was trying too much to be dark and gritty.
  • The game world is too empty… You have great cities, loads of space for wandering, even a kind of sandbox groove to it, but nothing happens there… there’s just some side-quests (that are extremely linked to the game plot anyway)… I’d like to see more stuff happening; sometimes I’d wander around town and think to myself: “I wish there was some “clear the gang activity” quest here.”. I understand that the main character is probably too important for that (it would be kind of silly to have someone as important running errands), but if that’s a problem, maybe they should have built the game the other way around: start with an insignificant character that grows in importance.
  • The main character was too dumb… There’s nothing worse than you having connected the dots for ages now and the main character still acts completely oblivious to the situation… Five or six hours into the game, you’d already have a good idea on who the bad guy was, but Adam would happily run errands for him anyway…
  • Story was too convoluted… I know the idea is to build a good “conspiracy theory”, but it reaches a point where you can think of at least 10 different ways the “bad guys” could win without getting so complicated at it… Most of the game just seems like a prelude to the inevitable (and totally predictable) backstabbing…
  • Worse of the worse: the boss fights were stupid… This is a game mainly aimed at stealth (at least for me), but the only way to defeat the bosses was by shooting… no smart thinking, no stealth, not intelligent use of the environment… Nope, plain old “shoot-the-bastard-until-he-dies”… This is particularly nasty if you (like me) haven’t invested in combat skills, preferring to spend your upgrades in hacking and stealth. This is a stupid design decision; it breaks the entire core of the game and just frustrates the player – it’s not a challenge if the game is actually cheating by design!

 

But… even with all these faults, it is a great game… It took me about 16-18 hours to finish (which is good value for money in this day and age of 8 hour games), without me ever thinking “Will this never end?!”… Good area design, with plenty of options and choices to go around, depending on how you like to play (could have some more stuff for the hacker-ish)

If I notice all those problems in the game is because I feel the game could have been much more, but what it is is enough… Hopefully this will not be the end of the saga, and I wish in the future someone does a kind of cross between Deus Ex and the sandboxing of GTA (that would be totally sweet!).

Special mention to the music of the game… although it’s a complete rip-off of Blade Runner’s OST, it’s very good at establishing the mood…

After playing this one, I just feel like making a cyberpunk game and listen to some Billy Idol’s “Cyberpunk” album, while reading some William Gibson… Smile

Overall, it’s a 9/10 game, for those that like scores! Smile

 
No Comments

Posted in Games

 

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

 
 

The emptiness of space….

21 Sep

Everybody that knows me know that from time to time I get this urge of making a space opera game… The actual form of that space opera varies, from “Star Control 3 type”, to “Geometry Wars in real space”, to strategy combat, to more action-oriented, sometimes going on planets, other times in outer space only… All of them feature wandering about space, giving it a sandbox feel.

I usually spend some time day-dreaming about it, designing it in my head, etc… then some other more feasible project comes along and I forget it.

But one thing I always tend to get stuck in my head is a big problem: space is empty… Real space is boring,

Read the rest of this entry »

 
2 Comments

Posted in Games

 

Talk like a pirate…

19 Sep

Today it’s “Talk like a pirate day”, and a friend of mine reminded me of an Easter Egg we added to the unreleased game “Blitz and Massive”…

The game, on every 19th September would activate the “Pirate Talk” mode, which would add some phrases to the dialogues, and change some other words to match pirate talk:

Screen00001

Screen00002

One of the many Easter eggs we’ve built into the game… Open-mouthed smile

Shiver my timbers!

 
No Comments

Posted in Games

 

Win32 Tree Component

16 Sep

For SurgeED, I’ve had to build some tree views:

tree_view

I’m using the Win32 C API to build the GUI, but the TreeView control available didn’t support everything I needed (or supported it in such oblique ways it was too much work). I tried finding a control like this on the Internet, but either they cost money (which I can’t afford), the functionality wasn’t there, or they used MFCs (which I don’t like).

I decided to build my own, on top of the Windows one, and make the code available.

My tree view supports:

  • Multiple selection
  • Drag/drop operation
  • Context sensitive pop-up menu
  • Callbacks for
    • Selection
    • Command (WM_COMMAND message)
    • Drag operation (start/finish)
    • Popup called
    • Sort operation
    • Size change

 

You can download the files here. They probably don’t work “out of the box”, some helper functions are missing, and probably some includes need to be removed. Anyway, it should be easy enough to extrapolate what’s missing.

Some usage instructions (check .h file for the public interface):

  • To initialize (register the window class – you have to create a define called SURGE_TREE_VIEW with the name you want the class to have internally), you have to call “scc_register_tree_view()”. To unregister, call “scc_unregister_tree_view()
  • To create a tree view, either use a custom control (with the class set to whatever the name was), or something like:

 

HWND tree= CreateWindow(SURGE_TREE_VIEW,window_name,window_flags,
                        x,y,width,height,parent_window,NULL,instance,0L);

  • To enable/disable multiple selection, call “scc_set_tree_view_multiselect(tree,true/false)
  • To set a callback function, use “scc_set_tree_view_*_callback
  • To add nodes, you have to use "scc_add_node”. This takes as a parameter an object of type SurgeTreeNode (more on this later). This will add the node at the top level of the Tree View. To add elements as sub-nodes, use the “add_node” function on the SurgeTreeNode you want to be parent of this one.
  • The SurgeTreeNode is the base class of all the nodes in the tree. You should subclass it for “type of nodes”. For example, on the Component Explorer of SurgeED, I have loads of classes (“Project”, “Component Group”, “Component”, “Group” and “Entity”). All of these can have different options on the pop-up menu, have different behaviors on drag, etc.
    • add_node: Adds a subnode to this node
    • remove: Remove a subnode from this node
    • expand: Expands/contracts this node
    • toggle_expand: Expands the node if it is contracted, and vice-versa
    • select: Selects this node (and the nodes below, if the second parameter is set to “true”). Note that for this to work correctly, when you select a node, all the nodes below it are unselected (or else we could have some weird behaviors on the drags), although they are still highlighted (like they are selected because someone up the chain is selected)
    • toggle_select: Selects this node if it is unselected, and vice-versa
    • update_label: Forces a refresh on the label of the node
    • set_bold: Sets the label on this node to bold
    • (Virtual) get_label: Returns the label of the node
    • (Virtual) evt_select_change: This function is called whenever this node is selected
    • (Virtual) is_draggable: Should return true if this node can be dragged. Only if all nodes in the current selection can be dragged can the operation be executed.
    • (Virtual) try_drag: Should return true if this node can be dragged to the given target node
    • (Virtual) can_accept: Should return true if this node can accept all the given nodes as sub-nodes
    • (Virtual) notify_drag: This function gets call for each node that is dragged onto the target node, when the drag operation is completed (don’t have to do anything to change the structure of the tree itself, the nodes will be moved to the correct place)
    • (Virtual) get_menu_options: fetches a list of strings with the names of the options to show up on the pop-up menu. Only the options that are shared by all the selected nodes show up.
    • (Virtual) handle_menu_option: Gets called for all selected nodes when an option is selected.

 

For the record, you can use this code in any way you want (commercial and non-commercial), a heads-up and thank you would be nice.

I’m not responsible for any damages and bugs! Smile

Anyway, if you have any questions, just shoot them here or email me…

Hope this is helpful!

 

Sound woes…

14 Sep

My artist has been ill these last couple of weeks, and as such I’ve done nothing on “Amoeba” lately… It’s hard staying motivated when working alone on a project (at least for me).

sample01

Anyway, since he’s back I decided I should try and get this game finished (still don’t know what I’ll do about the music and from the commercial perspective)…

The main thing on this project (for me at least) is getting experience on mobile platforms, and to release this on multiple platforms (first on iPhone, Android and PC, then Mac/Linux, and finally WM7), and that part of the plan has been working as intended – although only really experimenting on Android and PC).

As I’ve said before, I’m using Marmalade to be able to build the game using my existing engine, Spellbook. So far, it’s been a pretty decent experience, I’m using Spellbook to build the game itself, and I just have a very thin abstraction layer that wraps Marmalade, but has the same interface as my main deployment platform (DX9+FMOD+DirectInput).

But, alas, finally I’ve found problems, with the sound component. The sound API of Marmalade is very poor (understandable, since it’s not very important in the mobile market), and only supports 16-bit PCM RAW files. This requires you to know the sample rate of all the sounds when you play them out (instead of loading that information from the WAV header or something). Of course, this is not the focus of Marmalade, but since they wasted so much time on the graphics APIs, they could have been as complete in the sound API). They have support for compressed audio, but only for the streaming API.

This is particularly bad for someone like me, that’s been using FMod for ages, and I’m used to just loading samples with one call, and playing them with another…

Anyway, it’s relatively simple to do a WAV or some other uncompressed format loader, but for “Amoeba” I can skip that and use RAW files playing at 22Khz… I’ll have to change this for the PC version (which can use FMod), but for now it’s good enough.

The real problem I’m having is not related to Marmalade, but with the sound system of the Android handhelds… There’s a huge latency between the call to the sound player and the actual sound playing (in some cases, almost one second). Some searches online lead me to believe that this is a problem with Samsung mobiles, but it’s a serious flaw, since even 200 ms lag time in a game can make everything look much worse… I’ve even ran “Angry Birds” on my Samsung S, and although I didn’t notice it before (it’s subtle in the case of that game), there’s a delay present aswell, so I believe it is unavoidable… Going to try it on a Google Nexus phone in some days to see if the problem is exclusive to Samsung’s implementation of Android… if so, I’ll have to rethink sound in the game, since it can become annoying, doing things and getting the sound feedback 200-500 ms later…

On other notes, I’ve also did some memory profiling, trying to see if I have memory leaks or anything, but I found a problem that got me stumped… According to the ARM emulator, I have about 4 Mb allocated (plus another 4 Mb on OpenGL textures), but my task manager on the Android shows about 40 Mb allocated (more precisely, when I close the application, I get about 40 Mb back). I’m not sure if the Android stack pre-allocates some amount of memory, even if I don’t use it, and I maybe can adjust that on the manifest (saving that for later in the project); but I’m very sure that I don’t allocate 40 Mbs of data on my game!

But hey, no memory leaks! Smile

 

The hiatus

12 Sep

Hey all!

I’ve been neglecting (again) my blog… but I got good reasons! Smile

One was my birthday, which implies a lot of partying… My wife got me a neat video camera (I’ve been lusting for one for ages!), a Cannon Legria:

l_09822270

It has nice quality… maybe on my next Ludum Dare 48 hour compo I’ll manage to use some rotoscoping or live video to make the game sprites… Smile

Anyway, after that excuse runs out, I’ve been having too much fun playing around with my editor! I can only work on it on my spare time (when I also write this blog), so when I get into the zone I tend to not deviate from it.

From a practical standpoint, just added some options to the light system (soft shadows, through PCF) and moved the light creation to the a new “Instance entities” tab on the toolbar. It makes sense, since there’s nothing different on the creation of the light and the other entities. This way the GUI becomes more organized (and more akin to 3d Studio Max, aswell).

Most of the changes in the editor was the updating of resources. Now it is possible to reimport some assets and have them replace the existing ones, which is really cool!). Was thinking on live update (modify the resource files themselves and have the system update), but decided against it. The editor is built on the idea of being a self-contained “project”: it has its own directory structure, naming schemes, etc, so I don’t want the artists/level designers to be able to change things around… too much potential for disaster, in my opinion… I rather have them export the assets to some temporary directory somewhere on their hard drive, and explicitly import the assets into the project. It requires an extra step (or two, since the system asks the user if he really wants to update the assets), but I think its not a big deal. Anyway, if we see the benefit in this, I can add an option for a live-link, which are files that get imported automatically as soon as they’re modified (without asking anything, etc). Also want to add live update of textures (since that’s a different resource type, we can afford to break the coherency of the system for that, since they get copied to the project itself).

The editor is coming along nicely, its already considerably powerful and it works pretty well (still has the occasional crash, but since the system auto saves almost continuously, it doesn’t cost the artist anything). Next step on the development map on it is helper objects (with object linking/sub-objects and sub-classing working properly). I’ll make a video then (a better one than the last, with narration!).

Anyway, I’ll do an effort to be more regular at updating the blog… Smile