1.0
21 Dec 2015 15:14
// Prepare a 10x32 layer 8. Have each layer image exactly 10x8. Start from layer 8 on top, end with layer 5 on bottom.
void onDrawLayer8(jjPLAYER@ p, jjCANVAS@ screen) // Let's subdivide the contents from layer 8 into 4 different layers, shall we?
{
jjPIXELMAP doLayer11(0, 0, 320, 240, 8); // Have the layer 8 image on tiles from 1,1 to 10,8 (or 10,7 if it's a 320x200 image)
jjANIMFRAME@ layer11 = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::BOLLPLAT].firstAnim].firstFrame]; // Assuming you're not using boll platforms, place one somewhere nearby the start, but not in a visible place.
layer11.hotSpotX = 0;
layer11.hotSpotY = 0; // So the background image is perfectly aligned.
doLayer11.save(layer11);
screen.drawResizedSprite(0, 0, ANIM::BOLLPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0); // Or 0.005 if it's a 320x200 image, but it will appear stretched in 4:3 resolutions.
jjPIXELMAP doLayer10(0, 8 * 32, 10 * 32, 8 * 32, 8); // Have the layer 7 image on tiles from 1,9 to 10,16
jjANIMFRAME@ layer10 = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::FRUITPLAT].firstAnim].firstFrame]; // We'll need more frames, so assuming you'll not use the first 4 platforms, let's replace their sprites with backgrounds.
layer10.hotSpotX = 0;
layer10.hotSpotY = 0;
doLayer10.save(layer10);
screen.drawResizedSprite(0 - (p.cameraX % ((0.25 * jjResolutionWidth) * 32) / 8), 0 - (p.cameraY % (160 * 32) / 32), ANIM::FRUITPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0); // Higher divisions mean further background.
screen.drawResizedSprite(jjResolutionWidth - (p.cameraX % ((0.25 * jjResolutionWidth) * 32) / 8), 0 - (p.cameraY % (160 * 32) / 32), ANIM::FRUITPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0); // Leaving the Y origin to 0 is good for backgrounds with a ceiling.
jjPIXELMAP doLayer9(0, 16 * 32, 10 * 32, 8 * 32, 8); // Shortly, place the next layer's tiles each 8 tiles down, or customize the area if you want.
jjANIMFRAME@ layer9 = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::GRASSPLAT].firstAnim].firstFrame];
layer9.hotSpotX = 0;
layer9.hotSpotY = 0;
doLayer9.save(layer9);
screen.drawResizedSprite(0 - (p.cameraX % ((0.125 * jjResolutionWidth) * 32) / 4), 0 - (p.cameraY % (80 * 32) / 16), ANIM::GRASSPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0);
screen.drawResizedSprite(jjResolutionWidth - (p.cameraX % ((0.125 * jjResolutionWidth) * 32) / 4), 0 - (p.cameraY % (80 * 32) / 16), ANIM::GRASSPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0); // Increase the Y origin according to the level height.
jjPIXELMAP doLayer8(0, 24 * 32, 10 * 32, 8 * 32, 8); // Once you're done with these, put whatever you want on layers 5-7 and enjoy watching!
jjANIMFRAME@ layer8 = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::PINKPLAT].firstAnim].firstFrame];
layer8.hotSpotX = 0;
layer8.hotSpotY = 0;
doLayer8.save(layer8);
screen.drawResizedSprite(0 - (p.cameraX % ((0.0625 * jjResolutionWidth) * 32) / 2), 0 - (p.cameraY / 8), ANIM::PINKPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0); // The Y positions (speeds) are examples. For now, you may want to set them to 0.
screen.drawResizedSprite(jjResolutionWidth - (p.cameraX % ((0.0625 * jjResolutionWidth) * 32) / 2), 0 - (p.cameraY / 8), ANIM::PINKPLAT, 0, 0, 0.003125 * jjResolutionWidth, 0.0041666667 * jjResolutionHeight, SPRITE::NORMAL, 0);
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.