Thanks mr_happy. That is exactly what I was looking for!
Appreciate you taking time to help me...
Hi all,
I have just started experimenting with TIC 80 and am sort of stuck animating a 2x3 sprite (refer to attached image).
I would like to animate it when moving (pressing left and right arrow) in a smooth way (not glitchy).
x=10 y=80 sn=0 function aspr() sn=0+t%16//8*2 end function TIC() cls(7) spr(sn,x,y,1,1,0,0,2,3) if btn(2) then aspr(); x=x-0.5 elseif btn(3) then aspr(); x=x+0.5 else sn=0 end end
Obviously this code is far from perfect. Let's say it works but if I quickly press and release the arrow keys the player sort of slides without being animated.
The sprite is not mine (I am just experimenting as I said) but I would like a smooth walking transition. I thought of changing the aspr() values to 16 and 8 to quickly cycle between the sprites. I am also incrementing x by 0.5 no to make the player go so fast. Not sure if I am doing well.
Can someone give me a helping hand to optimise the code in the correct way?
Thanks in advance
Ok will do but it seems someone else asked this question more than a year ago and was left unanswered ( https://itch.io/t/300533/tic80-fullscreen-not-working)
Thanks for the link
tic80 is just a binary file of 10MB. You just download the archive, extract and that's it. No installation, no documentation and tic80 -h or --help just output the message that the parameter is not supported.
The documentation online says -fullscreen is the switch but it is not working. Maybe some developers can help?
Ok thanks.
So basically using 2-bit instead of 4-bit sprites does not make any difference in the number of sprites you have available. The number is always 512 (256 FG + 256 BG).
If you want more sprites, you can use the LZW compression and compress a sprite sheet as a string of text. Is that correct?
Thanks a lot. I understand better now.
However, in the beginning you have this:
SPRITE_ADDR=0x4000*2
NIBBLES_IN_SPR=64
SPR_IX=256
ADDR=SPRITE_ADDR+NIBBLES_IN_SPR*SPR_IX
You are using address 49152 (0xC000). Any reason behind this please?
Also, how does this example give me space for more sprites other than the 256 in the sprite editor? (excluding background tiles)
Thanks
Thanks a real lot for your time in this alrado. I really appreciate and that is exactly what I was referring to.
However I do not think I am understanding the technique you used.
In the FG I see 5 sprites with pixels of all colours. What are those? When I removed them and ran the cartridge, nothing was displayed.
And you used the BG to draw your sprites. Why?
I guess if you use the sprite editor, you are still limited to 256 sprites and 256 tiles right? How does this give us 512 sprites instead of 256?
And why are there 2 sets of sprites on screen? It is as if the whole BG area is being output as well and then the sprite at 50,50.
Excuse my lack of experience in this but I am asking to learn.
If you can find some time to add a little more comments, that would be great.
Thanks once again for your time and well done for the cartridge.
Thanks for your reply alrado.
I understand that poke4 puts 1 pixel while poke puts 2 pixels
However how can you draw 2-bit (not 4-bit) sprites using poke4 please? Like the original NES sprites.
I was told by TIC support that if you use 2-bit sprites you gain an extra 512 sprites.
I would like to know how to use 0x4000 to store the 2-bit sprites and then store the 4-color palette maybe in map region 0x8000 as I was told.
I also saw your example of LZW-compressor. With 2 images it takes 16K of code. That is why I would like to use 2-bit if possible.
Imagine using 2-bit sprites with the LZW-compressor to have a lot more sprites.
An example code if possible would be great.
Thanks to all in advance for your time and help in this.
Thanks for your reply.
However I still cannot understand how poke and poke4 differ.
I downloaded and tested this example:
NIBBLES_IN_SPR=8*8 SPR_SHEET_ADDR=0x4000*2 sprIx=5 sprDataHex="a000000aa0f00f0aaaaaaaaaaafaaa6aafffaaaaaafaa6aaaaaaaaaa33333333" cls() for i=1,NIBBLES_IN_SPR do nibble=tonumber(sprDataHex:sub(i,i),16) poke4(SPR_SHEET_ADDR+(NIBBLES_IN_SPR*sprIx)+i-1,nibble) end print("See sprite sheet, index = "..sprIx) function TIC() end
But still the same sprite (TIC-80) logo is displayed in index 5.
Maybe someone can provide examples to show how poke4 can be used for 2-bit sprites please?
Thanks in advance