EDIT: Ooh shiny, a featured page under WP’s roguelike tag. Well I’ve got a newer post up here that’s got some changes from this one, if you’re interested.
Combat is extremely basic at the moment, and not at all where I’d like it, but I have a change of plans. My code has gotten to the point where, although it makes sense from a “I can follow the dots down the line from player input -> game draws to screen” perspective, it seems like each time I make a minor change, the AI’s following behaivor reverts back to doing something odd that I thought I already fixed. Currently here’s the basic game logic loop:
player presses a key (say, a movement key)
Scene.filterkeys() is called
that calls Player.move():
..player.x,player.y, and world coords are set
..generateview() is called -> screen re-establishes what tiles are where and what they look like
enter Scene.update() loop:
..nothing relevant happens, oddly
..nothing important, just sets up which tiles are dirty for dirty rectangle updates
..if entity in list is within bounds of the screen, add to livingspritegroup
set a matrix according to each tile's blocking status within the viewable screen
..do a floodfill of "scent" for collab diffusion followers to hone in on
..move according to scentmap/generateview() changes
exit update, await next input
Its mainly the latter half of the set, where the miscellaneous functions (scent map, etc) are called is where things get messy. At this point I’m going to get down to finding out how to simplify and unify (and probably rewrite) everything, particularly in terms of collision. “When is collision handled?” is not a very easy question to answer at this point in time.