- [NEW] Cat's Life

This commit is contained in:
2024-07-25 10:16:57 +02:00
parent 1f6ce61ee2
commit 8c8449fb16
10 changed files with 107 additions and 10 deletions

View File

@@ -209,3 +209,15 @@ actor{
flags: ANIMATED
movement: CW
}
actor{
name: GAT-NEGRE
bmp: gat.gif
bmp-rect: 0 0 24 26
bmp-offset: 0 32
pos: 32 32 0
size: 8 8 8
anim-wait: 2
flags: ANIMATED
movement: CW
}

View File

@@ -1567,10 +1567,12 @@ namespace actor
int partsCollected = 0;
bool roomVisited[MAX_ROOMS];
int livesLost = 0;
int catsLifeOdds = 5;
void reset()
{
partsCollected = livesLost = 0;
catsLifeOdds = 5;
for (int i=0; i<MAX_ROOMS; ++i) roomVisited[i] = false;
}
@@ -1587,6 +1589,17 @@ namespace actor
}
int getLivesLost() { return livesLost; }
bool catsLife()
{
if ( (rand()%catsLifeOdds) == 0) {
catsLifeOdds *= 2;
return true;
} else {
return false;
}
}
}
}

View File

@@ -222,5 +222,7 @@ namespace actor
int getNumPartsCollected();
int getRoomsVisited();
int getLivesLost();
bool catsLife();
}
}

44
source/m_catslife.cpp Normal file
View File

@@ -0,0 +1,44 @@
#include "m_catslife.h"
#include "jgame.h"
#include "jinput.h"
#include "jdraw.h"
#include "actor.h"
#include "room.h"
#include "config.h"
#include <SDL2/SDL.h>
namespace modules
{
namespace catslife
{
actor::actor_t *gat = nullptr;
void init()
{
if (gat == nullptr) gat = actor::createFromTemplate("GAT-NEGRE");
}
bool loop()
{
if (input::keyPressed(SDL_SCANCODE_SPACE)) {
return false;
}
draw::cls(2);
draw::color(1);
draw::swapcol(1, WHITE);
actor::update(gat, false);
actor::drawAt(gat, 150, 130);
draw::print2("THE POOL", 16, 3, TEAL, FONT_ZOOM_VERTICAL);
draw::print2("CAT'S LIFE", 15, 9, YELLOW, FONT_ZOOM_VERTICAL);
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
draw::render();
return true;
}
}
}

10
source/m_catslife.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
namespace modules
{
namespace catslife
{
void init();
bool loop();
}
}

View File

@@ -12,7 +12,6 @@ namespace modules
namespace gameover
{
actor::actor_t *heroi = nullptr;
int selected_option = GAMEOVER_CONTINUAR;
void init()
{
@@ -20,7 +19,7 @@ namespace modules
heroi->flags = FLAG_ANIMATED;
}
int loop()
bool loop()
{
if (input::keyPressed(SDL_SCANCODE_SPACE)) {
return false;

View File

@@ -4,10 +4,7 @@ namespace modules
{
namespace gameover
{
#define GAMEOVER_CONTINUAR 0
#define GAMEOVER_EIXIR 1
void init();
int loop();
bool loop();
}
}

View File

@@ -8,11 +8,15 @@
#include "config.h"
#include <SDL2/SDL.h>
#include "actor.h"
#include "room.h"
#include "m_game.h"
#include "m_menu.h"
#include "m_logo.h"
#include "m_ingame.h"
#include "m_gameover.h"
#include "m_catslife.h"
#include "m_menu_tecles.h"
#include "m_menu_audio.h"
@@ -21,8 +25,9 @@
#define M_GAME 2
#define M_INGAME 3
#define M_GAMEOVER 4
#define M_MENU_TECLES 5
#define M_MENU_AUDIO 6
#define M_CATSLIFE 5
#define M_MENU_TECLES 6
#define M_MENU_AUDIO 7
int current_module = M_LOGO;
int zoom = 3;
@@ -124,7 +129,11 @@ bool game::loop()
modules::ingame::init(); current_module = M_INGAME;
}
} else if (option==GAME_DEAD) {
modules::gameover::init(); current_module = M_GAMEOVER;
if (actor::stats::catsLife()) {
modules::catslife::init(); current_module = M_CATSLIFE;
} else {
modules::gameover::init(); current_module = M_GAMEOVER;
}
}
}
break;
@@ -140,6 +149,14 @@ bool game::loop()
modules::menu::init(); current_module = M_MENU;
}
break;
case M_CATSLIFE:
if (!modules::catslife::loop()) {
actor::hero::init(false);
actor::hero::setLives(1);
room::reload();
current_module = M_GAME;
}
break;
case M_MENU_TECLES:
if (modules::menu_tecles::loop() == MENU_TECLES_TORNAR) {
modules::menu::init(); current_module = M_MENU;

View File

@@ -121,6 +121,8 @@ namespace room
}
//void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col, uint8_t floor, uint8_t walls, uint8_t door, uint8_t walldoor)
void reload() { load(current_room); }
void load(int room, const int door)
{
if (room > MAX_ROOMS || room < 0) {

View File

@@ -21,6 +21,7 @@ namespace room
{
void init();
void load(int room, const int door=-1);
void reload();
//void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col, uint8_t floor, uint8_t walls, uint8_t door, uint8_t doorwall);
void update();
void draw();