I have no idea exactly what I was doing on June 28, 2008. It was a Saturday (had to look that up on Wikipedia), which meant I was most likely dividing the day between laundry, video games, and mindless web surfing.

At some point in the afternoon a friend (can’t remember which one) dropped me an IM and sent me to Blizzard’s website. Diablo 3 had been officially announced…all was good and right in the world. Not only that, but Blizzard showed off a 20 min reel of impressive gameplay footage featuring a barbarian doing all sorts of things you’d expect large bearded men with axes to be doing. I was giddy…as were many others.

In the nearly 4 YEARS that have since passed I’ve seen a lot of screen shots, read a lot of rumors, watched a lot of videos, and even gotten a rare invitation to the beta around the end of last October. This is all well and good, but it fails to satisfy a very basic, burning curiosity that even the most patient Blizzard fans are feeling at this point:

When is this f*&$ing game being released?!?!

The last time we got any hint of a schedule, it was back in October. Mike Morhaime (CEO) basically said there was no way the game was going to make it to stores in 2011, and that “early 2012″ was very likely. In the last week, not only has the senior producer of the game left Blizzard, but the lead designer has announced several major changes to game mechanics. Added up, that’s not good…not good at all.

Seeing as how I’ve only got a few friends and we’re all salivating for this game, we’re starting a little bet. Each person picks a month and a year. When the release date is finally announced, the winner (closest guess to the actual date) gets pizza and beer (courtesy of the losers). I wish I didn’t have to include the year…but it seems necessary at this point. Here’s a list of the current players. I’ll keep it updated if more suckers decide to play:

  • Reshen – May, 2012
  • Erik – August, 2012
  • Rob – April, 2012
Update (2/9/12)
Looks like the “estimated” release date was updated during the Activision Blizzard earning call today. Second quarter 2012…Rob and Resh are looking better. :)

I integrated JBox2D into catalyst. It took me a while to wrap my mind around how to handle the bridge between our entity system and JBox2D’s. Essentially, I was having trouble resolving how two different subsystems, who each have their own view of what the world should look like should coordinate. As a simple example, I had positions for all entities defined as my own thing while JBox2D also has its own idea of where physical bodies are located in the world. At the end of the day, the solution was pretty simple – if something has a a physics related component, let JBox2D do its thing and keep track of it. We’ll use hooks back into catalyst to get notified of things like collision, and if we need to query for a given body’s position – we’ll ask JBox2D to look the item up. On the other hand, if a component has no impact on physics, then the plan will be to keep track of it completely outside of JBox2D. I imagine with some well built interfaces for querying components, this additional complexity need not be visible to other engine components or game logic.

Secondly, I was able to quickly integrate a simple camera system with world and screen support with a significant hand up from bensmiley’s blog post. At this point, I only have a passing understanding of the camera class he has built; but it allowed me to use WASD to pan the camera around in the video below. I redefined all game entity sizes and positions in world units (meters) and the rendering engine just uses the Camera class to translate from world units to screen pixels.

Enjoy… Notice the impacts of bullets push zombies back.



For the next sprint, the plan is:

  • Allow the player to move again
  • Detect and handle collisions (bullets cause damage)
  • Figure out world tile system
  • Start thinking about what it would take to do proper path finding (A*)?

I’ve been doing many other useless things; but I’m back now. That’s pretty much it.

I’ve got a simple slick2d project setup, hosted in a private repo by the good guys over at bitbucket, tentatively called Catalyst.

The concept of Catalyst is simple enough: Left 4 Dead meets Grand Theft Auto 2.

So, since I’m a fan of learning from past projects (both good and bad), I’m going to lay out some basic tenets that I’m going to try and hold myself to for this project:

  • Agile development. Work in sprints.
  • Make regular updates to this blog. At least once every two weeks: Post a sprint topic, and a post portem.
  • Always have playable game. I don’t care how stupid or simple it seems, I don’t want to get stuck making neat tech demos. By always having a playable game, I always have something that I can show to someone and have them answer a simple statement: Is it any fun?
  • Set aside a scheduled time each week to make progress. Preferably work a little every day.

In a few days of work, I have a very simple playable demo. Check it out:



Next up, integrate JBox2D and have bullets have realistic force behind them. Close after that will be implementing world and screen coordinates.

It’s been a while since my last sprint, and it’s far past time to get another one going. Lately, I’ve thought a great deal about user interfaces in the context of designing an Uplink like hacker game. It has really bothered me that there doesn’t seem to be a high level of quality when it comes to UI frameworks that are freely available and built on one of the game engines I’ve looked at (pygame, lwjgl, etc). Queue the state of the art in UI frameworks – HTML5 + CSS3 + Javascript. So, can a compelling game experience be delivered via a browser? What do the components look like? Where does the logic go? Can performance be on par with a native game? Can I use an alternative language to javascript? Let’s go exploring by starting with two recent Google I/O videos that cover this very topic:

This sprint:

Completion criteria: the above delivered to an appspot URL linked from here.

Meanwhile, two months later…

I won’t even bother with an explanation. Lets just say life gets in the way and leave it at that, shall we? So what do I have to show for 10 weeks worth of sporadic effort? Not a whole hell of a lot, actually.

All of the simple interactive features I wanted to include in this demo were dropped simply because I lost interest after awhile. The primary objective here was to do something useful with shaders and gain some insight into the complexity they add to the dev pipeline. I can honestly say I accomplished at least that much, but I’m left me with noting but a YouTube video and some poorly commented code. The former is linked below, the latter may get posted later if I can find time to clean it up a bit.

Here’s a couple notes:

  • As far as I can tell, the code posted with the GLSL shader example on the LWJGL wiki doesn’t work. I used the it as a starting point for my code but had to modify it pretty heavily just to get something basic functioning. Not sure if I’m missing something there or if the sample code is supposed to be used with an older version of LWJGL.
  • Debugging shaders is a royal pain in the ass. No code stepping. No printf. No nothing. Thankfully it’s easy enough getting the shader compiler to spit out an error log so you at least know when the code has syntax errors. After that it gets pretty painful. The only real feedback provided is what’s rendered, so if nothing shows up on the screen for some reason (which happens frequently with new code), then you get to guess a lot. There are a few tools that can help with profiling and spotting performance bottlenecks, but given what I’ve come to expect from Eclipse’s debugging capabilities, it’s a bit of a shock trying to get useful feedback from a shader.



This is a follow-up post to Entity frameworks.

Adam, over at T=Machine, wrote a great series on Entity Frameworks based on his experience. The first part in that series is entitled Entity Systems are the future of MMOG development – Part 1. He posted a sample Java Entity System on Github which I forked into my own EntityProject. In fact, he created an entire wiki, http://entity-systems.wikidot.com/, dedicated to this topic.

Adam noticed that I forked his project and was kind enough to provide a brief code review and some feedback. That kicked off a chain of e-mails between us where we were discussing various concepts around Entity Systems. The largest thing I was struggling with was how to manage the relationship between components of the same entity at runtime. I believe that there is room for a relationship scaffolding, while Adam’s vast practical experience in this area indicated that that was actually entirely unnecessary when it came to real games. Paraphrasing his argument: any sort of complex relationship amongst components generally requires custom code anyway, and that a modern game has to define those relationships concretely simply due to the fact that you need to implement something at the end of the day. Anyway, for those interested in the gory details, the full e-mail chain is provided below. I apologize for the complete lack of editing ;-) .

Reshen -> Adam:
I’ve spent a great deal of time thinking about your blog posts on the topic recently; and as you have seen, I forked and made some very minor changes to your example implementation. I am planning on iterating my fork until I reach something I’m happy with.

I agree that traditional OO game object complexity scales very, very poorly. That’s just a fact of OO – the more derived classes you have, the easier it is to fall prey to promoting data and members up the tree until you have unwieldy and inefficient base classes.

Conversely, I think that ES are poor at managing the run time relationships between objects. This is an inherent problem to relational data design. Consider the following trivial (2D) example:

Rectangle component (width, height)
Circle component (radius)
Position component (x, y)

Game entity 1 (Alice): Rectangle, Position
Game entity 2 (Bob): Circle, Position
Game entity 3 (Charlie): Rectangle, Circle, Position

Alice and Bob are easy. Charlie introduces some subtle complexity. Specifically, ES are poor at describing the relationship between Charlie’s Rectangle and Circle. In OO, you would have one take ownership of the other and define custom behavior for how one treats the other. In ES, the analogy is that you would have some kind of foreign key constraint between the data – which would pollute one of the base components with an unnecessary member. Alternatively, you could have a RectCirc component that has foreign GUID keys to the two children; but that seems silly to me as well.

I guess my point is that I’m coming to the conclusion that there are really 3 pieces to my ideal game object framework:
1. Pure data objects (as your components are defined)
2. Pure behavior objects (as your subsystems are defined)
3. Pure relationships between data and/or behaviors (not yet defined)

I’m trying to come up with an elegant way to define Charlie dynamically. That is, (#1) create pure data objects, (#2) leverage subsystems to do the reusable behavior, but (#3) allow any of the following relationships to be defined when creating Charlie : rectangle is inside of his circle, circle inside of his rectangle, or the two render next to each other. I think the solution lies in creating a separate ComponentRelation framework – I’d like to hear your thoughts.

Sorry for ranting so long =). I really do appreciate your time and any cycles you put into thinking about this.

Adam -> Reshen:
Ah, OK, I see. It’s giving you a seamless, fast aliasing / shadowing
at the Component level, right?

When talking to beginners, I tell them to stop worrying and ignore it.
I tell them to make (say) a CameraHolder component that contains a var
of type UUID, which you assign the UUID of the entity the camera is
currently “attached” to. It works, and requires no changes to the ES.

There’s an obvious problem to this feature (no matter how you do it)
which I think is why I tended to avoid this approach in recent years:
you’re (implicitly) saying that writing to a Component is no longer
side-effect-free. If you attempt to write to that Camera’s version of
the Component, what happens?

At a more advanced level, there’s a definite problem in the basic
approach, which I guess is how you got interested in this? You can no
longer simply stream data direct into a subsystem and say “here’s all
the entity/component mappings you asked for; process one frame’s
worth”. Instead, you have to resolve some sub-lookups. A few of those
is fine; OTOH, if you have 1,000′s per frame, that’ll undo the
performance benefits you had from streaming/cache-efficiently
processing the components.

IIRC in C++ we (ab)used custom pointers and had the overarching
EntityManager intelligently scan the component lists and de-ref any
special pointers once per frame, just before sending the
lists-of-components/entities to the subsystems for processing.

Off the top of my head, if I were doing a lot of aliasing, I’d
probably start with a similar approach again: i.e.:

- EntityManager is responsible for this
- it’s invisible to the main ES/framework/thing – you can only tell
the existence of these “linked” components by querying special methods
in the EntityManager class
- when a subsystem receives it’s once-per-frame list of components,
the EntityManager guarantees to have already pre-resolved/unified any
linked components, so that they *appear* to be ordinary
- in Debug/Development mode, you run a check after each frame just to
make sure no subsystem wrote to any fields of a linked component,
except in the master version of that component
- …or, of course, if the language supports it: you’d pass in the
“linked” components as read-only data structures, and let the
compiler/runtime throw an exception if writing was done when
disallowed

…but I’d first try to avoid the issue altogether, I really like
having writes to components be side-effect-free :) .

Reshen -> Adam:
Concerning the formatting, I don’t mind making the small fixes to your example implementation. It’s up to you – if you want me to take that on, feel free to add me as a collaborator to your git project and I’ll hand patch my minor fixes over to a dev branch in your project. You can take a look, and when happy, merge them nicely into your master (aka trunk) branch.

I’ll definitely update the two wiki pages with my thoughts: first to suggest the UUID usage in java, and second to have a more general experience/discussion page after using the example framework.

Concerning the relational framework item below: what I’m really trying to drive for is the analogy in ES to the publisher/subscriber design pattern – components are loosely coupled. I’m specifically talking here *not* about their behaviors – I understand behaviors are kept strictly in the subsystems. What I’m talking about is replacing the RDBMS foreign key constraint idea with a dynamic foreign relation. This is analogous to an RDBMS’s Junction Table – http://en.wikipedia.org/wiki/Junction_table.

Allow me to illustrate with, hopefully, a more concrete example:

- Game components with GUID #1 : Camera, Position
- Game components with GUID #2 : Player, Position
- Game components with GUID #3 : Bullet, Position

Now suppose I have a subsystem called “RelationalBehaviorSubsystem”. One method thats part of RelationalBehaviorSubsystem is copy(Component src, Component dest). As the name implies, copy simply copies the contents of src to dest.

Now suppose I have an EntityRelation framework, for now – its a single class with the following constructor: EntityRelation(Component A, Component B).

You can probably see where I’m going with this: I can now create an EntityRelation component :

- Game component with GUID #4 : EntityRelation(GUID#1 Position, GUID#2 Position)

Now, when the RelationalBehaviorSubsystem udpates, its going to query for all EntityRelation components and perform some behavior on them. For now, the only method thats available is copy – so copy is applied to all EntityRelation components.

I now have a dynamic and easy way to attach the Camera’s position to either the player’s position or the bullet’s position – and best of all, I can do this dynamically by updating GUID #4.

Here is where my argument falters : Without allowing a type explosion in EntityRelation (CopyEntityRelation / FooEntityRelation / etc); how do I easily tie EntityRelation to a specific subsystem behavior? (This question is rhetorical, but feel free to chime in with an answer =).

Anyways, I think it might be best to defer to your experience here and just stick strictly to what you’ve recommended. Perhaps at the end of the day, it turns out that for all practical implementations, the complexity of introducing junction tables (aka EntityRelation framework) don’t really add value. The elephant in the room is that real game objects inevitably need subsystem specific code to handle them. Games rarely do the infinite recomposition of components.

Again, I’m grateful for your time and thoughts.

Adam -> Reshen:
PS: I’d advise putting some of your ideas/thoughts on this on the Wiki
- it’s low traffic at the moment, but it’s a great place to write down
what you think you’re doing and why, and get other people to critique
and modify it.

(I started it largely because the blog posts are too static – they
don’t give enough power for other people to come along and correct my
mistakes. e.g. some of the naming I originally used … people have
suggested some much better names. Or e.g. your use of UUID (I didn’t
know that existed ;) ) – the description of *all* java implementations
on the wiki ought to be updated to say “use UUID for entity id” IMHO)

>
> I’ve spent a great deal of time thinking about your blog posts on the topic recently; and as you have seen, I forked and made some very minor changes to your example implementation. I am planning on iterating my fork until I reach something I’m happy with.
>

Yeah, I’d like to merge some of the changes, but the re-formatting
checkin has upset github. It’s saying all future merges will probably
fail. If formatting is a big issue for you, you can setup eclipse (and
git, if you want) to auto-format code however you like (it’s been a
while since I’ve done it, but all the big projects I’ve worked on, we
had an SCM-formatter for Eclipse, and a pre-checkin-hook that would
reformat code with it. That way, everyone could view code however they
wanted, and yet merging worked OK).

I’ll just have to do copy/paste merges by hand when I get the chance.

> Conversely, I think that ES are poor at managing the run time relationships between objects. This is an inherent problem to relational data design. Consider the following trivial (2D) example:

In practice, I see nothing wrong with your example. The ES works
perfectly – the situation you describe is common in live games, and
typically presents *no* problems. If something is both a Circ and a
Rect that’s 99% likely to be because “in one context, it’s a Circ”,
“in a different, unrelated, context it’s a Rect”. The ES supports that
behaviour beautifully (and handles it a lot better than multiple
inheritance would :) ).

In the rare cases where you genuinely need an entity to have two
conflicting sets of data within the *same* context, you’ve got an
interesting problem, one that often means you’ve designed your code
poorly (and should re-think it), or that you genuinely need a
“RectCirc” component, because your algorithms are going to have to
special-case this weird “Circ + Rect thing” anyway.

> 3. Pure relationships between data and/or behaviors (not yet defined)

I strongly strongly advise: DO NOT GO THERE! (ALL CAPS!!!!!!111!! ;) )

Think about it. With 3 above, you just described the core concept of
OOP: “Objects are: data + methods that act on that data”. It’s an
awesome and powerful tool – but do you need it?

My experience from game teams suggests that with games the answer is:
“No; we’re just so accustomed to using it that we sub-consciously keep
trying to use it, even when we’re consciously trying not to”.

> allow any of the following relationships to be defined when creating Charlie
> : rectangle is inside of his circle, circle inside of his rectangle, or the two
> render next to each other. I think the solution lies in creating a separate
> ComponentRelation framework – I’d like to hear your thoughts.

Simply put: why do you *need* this?

No matter how gray the region between writing “game code” and “game engine code” gets, OpenGL has long been one of those APIs that made the distinction simple. If you’re calling OpenGL directly, you’re writing “game engine” code. This distinction is important because for every developer interested in writing code for a game engine, there’s probably a hundred more who just want to write a game and rather not worry about the gory details of rendering quads and triangles. This distinction becomes even clearer if you ever actually try to get OpenGL to do something useful…which brings me to shaders.

The programmable graphics pipeline has been a mainstay in game development for the better part of a decade and has enabled some truly awesome visuals in countless titles. But shader programming adds a layer of complexity to graphics development that I’ve never been able to completely wrap my head around. The concept is easy enough to understand, but in practice things get a little hairy.

For instance, I’m currently staring at some sample code from an intro tutorial on the LWGL wiki.  It’s designed to show programmers the bare minimum amount of Java and OpenGL shader code necessary to make SOMETHING show up on the screen. The program simply brings up a window and draws a white box against a black background. There’s no less than 250 lines of code spread across three files in this example. If you take out the code to draw the box, you only knock it down six lines. That’s a lot of code just to get a black screen. :)

Regardless, I think it’s about time I man up and dive into shaders head first. Not only because the fixed function pipeline had been deprecated or removed from most modern rendering engines (Nintendo game consoles notwithstanding), but because pretty graphics make people happy…myself included. There’s also a lot of nifty effects I’d like to be able to add to some projects now and in the future. So with that said, here’s the particulars on my third sprint:

Technical Area of Exploration
Shader programming in GLSL


Goals

  • Create a simple program that allows the user to place two points on the screen.
  • Between those points, draw a layzor beam. That’s right, a layyyyzor beam. :)
  • Allow the user to change various characteristics of the beam such as width, intensity, color, etc.
  • Render the beam using vertex and fragment shaders.

 

Due Date & Retrospect Writeup
4/17/2011

Tools of the Trade
Java, Eclipse, LWGL, OpenGL, GLSL

In preparation for creating my own entity framework, I’ve been reading many articles, blogs, and forum posts on the topic.  Some of the best ones are linked below.  Generally, I’m not a big fan of not reinventing the wheel; I’d rather just use a FOSS framework.  However, in this case I think there is a lot to be learned from rolling my own and it isn’t a terrible amount of code.

As with all things, there is no perfect answer.  But, there are two resounding lessons that years of experience from other game devs seem to agree on:

  1. Using inheritance for game objects doesn’t scale well as the quantity and complexity of game objects increase.  However, if you can answer the following question in the affirmative, then inheritance is probably correct: does every single inheritor require the inherited functionality?  A good example of this is a globally unique identifier (GUID).  Every entity in a game has a valid use case for having a GUID.
  2. Using composition allows an entity to aggregate just the functionality it needs.  However, the associated penalties are that an entity is spread across multiple runtime objects who would like to know nothing about each other.  Unfortunately, you will have cases where the components are strongly dependent on one another at runtime, perhaps even dependent on the order in which they are executed.  The bottom line is that you might need to dirty up your clean architecture such that components use each other directly, thus negating the idea that components are completely disjointed.

For now, I still haven’t finalized the design for my hopefully reusable, light weight framework.  When I do, I’ll certainly create a follow up post.

Well damnit all…so much for Friday deadlines. To be fair, I had the code for this sprint working and tested on Sunday afternoon, therefore it’s technically only a day and some change late (like that helps). Future sprints will definitely have Sunday deadlines, that way I can put it off all weekend and not feel guilty until Monday. I also had to spend extra hours on this one figuring out how to embed a Java applet into a WordPress post. It really doesn’t look half bad…and by that I mean it doesn’t look like an applet. :)

The goal for this sprint was simple: get a Cartesian grid drawn up with Processing and Java using custom units (1m = so many pixels).  I got three basic features implemented on top of drawing the grid itself in order to help test it: panning, zooming, and the ability to draw a line by selecting two points. So in retrospect, here are a couple tidbits for future reference:

  1. I had initially wanted to use the mouse scroll wheel for zooming but couldn’t because the Java applet mouse input callback functions don’t recognize the scroll wheel. Seriously, they just don’t know it’s there. A bit disappointing.
  2. Processing doesn’t really have a “layer object”, everything is drawn onto the same canvas using the Painter’s model. This is fine for basic sketch’s but makes more complicated app development difficult. This only took a few days so I may be missing something about Processing here.
  3. Processing doesn’t let you call drawing functions from PGraphic and PShape object instances. In other words, you have to pass a reference to the program’s PApplet instance to every object that you want to have drawing capability, and all the drawing output ends up on the same canvas. Again, I may be missing something, but this is very annoying.

For all the gripes I have about Processing, it did get the job done and is a very capable 2D drawing library. Here’s the demo applet for this sprint along with some control instructions:

Zooming: Left click (zoom in), right click (zoom out)
Panning: Hold left click and drag
Draw a line: Middle click once to place first point, again to place a second

It’s time.  Actually, it’s far past time.   I should have written this blog post about 10 years ago, and I should have created and released a game closer to eight years ago.

But, hey, they say that late is better than never, and so here goes.

I started with a simple enough goal.  Replicate the code matching mini-game that Mass Effect 2 implemented.  For those unfamiliar, you can see a video if it in action here. At any rate, 10 hours later and some basic experimentation with several engines, I changed my mind and started to implement an even more basic task: create a polygon (triangle) on a 2d surface, allow it to be selectable via left click, and movable to a destination via right click. Really, really basic functionality to anyone who has played an RTS. Over the next week, I implemented several variations of this in a bunch of different engines. I learned alot along the way, including a list of critical engine features that I’d rather not live without.

So, that’s what I’m going to talk about. Features and my impressions of the engines I tried.

Here is a list of must-haves, ordered from most to least important.

  1. Production level engine. I’m not going to pick something that doesn’t have at least a few years of active development with a well established user base.
  2. Unrestricted licensing, access to all source code. I’m not going to pick a closed source engine nor am I going to pick something that requires me to shell out a bunch of money. I believe there are plenty of good engines that meet this criteria.
  3. Well documented. I write software for a living, and so I realize the value of well documented APIs, an active forum, an easy to navigate web site, and a community owned wiki. In this day and age, if you can’t manage these basic things, you ought to take a serious look at the quality of your product.
  4. Performance. My code should be the performance bottleneck, not the engine its built on.
  5. Newer programming languages. While I’ve done plenty of C and C++ in my career, I really enjoy things like garbage collection, extensive libraries out of the box, and simple cross platform compilation. I think C/C++ make you a good programmer because they force you to be disciplined; but the reality is, I want to create something quickly, and I’d rather spend time implementing a neat new visual effect than tracking down a memory leak or heap corruption due to buffer overflow. Towards that end, I will be mostly focused on Python and Java engines. I may briefly consider C++.
  6. Physics. Ideally, the engine I choose already has APIs to a physics library. Box2D support would be ideal.
  7. Basic geometry drawing. I expect basic 2d shape drawing out of the box. Like everything else, I can do it myself, but its much faster if there is a robust lib already in place.
  8. User Interface support. At some point, I’ll need some significant UI elements in my game. It’s not interesting to write text wrapping or sliders or any of that stuff. The community should have already created some libraries for basic UI elements.

I’ll tweak the above list as things occur to me, but in the next post I plan on talking about my brief experiences with PyOgre, PyGame, NodeBox, and Slick2D.

© 2012 Gray Lantern Suffusion theme by Sayontan Sinha