Feature: "End" action on LinesSprite/Lines3dSprite

Started by jaymzjulian, December 23, 2019, 01:07:45 AM

Previous topic - Next topic

jaymzjulian

Right now, the "length" of a linesprite object is always the length of the object - this is _usually_ what you want, unless you want to grow/morph/otherwise manipulate it to a different number of lines, when it isn't.  Today, I'm just working around this by re-generating the entire display whenever I need to change the size of the trail sprites, however this can take a non-trivial amount of cycles when things get busy (around 20 ticks or so).  This actually isn't a problem really most of the time, but it's.... definitely clumsy.

So I could optimize that, of course - I know there is a few dumb things I'm doing in there - but my initial instinct was "well, just don't do that" and just grow the array - it's live data, after all, but that's where I hit the snag - if I define it at "max size", the object has values like:

MoveTo, 0, 0, 0
DrawTo, 1, 1, 1
Undefined
Undefined

So of course, if you try and draw this, it errors - as it should - since Undefined is, well, undefined.  So far, so copasetic.  I was actually able to work around this by doing:

MoveTo, 0, 0, 0
DrawTo, 1, 1, 1
MoveTo, 0,0,0
MoveTo, 0,0,0
MoveTo, 0,0,0

Where most of those MoveTo's are optimized out, so everything is "fine".  Works out reasonably, crisis averted, but is pretty clumsy.   As an aside, of course I could use the RemoveSprite/PutSpriteBefore function as well with a deepcopy of the array, which I actually find clumsier, myself, but it'd be doable.  But what I really want to do, is something like:

MoveTo, 0,0,0
DrawTo 1,1,1
EndDraw
Undefined
Undefined

Then when I grow the object, I can update it to be:

MoveTo 0,0,0
DrawTo 1,1,1
DrawTo 2,2,2
EndDraw
Undefined

Without having to recreate the sprite object.   My running theory is that it should be pretty easy for that code to just go "ohhey, this is the end of the object, get out!".  As always, it's entirely possible/probably I'm wrong about the internals :).

Vectrex32

Do we need the EndDraw, or should the V32 just ignore Undefined data in the array?

- Bob

jaymzjulian

For me right now, just ignoring Undefined would work out just fine - it would actually be easier for me, that way. 

I do wonder if there's a use case for reducing an object as well, though... although I admit what I can think of in my head is reasonably long-shot stuff like "oh, i destroyed half a ship, i'll remove the wing object" which would be better handled by multiple Lines[3d]Sprite objects, or switching out the sprite to the reduced one that you've already pre-made, so I wouldn't sweat it unless someone has one ;).