{"author_link":"\/users\/f1krazy","author_name":"F1Krazy","author_uid":"f1krazy","comments":[],"epoch":1620474599,"event":"LD48","format":"md","ldjam_node_id":256338,"likes":3,"metadata":{"p_key":"157751","p_author":"F1Krazy","p_authorkey":"1071341","p_urlkey":"377998","p_title":"BreakEven - The Techy Stuff","p_cat":"LDJam ","p_event":"LD48","p_time":"1620474599","p_likes":"3","p_comments":"0","p_status":"WAYBACK","us_key":"1071341","us_name":"F1Krazy","us_username":"f1krazy","event_start":"1619222400","event_key":"109","event_name":"Ludum Dare 48"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD48","removed_author":false},"_superparent":233335,"_trust":11,"author":71341,"body":"First of all, a big thank you to everyone who's played and rated *[BreakEven](https:\/\/ldjam.com\/events\/ludum-dare\/48\/breakeven)* so far! I plan to start rating other people's games later today - I have next week off work, so I'll have plenty of time to devote to it.\n\nFor now, though, it's time for my usual breakdown of some of the more technical aspects of *BreakEven*. Considering what a nightmare it was just to get this game working, this ought to be interesting.\n\n![screen1.png](\/\/\/raw\/da6\/11\/z\/42487.gif)\n\n### The AI ###\n\nEnemies that can freely move in 2D space are something I have never done before, and something I figured I should probably learn how to do. It turned out to be quite possibly the most time-consuming feature I've ever programmed in a Ludum Dare game, partly because of how long it took to debug and optimise but mostly just because it required *so. Much. Code.*\n\nThe AI uses an implementation of the A* algorithm that I took from an online tutorial and modified to work in TIC-80. Once a second, the game generates a \"world grid\" with the locations of all the walls and hazards, and feeds it to the algorithm along with the player's position. The algorithm then generates an optimal path from each enemy to the player. Enemies will continuously move along this path, moving closer to you until they reach a certain distance.\n\n...in theory, anyway. In practice, the AI seems to just run around in circles until it gets stuck against a wall:\n\n![ai-is-bad-2.gif](\/\/\/raw\/da6\/11\/z\/42483.gif)\n\nIt's something, though, and I can keep working on it and improving it for future TIC-80 projects.\n\n### Animation ###\n\nI've continued to refine the effects system I used in *Save the Bird* and *Super Jump Guy*. I can now instantiate effects with a delay before they actually appear, which allows me to create the \"chain of explosions\" effect when you blow up an enemy tank (or when your own tank is blown up).\n\n![splosions.gif](\/\/\/raw\/da6\/11\/z\/4247a.gif)\n\nA more subtle improvement is that an object's animation speed scales with its actual movement speed. So for example, the faster your tank is going, the faster its tracks animate:\n\n![drive.gif](\/\/\/raw\/da6\/11\/z\/4247b.gif)\n\n### Collision Boxes ###\n\nIn PICO-8 and TIC-80, a sprite drawn at X=20, Y=20 will have its top-left pixel occupying that position. In my previous games, I accommodated this by making every object's XY coordinates correspond to the top-left of its sprite. This simplifies the drawing process - just pass each object's sprite index and XY position to the `spr()` function - but makes collision detection more complex, as you have to take this into account when drawing collision boxes.\n\nIn *BreakEven*, however, an object's XY coordinates correspond to the *center* of its sprite. This makes it much easier to calculate an object's collision box. When rendering, I then add an offset so that the sprite is drawn in the correct place.\n\nThat's everything I wanted to discuss. If you haven't played *BreakEven* yet, [please do give it a try](https:\/\/ldjam.com\/events\/ludum-dare\/48\/breakeven). As well as getting some rating done, I'll try and get some more fixes and improvements out over the course of the weekend.","comments":0,"created":"2021-05-06T18:02:45Z","files":[],"files-timestamp":0,"id":256338,"love":3,"love-timestamp":"2021-05-11T16:42:54Z","meta":[],"modified":"2021-05-11T16:42:54Z","name":"BreakEven - The Techy Stuff","node-timestamp":"2021-05-08T11:49:59Z","parent":235772,"parents":[1,5,9,233335,235772],"path":"\/events\/ludum-dare\/48\/breakeven\/breakeven-the-techy-stuff","published":"2021-05-08T11:49:59Z","scope":"public","slug":"breakeven-the-techy-stuff","subsubtype":"","subtype":"","type":"post","version":789051},"node_metadata":{"n_key":"256338","n_urlkey":"377998","n_parent":"235772","n_path":"\/events\/ludum-dare\/48\/breakeven\/breakeven-the-techy-stuff","n_slug":"breakeven-the-techy-stuff","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"71341","n_created":"1620324165","n_modified":"1620751374","n_version":"789051","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/48\/breakeven\/breakeven-the-techy-stuff","text":"First of all, a big thank you to everyone who's played and rated *[BreakEven](https:\/\/ldjam.com\/events\/ludum-dare\/48\/breakeven)* so far! I plan to start rating other people's games later today - I have next week off work, so I'll have plenty of time to devote to it.\n\nFor now, though, it's time for my usual breakdown of some of the more technical aspects of *BreakEven*. Considering what a nightmare it was just to get this game working, this ought to be interesting.\n\n![screen1.png](\/\/\/raw\/da6\/11\/z\/42487.gif)\n\n### The AI ###\n\nEnemies that can freely move in 2D space are something I have never done before, and something I figured I should probably learn how to do. It turned out to be quite possibly the most time-consuming feature I've ever programmed in a Ludum Dare game, partly because of how long it took to debug and optimise but mostly just because it required *so. Much. Code.*\n\nThe AI uses an implementation of the A* algorithm that I took from an online tutorial and modified to work in TIC-80. Once a second, the game generates a \"world grid\" with the locations of all the walls and hazards, and feeds it to the algorithm along with the player's position. The algorithm then generates an optimal path from each enemy to the player. Enemies will continuously move along this path, moving closer to you until they reach a certain distance.\n\n...in theory, anyway. In practice, the AI seems to just run around in circles until it gets stuck against a wall:\n\n![ai-is-bad-2.gif](\/\/\/raw\/da6\/11\/z\/42483.gif)\n\nIt's something, though, and I can keep working on it and improving it for future TIC-80 projects.\n\n### Animation ###\n\nI've continued to refine the effects system I used in *Save the Bird* and *Super Jump Guy*. I can now instantiate effects with a delay before they actually appear, which allows me to create the \"chain of explosions\" effect when you blow up an enemy tank (or when your own tank is blown up).\n\n![splosions.gif](\/\/\/raw\/da6\/11\/z\/4247a.gif)\n\nA more subtle improvement is that an object's animation speed scales with its actual movement speed. So for example, the faster your tank is going, the faster its tracks animate:\n\n![drive.gif](\/\/\/raw\/da6\/11\/z\/4247b.gif)\n\n### Collision Boxes ###\n\nIn PICO-8 and TIC-80, a sprite drawn at X=20, Y=20 will have its top-left pixel occupying that position. In my previous games, I accommodated this by making every object's XY coordinates correspond to the top-left of its sprite. This simplifies the drawing process - just pass each object's sprite index and XY position to the `spr()` function - but makes collision detection more complex, as you have to take this into account when drawing collision boxes.\n\nIn *BreakEven*, however, an object's XY coordinates correspond to the *center* of its sprite. This makes it much easier to calculate an object's collision box. When rendering, I then add an offset so that the sprite is drawn in the correct place.\n\nThat's everything I wanted to discuss. If you haven't played *BreakEven* yet, [please do give it a try](https:\/\/ldjam.com\/events\/ludum-dare\/48\/breakeven). As well as getting some rating done, I'll try and get some more fixes and improvements out over the course of the weekend.","title":"BreakEven - The Techy Stuff","wayback_source":[]}