As I mentioned last week, I took a few days off over the Christmas weekend, making the week just past a little shorter than usual. Nevertheless, a few things were done:
Work continued on the first scene of the cutscene to the first level, primarily in painting two close-up images of the protagonist, sitting at the bar that fronts the scene. This isn't quite done, but is close, I believe.
On the code-side, I added three new features, two in the game itself, and one in the level-editor:
To the game, as shown above, I added support for objects falling automatically when their support is removed (and when the appropriate flags have been set); this was primarily intended for carriable objects, but may see use elsewhere. I haven't yet tested all cases (for example, I haven't yet tested how it works with doors), but thus far it seems to work fairly well.
Doing this involved reworking elements of certain base "game-object" classes in the game, a prospect that I recall being a little nervous about. I think that I feared introducing serious bugs by altering the workings of so fundamental a set of classes at so late a stage, with so much code already in place. However, I'm glad to say that it actually went fairly smoothly!
There is an issue with the implementation that I have right now: it uses only a simple ray-cast from the centre of the object to determine the point to which the object should fall. This means that if one object falls from above another, with its centre not over the lower object but its edges overlapping, it can end up falling through the lower object, intersecting it.
The obvious thought is to instead use the physics system, with significant constraints to prevent jitter, allowing collision and stopping to happen more or less naturally.
As I recall, I moved away from this when I recently reworked "falling objects" because I found that the small rock that the player can drop in the prologue level seemed to have a tendency to fall through the floor, landing rather too far below; the ray-cast method seemed rather more stable.
I
think, however, that this should only be a significant issue for smallish objects--like that rock; larger objects should be fine. For such smaller objects, I see two potential solutions at the moment: I could have them continue to use the current ray-cast method (since overlaps should be less problematic with small objects), or have them use "continuous collision detection", which should be more reliable, but a little more costly in terms of performance.
I'm still considering whether to switch to using the physics system as I've just described; right now, I'm leaning towards doing so.
The other feature added to the game was support for "display-names". Thus far, I've been using an object's internal, unique name to determine what label should be shown on-screen, drawn from a string-file. However, when there are a number of objects that should all show the same name (chairs, for example), this can lead to a slightly-tedious business of creating the association of each internal name with the relevant string. To alleviate this, I've given each object an optional "display-name": if present, this name is used to find the relevant string to show on-screen; if not, the internal name is used, as before. Display-names needn't be unique, so they allow me to create just one string association for a number of objects.
This was implemented, as I recall, because of the new editor-feature: object templates. In short, these are saved objects that can be spawned in with all of their attributes intact--quite useful for creating a number of similar objects, such as chairs, tables, and so on. The implementation is fairly rudimentary--there's no easy way to edit a template, and deleting one is achieved by just deleting the relevant file in the template directory--but I think that it's likely to prove quite useful in future.
Finally, I discovered two bugs in the code that assigns internal object-names; one was fixed, and the other deemed not worth fixing, I believe.
That's all for this week--stay well, and thank you for reading! ^_^