~ndiddy/libremo

207bf762debd4faf7f16a4b3425cdfc55d6228d2 — Nathan Misner 2 years ago dc1f720
probably done with stage clear bonus
7 files changed, 158 insertions(+), 13 deletions(-)

M bonus.cpp
M bonus.h
M game.cpp
M game.h
M hud.cpp
M hud.h
M stage.cpp
M bonus.cpp => bonus.cpp +40 -1
@@ 64,7 64,7 @@ static void Bonus_PrintScore(int score, float x, float y) {
    }
}

void Bonus_Normal(int score) {
static void Bonus_Normal(int score) {
    float xCursor = LEFT_WALL + BONUS_TEXT_SIZE;
    float yCursor = TOP_WALL + (4 * BONUS_TEXT_SIZE);



@@ 85,4 85,43 @@ void Bonus_Normal(int score) {
    xCursor = LEFT_WALL + (8 * BONUS_TEXT_SIZE);
    yCursor += 2 * BONUS_TEXT_SIZE;
    Bonus_PrintScore(score, xCursor, yCursor);
}

static void Bonus_Stage(int score) {
    float xCursor = LEFT_WALL + BONUS_TEXT_SIZE;
    float yCursor = TOP_WALL + (4 * BONUS_TEXT_SIZE);

    // print the text
    Bonus_Print(BONUS_S, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_T, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_A, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_G, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_E, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    xCursor += BONUS_TEXT_SIZE; // space
    Bonus_Print(BONUS_C, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_L, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_E, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_A, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_R, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    xCursor = LEFT_WALL + (4 * BONUS_TEXT_SIZE);
    yCursor += (2 * BONUS_TEXT_SIZE);
    Bonus_Print(BONUS_B, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_O, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_N, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_U, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;
    Bonus_Print(BONUS_S, xCursor, yCursor); xCursor += BONUS_TEXT_SIZE;

    // print the score
    xCursor = LEFT_WALL + (8 * BONUS_TEXT_SIZE);
    yCursor += 2 * BONUS_TEXT_SIZE;
    Bonus_PrintScore(score, xCursor, yCursor);
}

void Bonus_Display(int score, int stageClear) {
    if (stageClear) {
        Bonus_Stage(score);
    }
    else {
        Bonus_Normal(score);
    }
}
\ No newline at end of file

M bonus.h => bonus.h +4 -2
@@ 21,5 21,7 @@
// should be run before displaying any bonus
void Bonus_Init();

// shows a normal "CLEAR BONUS" bonus with the given score
void Bonus_Normal(int score);
\ No newline at end of file
// shows a bonus
// score: the score to display
// stageClear: 0 if this is a round clear bonus, 1 if this is a stage clear bonus
void Bonus_Display(int score, int stageClear);
\ No newline at end of file

M game.cpp => game.cpp +50 -7
@@ 50,6 50,9 @@ typedef enum {
    STATE_GAME_FLYUP,
    STATE_GAME_FLYDOWN,
    STATE_GAME_FLYOUT,
    STATE_GAME_ADDBONUS,
    STATE_GAME_WAIT,
    STATE_GAME_FADEOUT,
    STATE_GAME_OVER,
} GAME_STATE;



@@ 61,6 64,11 @@ static float frames = 0;

int score = 0;

// end-of-round bonus information
static int stageClear;
static int bonus;


// extra lives, not total lives (you can have 0 lives)
#define START_LIVES (4)
static int lives = START_LIVES;


@@ 192,7 200,7 @@ void Game_StateReset() {
    Game_PowerUpReset();
}

void Game_Init(int level, int numLevels) {
void Game_Init(int level, int numLevels, int isStageClear, int bonusPoints) {
    Fade_Start(0xFF, 0x00, 30);
    Global_SetLoRes();
    shipSprite = SpriteInfo("ship.png");


@@ 241,6 249,10 @@ void Game_Init(int level, int numLevels) {
    Block_SetAlpha(255);
    // make sure the ship door is closed
    Hud_CloseShipDoor();

    stageClear = isStageClear;
    bonus = bonusPoints;

    gameLevel = std::make_unique<Level>(LEFT_WALL, TOP_WALL, gameLevelNum, BLOCK_MODE_NORMAL);

    state = STATE_GAME_FADEIN;


@@ 588,7 600,7 @@ int Game_Run() {
    // move the ship to the center of the playfield in preparation for the
    // flying out animation
    case STATE_GAME_CENTERSHIP:
        Bonus_Normal(1000);
        Bonus_Display(bonus, stageClear);
        if (shipSprite.x < SHIP_STARTX) {
            shipSprite.x += 3;
            if (shipSprite.x > SHIP_STARTX) {


@@ 610,7 622,7 @@ int Game_Run() {

    // door at the top opens to allow the ship to pass through
    case STATE_GAME_SHIPDOOROPEN:
        Bonus_Normal(1000);
        Bonus_Display(bonus, stageClear);
        if (Hud_OpenShipDoor()) {
            state = STATE_GAME_FLYUP;
        }


@@ 618,7 630,7 @@ int Game_Run() {

    // ship moves up while transforming from a paddle to a ship
    case STATE_GAME_FLYUP:
        Bonus_Normal(1000);
        Bonus_Display(bonus, stageClear);
        if (shipSprite.y > SHIP_FLY1) {
            shipSprite.y--;
            // get the ship ready for animation


@@ 637,7 649,7 @@ int Game_Run() {

    // ship flies down with a small flame coming out the back
    case STATE_GAME_FLYDOWN:
        Bonus_Normal(1000);
        Bonus_Display(bonus, stageClear);
        if (shipSprite.y < SHIP_FLY3) {
            shipSprite.y += 0.5;
        }


@@ 655,16 667,47 @@ int Game_Run() {

    // ship flies offscreen with a large flame coming out the back
    case STATE_GAME_FLYOUT:
        Bonus_Normal(1000);
        Bonus_Display(bonus, stageClear);
        shipSpeed += 0.2;
        shipSprite.y -= shipSpeed;

        if (shipSprite.y < -128) {
            return 1;
            state = STATE_GAME_ADDBONUS;
            Hud_ChipSet(STATE_CHIP_WINK);
        }
        Game_FlameRun(FLAME_LARGE_START, FLAME_LARGE_END);
        break;

    // the bonus score gets added to the player's score
    case STATE_GAME_ADDBONUS:
        bonus -= 100;
        score += 100;
        Bonus_Display(bonus, stageClear);
        if (bonus <= 0) {
            bonus = 0;
            frames = 0;
            state = STATE_GAME_WAIT;
        }
        break;

    // wait a second for dramatic effect
    case STATE_GAME_WAIT:
        Bonus_Display(bonus, stageClear);
        frames += Speed_Multiplier();
        if (frames >= 60) {
            Fade_Out();
            state = STATE_GAME_FADEOUT;
        }
        break;

    case STATE_GAME_FADEOUT:
        Bonus_Display(bonus, stageClear);
        if (Fade_OutDone()) {
            return 1;
        }
        break;


    case STATE_GAME_OVER:
        frames += Speed_Multiplier();
        if (frames >= 360) {

M game.h => game.h +6 -1
@@ 76,7 76,12 @@ extern int gameLevelNum;
void Game_StateReset();

// inits a game running a set of levels
void Game_Init(int level, int numLevels);
// level: level number to start at
// numLevels: the number of levels to play through
// isStageClear: 1 if this is the last level set in a stage, 0 otherwise
// bonusPoints: the number of bonus points to give after clearing the level

void Game_Init(int level, int numLevels, int isStageClear, int bonusPoints);

// should be run every frame that you're playing the game
int Game_Run();

M hud.cpp => hud.cpp +6 -0
@@ 68,6 68,8 @@ static int chipBlinkTimings[CHIP_BLINK_NUMFRAMES] = {11, 4, 4};
#define BLINK_X (32)
#define BLINK_Y (16)

#define CHIP_WINK_FRAME (10)

#define CHIP_SLEEP_NUMFRAMES (8)
static int chipSleepFrames[CHIP_SLEEP_NUMFRAMES] = {18, 19, 20, 21, 22, 21, 20, 19};
static int chipSleepTimings[CHIP_SLEEP_NUMFRAMES] = {32, 18, 18, 18, 18, 18, 18, 18};


@@ 236,6 238,10 @@ static void Hud_ChipAnim() {
            }
            break;

        case STATE_CHIP_WINK:
            Anim_Put(CHIP_WINK_FRAME, BLINK_X, BLINK_Y);
            break;

        case STATE_CHIP_SLEEP:
            chipTimer += Speed_Multiplier();
            if (chipTimer >= chipSleepTimings[chipCursor]) {

M hud.h => hud.h +1 -0
@@ 41,6 41,7 @@ typedef enum {
    STATE_CHIP_BURNT,
    STATE_CHIP_SBLINK,
    STATE_CHIP_DBLINK,
    STATE_CHIP_WINK,
    STATE_CHIP_SLEEP,
    STATE_CHIP_GAMEOVER,
} CHIP_STATE;

M stage.cpp => stage.cpp +51 -2
@@ 27,6 27,8 @@
typedef struct StageStruct {
    std::string cutscene;
    std::string cutsceneText;
    int stageNum;
    int lastRound;
    int level;
    int numLevels;
    std::string tutorialText;


@@ 37,6 39,8 @@ STAGE stages[] = {
        .cutscene = "",
        //.cutscene = "a1.pak",
        .cutsceneText = "",
        .stageNum = 1,
        .lastRound = 0,
        .level = 0,
        .numLevels = 2,
        .tutorialText = "I'm Chip! I'll be working with you to\nbeat the game. These first levels are\neasy, so you can practice☆ Go!Go!"


@@ 44,6 48,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 1,
        .lastRound = 0,
        .level = 2,
        .numLevels = 2,
        .tutorialText = "Here is where the Move Block comes in.\nIt changes the ball's direction, but\nsometimes that's a good thing☆"


@@ 51,6 57,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 1,
        .lastRound = 0,
        .level = 4,
        .numLevels = 3,
        .tutorialText = "The Bio-Block can't be destroyed by\nlasers. Power up well and use the\nGigaball to clear it quickly!"


@@ 58,6 66,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 1,
        .lastRound = 1,
        .level = 7,
        .numLevels = 4,
        .tutorialText = "Watch out for the Stealth Blocks, and\nif the ball goes on top, use a\ndisruption attack☆"


@@ 65,6 75,8 @@ STAGE stages[] = {
    {
        .cutscene = "b1.pak",
        .cutsceneText = "",
        .stageNum = 2,
        .lastRound = 0,
        .level = 11,
        .numLevels = 2,
        .tutorialText = "Stage 2 starts here. There are many\nShield Blocks, so you have to be\npatient. Do your best☆"


@@ 72,6 84,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 2,
        .lastRound = 0,
        .level = 13,
        .numLevels = 2,
        .tutorialText = "You get more points for breaking blocks\nwith a ball than with a laser☆ Ballsy\nplayers can get a high score!"


@@ 79,6 93,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 2,
        .lastRound = 0,
        .level = 15,
        .numLevels = 3,
        .tutorialText = "The Revival Block will disappear if you\nhit it regularly. The rest is up to your\neffort and perseverence☆"


@@ 86,6 102,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 2,
        .lastRound = 1,
        .level = 18,
        .numLevels = 4,
        .tutorialText = "When the ball hits the top wall a\ncertain number of times, it speeds up.\nDon't miss the Slow Ball item!"


@@ 93,6 111,8 @@ STAGE stages[] = {
    {
        .cutscene = "c1.pak",
        .cutsceneText = "",
        .stageNum = 3,
        .lastRound = 0,
        .level = 22,
        .numLevels = 2,
        .tutorialText = "Stage 3 is the middle stage of the game.\nThe level on the right is a Metal\nOrange☆"


@@ 100,6 120,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 3,
        .lastRound = 0,
        .level = 24,
        .numLevels = 2,
        .tutorialText = "If you're good at using the Turbo\npower-up, Illusion may be more effective\nthan Bit. Give it a try☆"


@@ 107,6 129,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 3,
        .lastRound = 0,
        .level = 26,
        .numLevels = 3,
        .tutorialText = "You get 5000 bonus points for each loop\nof the power-up gauge☆ Go for it if\nyou're fully powered up!"


@@ 114,6 138,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 3,
        .lastRound = 1,
        .level = 29,
        .numLevels = 4,
        .tutorialText = "You have to raise the Gigaball to the\nsecond level to clear a stage with\nblocks surrounded by Shield Blocks☆"


@@ 121,6 147,8 @@ STAGE stages[] = {
    {
        .cutscene = "d1.pak",
        .cutsceneText = "",
        .stageNum = 4,
        .lastRound = 0,
        .level = 33,
        .numLevels = 2,
        .tutorialText = "Here we are at the second half of the\ngame. If you've made it this far, you're\na Metal Orange expert☆"


@@ 128,6 156,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 4,
        .lastRound = 0,
        .level = 35,
        .numLevels = 3,
        .tutorialText = "Be careful not to shoot lasers at\nRevival Blocks when they're hidden. It\nmay have the opposite effect☆"


@@ 135,6 165,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 4,
        .lastRound = 0,
        .level = 38,
        .numLevels = 3,
        .tutorialText = "For those of you suffering from the\nStealth Blocks, here's a tip:\n[tip goes here]"


@@ 142,6 174,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 4,
        .lastRound = 1,
        .level = 41,
        .numLevels = 4,
        .tutorialText = "Now, the last area of Stage 4. It\nshouldn't be too hard if you use the\npower-ups well☆ Go!Go!"


@@ 149,6 183,8 @@ STAGE stages[] = {
    {
        .cutscene = "e1.pak",
        .cutsceneText = "",
        .stageNum = 5,
        .lastRound = 0,
        .level = 45,
        .numLevels = 2,
        .tutorialText = "Finally, we are at the last stage,\nStage 5! The key is to make a strategy\nfor using your power-ups☆"


@@ 156,6 192,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 5,
        .lastRound = 0,
        .level = 47,
        .numLevels = 3,
        .tutorialText = "If you die, it's hard to recover, so\nlet's be diligent and try not to die!\nBelieve in the power of the Force☆"


@@ 163,6 201,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 5,
        .lastRound = 0,
        .level = 50,
        .numLevels = 4,
        .tutorialText = "Don't underestimate the EX stage, or\nyou'll be in for a world of hurt. Make\nsure you have Gigaball level 2☆"


@@ 170,6 210,8 @@ STAGE stages[] = {
    {
        .cutscene = "",
        .cutsceneText = "",
        .stageNum = 5,
        .lastRound = 1,
        .level = 54,
        .numLevels = 4,
        .tutorialText = "This is the last area! You've done so\nwell! I don't have anything to teach you\nnow. You can do it on your own☆"


@@ 226,8 268,15 @@ void Stage_Run() {
        }
        break;

    case STATE_GAME_INIT:
        Game_Init(stage->level, stage->numLevels);
    case STATE_GAME_INIT:;
        int bonus;
        if (stage->lastRound) {
            bonus = (stage->stageNum * 20000) - 10000;
        }
        else {
            bonus = stage->stageNum * 1000;
        }
        Game_Init(stage->level, stage->numLevels, stage->lastRound, bonus);
        state = STATE_GAME_RUN;
        // fall through