v1.1 Improvements


  • Optimised trajectory maths. I used BasinC to profile the code and I was amazed to find that a power of two calculation was slowing the whole loop down substantially. I changed "LET y1=y01+v0y1*t+0.5*-9.81*t^2" into "LET y1=y01+v0y1*t-4.905*t*t" for a decent speedup.
  • Reorganised some of the trajectory loop conditional logic to remove unnecessary NOT operators.
  • Changed the terrain collision detection back to ATTR function from a PEEK, but now it only occurs if the trajectory is on-screen. It was previously possible for the function to overstep the screen memory and return a spurious result. Castle collision detection remains via PEEK since it appears to be faster when the position doesn't change, and since castle attribute memory locations only need determining once per round.
  • Added a night mode which adds some conditional behaviour to colour selection during castle drawing and animation - blue items become black. Sinclair BASIC evaluating conditions inline is a huge help here e.g. "INK 1-(sky=1)"
  • Improved the terrain drawing method. The generation algorithm remains unchanged - y heights are generated for each x position - so it's built in vertical slices. However as could be seen with v1.0 these slices are very slow to render using a FOR loop, so the new method stores the generated extents in a matrix. It iterates vertically again finding missing edges where the stepping was greater than one, and then this matrix can be used to draw the whole playfield quickly in horizontal slices using TAB. Time taken from generation to round start is about the same, but the screen can now be re-drawn.
  • Time of day changes during a round, since the screen can quickly be redrawn preserving the previous trajectory arcs. Bottom to top for setting sun, top to bottom for rising sun.
  • Terrain types and their colours at the four times of day are stored in a lookup table (day, dusk, night, dawn). Day and night last for two turns, dawn and dusk last a single turn.
  • After 4 turns nightfall will erase all trajectory traces in the sky to prevent it getting too cluttered. Traces that touch terrain will remain by design - those screen re-entry single pixel plots are essential for ranging.
  • Scores can run into double digits without spoiling the screen layout (e.g. if both players draw at 9 points each and additional rounds are needed to determine the match winner).

Get Artillery