Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
CandionV | Violet CLM | Tileset conversion | 9.7 |
const uint16 LollipopTileID = 390;
array<uint16> tilesToTurnIntoSprites = {
585,625, //pickups
604,605,606,607,608, //lights
LollipopTileID
};
class Sprite {
Sprite(){}
float x, y;
uint age;
uint color;
Sprite(float xx, float yy, uint a, uint c = 0) {
x = xx; y = yy; age = a; color = c;
}
}
uint firstSingleTileFrameID, firstMultiTileFrameID, firstCandyCaneFrameID;
const uint levelWidth = jjLayerWidth[4];
const uint levelHeight = jjLayerHeight[4];
array<Sprite> Lollipops, Spazzes, Jacks, CandyCanes;
array<array<Sprite>> Lights(2);
void onLevelLoad() {
array<jjLAYER@> layerOrder = {jjLayers[1], jjLayers[2], jjLayers[3], jjLayers[4], jjLayers[5]};
//skip layer 6, it's just there to make vanilla people feel good about themselves
for (uint i = 0; i < 5*2; ++i) {
jjLAYER rocksInChocolate(4, 1);
rocksInChocolate.tileWidth = true;
rocksInChocolate.ySpeed = 0.24 - i * 0.003;
rocksInChocolate.xSpeed = 0.7 - i * 0.04;
rocksInChocolate.xOffset = jjRandom();
rocksInChocolate.yOffset = -666 + int(i*20);
rocksInChocolate.generateSettableTileArea();
for (uint x = 0; x < 4; ++x)
rocksInChocolate.tileSet(x, 0, 680 + 8 - (i & ~1) + (x & 1));
layerOrder.insertLast(@rocksInChocolate);
}
{
jjLAYER bigTrees(4, 8), smallTrees(4, 5);
bigTrees.tileWidth = smallTrees.tileWidth = true;
bigTrees.limitVisibleRegion = smallTrees.limitVisibleRegion = true;
bigTrees.yOffset = -180; smallTrees.yOffset = -300;
bigTrees.generateSettableTileArea();
smallTrees.generateSettableTileArea();
for (uint x = 0; x < 4; ++x) {
for (int y = 0; y < bigTrees.height; ++y) {
if (y < 3) { if (!(y == 0 && x > 1))
bigTrees.tileSet(x, y, 578 + (x & 1) + (y - x/2) * 10);
} else
bigTrees.tileSet(x, y, 598 + (x & 1));
}
for (int y = 0; y < smallTrees.height; ++y) {
if (y < 2)
smallTrees.tileSet(x, y, 576 + (x & 1) + (y * 10));
else
smallTrees.tileSet(x, y, 586);
}
}
for (uint i = 0; i < 8; ++i) {
jjLAYER trees(i < 5 ? bigTrees : smallTrees);
trees.ySpeed = 0.13 - i * 0.02;
//if (i >= 3) trees.ySpeed -= 0.02;
trees.xSpeed = 0.3 - i * 0.024;
trees.xOffset = jjRandom();
trees.yOffset += (i < 5) ? int(i*60) : (210 + int(i*30));
layerOrder.insertLast(@trees);
}
}
layerOrder.insertLast(jjLayers[7]);
jjLAYER secondBackgroundMountains(jjLayers[7]);
secondBackgroundMountains.yOffset = 64;
secondBackgroundMountains.ySpeed *= 0.85;;
secondBackgroundMountains.xSpeed *= 0.7;
layerOrder.insertLast(@secondBackgroundMountains);
layerOrder.insertLast(jjLayers[8]);
jjLayerOrderSet(layerOrder);
firstSingleTileFrameID = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]].allocate(array<uint> = {tilesToTurnIntoSprites.length, 2, 4})];
firstMultiTileFrameID = firstSingleTileFrameID + tilesToTurnIntoSprites.length;
firstCandyCaneFrameID = firstMultiTileFrameID + 2;
jjANIMFRAME@ frame;
for (uint i = 0; i < tilesToTurnIntoSprites.length; ++i) {
@frame = jjAnimFrames[firstSingleTileFrameID + i];
jjPIXELMAP(tilesToTurnIntoSprites[i]).save(frame);
frame.hotSpotX = frame.hotSpotY = -16;
}
jjObjectPresets[OBJECT::CHOCBAR].curFrame = jjAnimations[jjObjectPresets[OBJECT::CHOCBAR].curAnim].firstFrame = firstSingleTileFrameID; //candy cane
jjObjectPresets[OBJECT::ICECREAM].curFrame = jjAnimations[jjObjectPresets[OBJECT::ICECREAM].curAnim].firstFrame = firstSingleTileFrameID + 1; //ice cream
@frame = jjAnimFrames[firstMultiTileFrameID]; //spaz
jjPIXELMAP(32, 0, 128,128).save(frame);
frame.hotSpotX = frame.hotSpotY = 0;
@frame = jjAnimFrames[firstMultiTileFrameID + 1]; //jackdevan
jjPIXELMAP(160, 0, 64,96).save(frame);
frame.hotSpotX = 0; frame.hotSpotY = -64;
for (uint i = 0; i < 4; ++i) {
@frame = jjAnimFrames[firstCandyCaneFrameID + i];
jjPIXELMAP(7*32, i * 20, 12, 96 - i*20).save(frame);
frame.hotSpotX = -6; frame.hotSpotY = 0;
}
for (uint x = 0; x < levelWidth; ++x) {
for (uint y = 0; y < levelHeight; ++y) {
const uint16 tileID1 = jjTileGet(4, x, y), tileID2 = jjTileGet(5, x, y);
if (tileID1 == LollipopTileID || tileID2 == LollipopTileID)
Lollipops.insertLast(Sprite(x * 32 + 16, y * 32 + 16, jjRandom()));
else if (tileID1 == 301) //top left of Spaz
Spazzes.insertLast(Sprite((x - 1) * 32, y * 32, 0));
else if (tileID1 >= 340 && tileID1 <= 343) //spaz on bricks
jjTileSet(4, x,y, 56);
else if (tileID1 >= 395 && tileID1 <= 398) //spaz on ice
jjTileSet(4, x,y, 5);
else if (tileID1 == 334 || tileID1 == 335) { //top of box
jjTileSet(4, x,y, tileID1 - 30); //remove spring
if (tileID1 == 334)
Jacks.insertLast(Sprite(x * 32, y * 32, jjRandom()));
}
if (jjEventGet(x, y) == 255)
CandyCanes.insertLast(Sprite(x * 32 + 16, y * 32 + 16, jjRandom(), 3 - jjParameterGet(x, y, 0, 2)));
}
}
const uint16 firstTreeTileID = 592;
array<jjPIXELMAP@> foregroundTreeTileImages(679 - firstTreeTileID + 1, null);
for (uint i = 0; i < 2; ++i) {
const jjLAYER@ layer = jjLayers[1 + i];
for (int x = layer.width - 1; x >= 0; --x)
for (int y = layer.height - 1; y >= 0; --y) {
const uint16 tileID = layer.tileGet(x, y);
if (tileID >= firstTreeTileID) {
const uint16 adjustedTileID = tileID - firstTreeTileID; //to fit it into the image array
if (foregroundTreeTileImages[adjustedTileID] is null)
@foregroundTreeTileImages[adjustedTileID] = jjPIXELMAP(tileID);
const jjPIXELMAP@ tileImage = foregroundTreeTileImages[adjustedTileID];
uint8 xx, yy;
while (tileImage[xx = jjRandom() & 31, yy = jjRandom() & 31] == 0); //find a non-transparent pixel
Lights[i].insertLast(Sprite(x * 32 + xx, y * 32 + yy, jjRandom(), jjRandom() % 5));
}
}
}
}
void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
for (uint i = 0; i < Lollipops.length; ++i) {
const Sprite@ sprite = Lollipops[i];
screen.drawRotatedSpriteFromCurFrame(int(sprite.x), int(sprite.y), firstSingleTileFrameID + 7, sprite.age - (jjGameTicks << 4));
}
for (uint i = 0; i < Spazzes.length; ++i) {
const Sprite@ sprite = Spazzes[i];
screen.drawSpriteFromCurFrame(int(sprite.x), int(sprite.y), firstMultiTileFrameID, 1, SPRITE::PLAYER, play.playerID);
}
for (uint i = 0; i < CandyCanes.length; ++i) {
const Sprite@ sprite = CandyCanes[i];
screen.drawSwingingVineSpriteFromCurFrame(int(sprite.x), int(sprite.y), firstCandyCaneFrameID + sprite.color, 96 - sprite.color*20, int(jjSin(sprite.age + jjGameTicks * 6) * 0x4000));
}
}
void onDrawLayer5(jjPLAYER@, jjCANVAS@ screen) {
for (uint i = 0; i < Jacks.length; ++i) {
const Sprite@ sprite = Jacks[i];
screen.drawRotatedSpriteFromCurFrame(int(sprite.x), int(sprite.y), firstMultiTileFrameID + 1, int(jjSin(jjGameTicks << 2) * 28));
}
}
void drawLights(uint id, jjCANVAS@ screen) {
const array<Sprite>@ lights = @Lights[id];
for (uint i = 0; i < lights.length; ++i) {
const Sprite@ sprite = lights[i];
screen.drawSpriteFromCurFrame(int(sprite.x), int(sprite.y), firstSingleTileFrameID + 2 + sprite.color, 1, SPRITE::BRIGHTNESS, 128 + int(jjSin(sprite.age + (jjGameTicks << 3)) * 40));
}
}
void onDrawLayer1(jjPLAYER@, jjCANVAS@ screen) { drawLights(0, screen); }
void onDrawLayer2(jjPLAYER@, jjCANVAS@ screen) { drawLights(1, screen); }
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.