Downloads containing NyanCatTreasureHunt.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Nyan Cat Treasure Hunt!!! jjturbo9 Treasure hunt N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.8.asc" ///@MLLE-Generated
#pragma require "NyanCatTreasureHunt.j2l" ///@MLLE-Generated
///@SaveAndRunArgs -server -list -treasure -spaz ///@MLLE-Generated
#include "Resize v10.asc"
#pragma require "nyancat.bmp"
#pragma offer "nyan.wav"
#pragma name "Nyan Rush"

ANIM::Set NYANCAT;

void onLevelLoad() {
    TrueColor::ProcessPalette();
    TrueColor::EnableCaching();
    TrueColor::Bitmap spriteSheet("nyancat.bmp");
    jjPALCOLOR background = spriteSheet.pixels[0][0];
    jjPALCOLOR transparent = jjPALCOLOR(0,0,0);
    for(uint i = 0; i < spriteSheet.width; i++) {
        for(uint j = 0; j < spriteSheet.height; j++) {
            if(spriteSheet.pixels[i][j] == background) {
                spriteSheet.pixels[i][j] = transparent;
            }
        }
    }

    array<array<TrueColor::Coordinates>> coordArray2 = {
        {
            TrueColor::Coordinates(2,12,37,22,-15,-10),
            TrueColor::Coordinates(48,10,40,24,-15,-10),
            TrueColor::Coordinates(96,11,36,22,-15,-10),
            TrueColor::Coordinates(138,11,37,23,-15,-10),
            TrueColor::Coordinates(181,11,36,22,-15,-10),
            TrueColor::Coordinates(220,11,36,22,-15,-10)
        }
    };

    NYANCAT = TrueColor::FindCustomAnim();

    int NUM_ANIMS = 1;
    int NUM_SPRITES = 6;
    int WIDTH = 40;
    array<array<TrueColor::Coordinates>> coordArray(NUM_ANIMS, array<TrueColor::Coordinates>(NUM_SPRITES));
    for(int i = 0; i < NUM_ANIMS; i++) {
        for(int j = 0; j < NUM_SPRITES; j++) {
            coordArray[i][j] = TrueColor::Coordinates(j*WIDTH, 11, 45, 25);
        }
    }

    Resize::AllocateAndResizeTrueColorSpriteSheet(NYANCAT, spriteSheet, coordArray2, 2);
}

void onLevelBegin() {
	MLLE::SpawnOffgrids();
    jjSampleLoad(SOUND::RUSH_RUSH, "nyan.wav");
}

// No need for rush arrays if effect is permanent
// array<bool> isRush(32);
// array<bool> sugarStarted(32);

bool isAnim(jjPLAYER@ play, RABBIT::Anim anim) {
    return play.curAnim - jjAnimSets[play.setID].firstAnim == uint(anim);
}

bool isStomp(jjPLAYER@ play) {
    return isAnim(play, RABBIT::BUTTSTOMPLAND) || isAnim(play, RABBIT::FALLBUTTSTOMP) || isAnim(play, RABBIT::FALLLAND) || isAnim(play, RABBIT::FALL);
}

void onMain() {
    // Loop through all player slots
    for(int i = 0; i < 32; i++) {
        if(jjPlayers[i] is null) continue;

        // Always apply invisibility (optional: or leave as false)
        jjPlayers[i].invisibility = true;
        if(p.charCurr != CHAR::SPAZ) {
            p.morphTo(CHAR::SPAZ, false); // instant morph
        }

        // Draw Nyan Cat & particles permanently
        TrueColor::DrawSprite(jjPlayers[i].xPos, jjPlayers[i].yPos, NYANCAT, 0, (jjGameTicks >> 3) * TrueColor::NumberOfFramesPerImage, jjPlayers[i].direction);
        particle(jjPlayers[i], -18, 24);
        particle(jjPlayers[i], -11, 43);
        particle(jjPlayers[i], -4, 40);
        particle(jjPlayers[i], 4, 19);
        particle(jjPlayers[i], 11, 35);
        particle(jjPlayers[i], 18, 93);
    }
}

void particle(jjPLAYER@ player, int yOffset, int color) {
    jjPARTICLE@ part = jjAddParticle(PARTICLE::STAR);
    int xOffset = 15;
    int dir = (player.direction < 0 ? 1 : -1);
    xOffset = xOffset * dir;
    part.xPos = player.xPos + xOffset;
    part.yPos = player.yPos + yOffset + (jjSin((jjGameTicks % 35) * (1024/35))-0.5)*5;
    part.xSpeed = dir * 5;
    part.star.size = 12;
    part.star.color = color;
}

void onLevelReload() {
	MLLE::SpawnOffgridsLocal();
}