01-06-2021, 06:00 PM
Thanks, that mapping using DIM is a very neat trick, definitely an example that would be useful to have on the wiki.
I actually implemented the code I showed above and it didn't really speed things up over and above the addition of each ATTR to a total value.
It true, I am very much veering towards premature optimisation. I think it's because I have already written this game once, and I'm attempting to port it without completely re-designing it. I have some idea of which approaches are optimal, but since I have very little knowledge of ASM and the bare fundamentals of computer science it's difficult. I am a total amateur. I keep on discovering new features of ZX BASIC which lead me to greater improvements. And I'm learning a lot here so it's very interesting.
The attribute scanning seems at face value to be an optimal collision detection approach because it's simple. Wouldn't it be four expensive comparison operations to scan whether I've entered the hit castle hit-box with each PLOT? To my untrained eye, a whole series of greater than or less than comparisons is surely more costly than these POKEs and PEEKs.
I'll send you over my current working prototype. Your compiler, and the fSIN fCOS functions have allowed more than an order of magnitude performance improvement over Sinclair BASIC. I'm spending this on PLOTting the ballistic trajectory pixel-by-pixel rather than via achingly slow DRAW commands. It feels more like a real game now. I can also create a far better terrain generation algorithm than before. Other than that I'm going to be making the same game fundamentally. I'm also keen to implement a computer player too, though that seems quite a big task.
I actually implemented the code I showed above and it didn't really speed things up over and above the addition of each ATTR to a total value.
It true, I am very much veering towards premature optimisation. I think it's because I have already written this game once, and I'm attempting to port it without completely re-designing it. I have some idea of which approaches are optimal, but since I have very little knowledge of ASM and the bare fundamentals of computer science it's difficult. I am a total amateur. I keep on discovering new features of ZX BASIC which lead me to greater improvements. And I'm learning a lot here so it's very interesting.
The attribute scanning seems at face value to be an optimal collision detection approach because it's simple. Wouldn't it be four expensive comparison operations to scan whether I've entered the hit castle hit-box with each PLOT? To my untrained eye, a whole series of greater than or less than comparisons is surely more costly than these POKEs and PEEKs.
I'll send you over my current working prototype. Your compiler, and the fSIN fCOS functions have allowed more than an order of magnitude performance improvement over Sinclair BASIC. I'm spending this on PLOTting the ballistic trajectory pixel-by-pixel rather than via achingly slow DRAW commands. It feels more like a real game now. I can also create a far better terrain generation algorithm than before. Other than that I'm going to be making the same game fundamentally. I'm also keen to implement a computer player too, though that seems quite a big task.