News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_zhulien

Best Sprite & Tile Routines that are ROMable

Started by zhulien, 04:40, 19 February 22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zhulien

I am wanting to put some fantastic sprite and tile routines into ROM.


I was going to port my JS libraries to Z80, but perhaps someone has a better set of sprite and tile code than I could create.


Some wanted / expected features:


Images for which Sprites are obtained:



var m_arrImages = [ { name:'man', classes:'people', source:'images/man.jpg' }, { name:'woman', classes:'people', source:'images/woman.jpg' } ];



Sprites that can be defined from Images along with one or more animation sequences:


var m_arrSprites = [ { name:'man', classes:'people', imagename:'man', x:10, y:20, w:50, h:100, imagex:0, imagey:19, imagew:92, imageh:125, sequence:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,-1] }, { name:'woman', classes:'people', imagename:'woman', x:260, y:50, w:25, h:100, imagex:0, imagey:0, imagew:110, imageh:303, sequence:[1,1,2,2,3,3,4,4,5,5,-1] }
];



The ability to add images and sprites to a library in RAM:



m_objSprites.addImagesToLibrary(m_arrImages); m_objSprites.addSpritesToLibrary(m_arrSprites); m_arrPeopleImageIDs = m_objSprites.getImageIDsByClass('people');



The ability to use sprites from the library, this creates shorter specific lists for later processing for various purposes:



m_objSprites.useSpritesByClass('people'); m_arrPeopleSpriteIDs = m_objSprites.getSpriteIDsByClass('people');



The ability to load sprites and animate them when required:



m_objSprites.loadImagesByIDs(m_arrPeopleImageIDs, function() { // animate after the images are loaded m_objSprites.animateSpritesByIDs(m_arrPeopleSpriteIDs); m_blnResourcesLoaded = true; });
m_objSprites.animateSprites();



The ability to process sprites, show them, move them, do they collide?



m_objSprites.processSprites(m_arrPeopleImageIDs, function(intID_a) { m_objSprites.moveSpriteByID(intID_a, intXOffset, intYOffset); m_objSprites.showSpriteByID(intID_a); });







Current JSprites library:


(code in https://8bitology.net/poc/framework/js/jsprites.js, https://8bitology.net/poc/framework/js/game-spritedemo.js)


As you can see, may functions can also take in callbacks (pointers) instead of taking literals - that means to move a sprite for example along a sine wave, it can call a calculation callback instead of just taking an integer.  Multiple sprites can be moved in a single line with multiple animations, multiple collisions detected.


I have just started coding tilemap rendering... https://8bitology.net/poc/nzstory/js/jsprites.js
as shown here  https://8bitology.net/poc/nzstory/




The goal will be to add the commands to Locomotive BASIC v5


Powered by SMFPacks Menu Editor Mod