Not NaNo Day 2

One of the main problems I had with Panda3D was around Z-ordering, because conceptually everything is in one layer, even if I wanted to draw things on top of each other and not deal with Z-ordering. And even when I got that figured out, it never quite got figured out, and resulted in some massive z-fighting happening. Even when it shouldn’t be. This was one of the main reasons I decided to use cocos2d, because it’s a dedicated 2D engine, with the ability to make sure layers are always rendered above other layers.

So once I got that figured out, and it took quite a bit of figuring, I was able to move on to other things. The first thing I started working on was mouse input. I was trying to have a selection cursor follow the mouse cursor, but I started working on making a hex selected when you click it first because it was easier to test. Unselecting the hex proved to be more challenging, but made sense once I got a better understanding for how cocos2d’s node graph worked. I needed to remove the old nodes from the graphs, and then I was able to properly have the selection follow my mouse.

cocos2d hex selection.png
The magenta outlined hexes were selected by mouse click.

So now I can actually interact with the map. Yay! This will be the groundwork for being able to build buildings, move units, and similar.

cocos2d hex mouse.gif
Hex hover and selection animation. It looks better on my computer, but WordPress seems to have resampled it. Created with ScreenToGif.

However, there are a couple things still bugging me about it, but I feel they’re more for a polish stage, rather than actually trying to get something working. Namely, the selection doesn’t perfectly align with the underlying hexes, and the hexes themselves don’t align perfectly, likely a due to rounding errors.

The second thing I started working on better generation of the map. As one of the things I want is an infinite map, generating it on the fly will need to happen, because it’s computationally (read: impossible) to pre-generate and store everything. My plan is to generate approximately window sized “round” chunks, try to reconcile the edges with their neighbours (which I’m thinking is going to be harder than I assume) and then add them to the ever growing map.

As an aside, I’d also like to blog some about the project I started in Panda3D, a re-implementation of SimCity 2000 for modern systems, with optional enhancements, and the reverse engineering I did to figure it out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s