Dynamic Sprites

Anything QL Software or Programming Related.
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Dynamic Sprites

Post by dilwyn »

stevepoole wrote:Hi Dilwyn,
You are right about the comma in RND(-1,1) acting as though it were a TO.... (Not on JS ROMs ? -- I do not have a 128ko to test on).

To overcome this : xx=RND(1): x=x-(xx=0)+(xx=1): yy=RND(1): y=y-(yy=0)+(yy=1) : REM gets rid of zeroes for smoothness.

The difference is light, but noticeable.

Steve.
________________
I only tried it on SBASIC, so it's perfectly possible it might be different in SuperBASIC.

Often there are so many ways of achieving similar results in the end, none necessarily better than the other, that's the joy of tinkering with QL BASIC :geek:


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Dynamic Sprites

Post by dilwyn »

Steve, just for info, I tried the RND(-1,1) form on a QemuLator (haven't got a QL set up atm) with a JS ROM and it works the same as in SBASIC, in that you get -1, 0 and 1 as random numbers.

I do see where you're coming from with this, though - the use of a comma looks like it implies a list of possible values instead of a range, like a FOR loop index (FOR a=0,2,4,6,8 for example)


stevepoole
Super Gold Card
Posts: 714
Joined: Mon Nov 24, 2014 2:03 pm

Re: Dynamic Sprites

Post by stevepoole »

Hi Dilwyn,
I am in an embarassing situation here : On holiday in the Alps with no QL documents to fall back on !

In the early QL days, I read that RND(-5,9) would select either -5 or 9 as a return. (At the time I had a JM), and used the feature often.

I have never noticed that this feature had changed, not having used it for decades...

As for dynamic sprites, I used to use a font editor to design these, and animate them using CURSOR positioning ( in #1, origin 0,0 only, due to a bug).

OK, so using emulators you now need toolkits to access fonts etc, but that is the price to pay for having bells and whistles.

For larger sprites, join several font elements in big groups, moved simultaneously. Then animation is as fast as XORed character printing....

All this is relatively simple, compared to animated-3D-perspective-sprite handling !! But that stretches the 128ko QL to its limits.

Steve.


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Dynamic Sprites

Post by dilwyn »

stevepoole wrote:Hi Dilwyn,
I am in an embarassing situation here : On holiday in the Alps with no QL documents to fall back on !
What...nothing QL with you on holiday, shock horror!!! :evil:
stevepoole wrote: In the early QL days, I read that RND(-5,9) would select either -5 or 9 as a return. (At the time I had a JM), and used the feature often.

I have never noticed that this feature had changed, not having used it for decades...
A lot of things changed very slightly in those early days, as the designers tried to fit everything in. Would be interesting to see if the original early pre-release syntax definitions included this, as it would seem a natural extension for the RND function, to select from a list of random number values as opposed to a range. Shame this was not kept in. On the other hand it may possibly have been a side effect if there was incomplete error trapping when parsing parameters, for example.
Of course, you could always do some simple basic code to simulate it:
LET number=RND(1 TO 3)
SELect ON number:=1:number=100:=2:number=200:=3:number=300

(hope I got the syntax of the single line SELect correct there, I rarely use the single line form).

Or for large 'random' data sets, keep them in an array() and do something like LET number=array(RND(1 to however_many)) if what you wanted to do was to choose one from a range of possible random values.
stevepoole wrote:As for dynamic sprites, I used to use a font editor to design these, and animate them using CURSOR positioning ( in #1, origin 0,0 only, due to a bug).
OK, so using emulators you now need toolkits to access fonts etc, but that is the price to pay for having bells and whistles.
For larger sprites, join several font elements in big groups, moved simultaneously. Then animation is as fast as XORed character printing....
All this is relatively simple, compared to animated-3D-perspective-sprite handling !! But that stretches the 128ko QL to its limits.
Steve.
I think this is at the heart of what has been discussed here, in that the term "sprite" is used in two different ways, which leads to misunderstandings:
1. PE Sprite: a pointer environment object called a sprite, which includes a dynamic sprite. Generally used as a pointer, cursor or icon. Has its own file formats, unrelated to the games graphics or text fonts.
2. Game sprite: a games graphic unrelated to the above, which may be programmed in a completely different way (e.g. character graphics as you have discussed)

The use of PE sprites (for want of a better term to distinguish between the two types) is what I was discussing in relation to my program, then the thread went towards Game Sprites, which Tinyfpga has kindly moved to a new thread, which will hopefully result in greater discussion of that kind of sprite.

I'll probably have a think and write some text about what may be needed, to contribute to Tinyfpga's new thread, in the hope that it might persuade someone cleverer than me to write such code.


User avatar
RalfR
Aurora
Posts: 872
Joined: Fri Jun 15, 2018 8:58 pm

Re: Dynamic Sprites

Post by RalfR »

Image


4E75 7000
User avatar
pjw
QL Wafer Drive
Posts: 1299
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Dynamic Sprites

Post by pjw »

BSJR wrote:
dilwyn wrote: Thank you Per. Of all places, I didn't think of looking in EP manual . I recall reading somewhere that there was a specific reason why that size limit was chosen - doesn't make much sense having bigger pointer and cursor sprites anyway. Armed with this it should help me debug. Seems to confirm my observations, in that it explains why I was having difficulty with 64x64
Also TTs Sprite program as bundled with QPTR used a 64x48 pixels limit.
This is of course a 4:3 ratio and would produce a square image in the CRTs of that time.
SQRview uses a limit of 4K pixels to decide if it can be a pointer sprite or handled as static sprite so neither 64 or 48 is the limit but the total of pixels.<>
Sorry for revisiting this old chestnut, but I was just fiddling with Dilwyn's AnimGIF. In his documentation he writes that the limit for pointer sprites is 64x48. I believed Bob here had put the matter to bed with his claim that 4k pixels was the limit, irrespective of geometry. So I decided to put it to the test to try to get a definitive answer.
Well, I did put it to the test and I still dont have an answer. Sprites of 64x64 pixels (= 4k) seem fine. 128x32 (=4k) also seems fine. But 32x128 => KAAABOOOOM! Also other values, mainly where y > x crash the system. I tried looking for an answer in the sources (we're only talking SMSQ/E here, specifically V3.38) keys/con says

Code: Select all

pt_spsav equ     $64      sprite save area
pt.spspx equ       64        64x64 pixels
pt.spspy equ       64
which seems to support the 64x64 pixel theory, but I cant find any code that would explain why one geometry crashes the system while another doesnt.
Any ideas? Anyone?


Per
dont be happy. worry
- ?
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Dynamic Sprites

Post by dilwyn »

Thanks Per. Although I didn't look in the sources, your observation tally with what I observed during my tinkering with the sprites.

The 64x48 (4:3 ratio) refers to QDOS pointer environment as far as I can tell.


User avatar
BSJR
Trump Card
Posts: 186
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: Dynamic Sprites

Post by BSJR »

pjw wrote:...
Well, I did put it to the test and I still dont have an answer. Sprites of 64x64 pixels (= 4k) seem fine. 128x32 (=4k) also seems fine. But 32x128 => KAAABOOOOM! Also other values, mainly where y > x crash the system. I tried looking for an answer in the sources (we're only talking SMSQ/E here, specifically V3.38) keys/con says

Code: Select all

pt_spsav equ     $64      sprite save area
pt.spspx equ       64        64x64 pixels
pt.spspy equ       64
which seems to support the 64x64 pixel theory, but I cant find any code that would explain why one geometry crashes the system while another doesnt.
Any ideas? Anyone?
For SuQcess a routine is used to pick a text line from the screen and turn this into a pointer sprite, it's used in the Print menu.
I also wanted to use this in an Edit window to pickup a text and drop it on an empty line. This way a text pointer of 384x10 pixels can be moved around with max 64 chrs, which I tested to be a safe limit.

BSJR


Post Reply