Dynamite: Day 8 – Player and Guard movement
So far today I’ve just been doing some cleanup in my code. I’m about to add a “play” mode so I can try out my levels, which involves having information easily available to know what is solid or not. I’ve updated my tiles.json file to include that information on a per-tile basis, and I’ve used that along with some other things to clean up my rendering code as well.
I also am considering having the ability to rotate the screen 90 degrees. This way you can see behind walls easier. I had considered other options like a “short wall” mode or whatever, but it all started seeming really un-cool. Here’s a picture of the short-wall mode:
You can see really easily in this picture how light can leak through walls (those short ones). I haven’t decided on my solution to that problem yet. I think I’m going to have to get this running on the iPad, maybe at the end of this week, and evaluate how fast it is running and if I can afford to do more complex lighting.
Was about to get after getting the game playing, but I’m finding that jsoncpp is crashing during shutdown of my program. I’m getting a traceback like:
pure virtual method called
terminate called without an active exception
Program received signal: “SIGABRT”.
(gdb) backtrace
#0 0x97803ef6 in __kill ()
#1 0x97803ee8 in kill$UNIX2003 ()
#2 0x9789662d in raise ()
#3 0x978ac6e4 in abort ()
#4 0x975b7fda in __gnu_cxx::__verbose_terminate_handler ()
#5 0x975b617a in __cxxabiv1::__terminate ()
#6 0x975b61ba in std::terminate ()
#7 0x975b6753 in __cxa_pure_virtual ()
#8 0x00016cd4 in Json::Value::CZString::~CZString (this=0x33a180) at /Users/phil/code/idynamite/osx/../ext/json/json_value.cpp:199
#9 0x0001e06b in std::pair
#10 0x0001e089 in __gnu_cxx::new_allocator
…
Turns out this is due to some sort of bug in jsoncpp which makes it not work as global variables. Which I guess the old notion that global variables are bad news is hard to get away from. So I wrapped up all my json away from being globals and it works fine now. Less globals is certainly a good move, whatever the case.
Next off, I’ve now added a toggle to switch between editor mode and play mode. The editor saves the level state so that whatever happens during play doesn’t permanently damage the level.
With a bit more work, I’ve got the “play” mode starting to take shape. The player now walks to the tile you click on!
And now I’ve got a guard running around me like a crazed maniac. The arrows on the floor are special codes that tell the guard where to run.
I’ve also got animation going on the guards and the player, just sorting out some bugs on those. Tomorrow I hope to get a win condition and a lose condition and some more explosives going 🙂
-Phil