View Single Post
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 11,005

Violet CLM has disabled reputation

Apr 20, 2024, 09:40 AM
Violet CLM is offline
Reply With Quote
This is neat! But I think it's mostly a showcase of how fast tiles are. I tried to adapt it more generally and it seems to be slower than TrueColor, not to mention it relies on a specific palette and I don't think the math works for alpha channel.

Compare a TrueColor version with this addition to Cottage.j2as to draw as sprites instead of tiles:
Code:
uint cottageFrameID;
void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[0]].allocate(array={3});
	cottageFrameID = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]]];
	for (int i = 5; i <= 7; ++i) {
		jjLayerHasTiles[i] = false;
		jjPIXELMAP(0,0, 640,480, jjLayers[i]).save(jjAnimFrames[cottageFrameID + i - 5]);
	}
}
void onDrawLayer8(jjPLAYER@, jjCANVAS@ canvas) {
	canvas.drawSpriteFromCurFrame(0,0, cottageFrameID);
	canvas.drawSpriteFromCurFrame(0,0, cottageFrameID + 1, mode: SPRITE::BLEND_MULTIPLY, param:255);
	canvas.drawSpriteFromCurFrame(0,0, cottageFrameID + 2, mode: SPRITE::BLEND_MULTIPLY, param:255);
}
(I did also compare to BLEND_DARKEN and BLEND_BURN, but MULTIPLY seems to be the fastest of those.)
__________________