- [NEW] Cat's Life
This commit is contained in:
@@ -209,3 +209,15 @@ actor{
|
|||||||
flags: ANIMATED
|
flags: ANIMATED
|
||||||
movement: CW
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1567,10 +1567,12 @@ namespace actor
|
|||||||
int partsCollected = 0;
|
int partsCollected = 0;
|
||||||
bool roomVisited[MAX_ROOMS];
|
bool roomVisited[MAX_ROOMS];
|
||||||
int livesLost = 0;
|
int livesLost = 0;
|
||||||
|
int catsLifeOdds = 5;
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
partsCollected = livesLost = 0;
|
partsCollected = livesLost = 0;
|
||||||
|
catsLifeOdds = 5;
|
||||||
for (int i=0; i<MAX_ROOMS; ++i) roomVisited[i] = false;
|
for (int i=0; i<MAX_ROOMS; ++i) roomVisited[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1587,6 +1589,17 @@ namespace actor
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getLivesLost() { return livesLost; }
|
int getLivesLost() { return livesLost; }
|
||||||
|
|
||||||
|
bool catsLife()
|
||||||
|
{
|
||||||
|
if ( (rand()%catsLifeOdds) == 0) {
|
||||||
|
catsLifeOdds *= 2;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,5 +222,7 @@ namespace actor
|
|||||||
int getNumPartsCollected();
|
int getNumPartsCollected();
|
||||||
int getRoomsVisited();
|
int getRoomsVisited();
|
||||||
int getLivesLost();
|
int getLivesLost();
|
||||||
|
|
||||||
|
bool catsLife();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
44
source/m_catslife.cpp
Normal file
44
source/m_catslife.cpp
Normal 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
10
source/m_catslife.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace catslife
|
||||||
|
{
|
||||||
|
void init();
|
||||||
|
bool loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ namespace modules
|
|||||||
namespace gameover
|
namespace gameover
|
||||||
{
|
{
|
||||||
actor::actor_t *heroi = nullptr;
|
actor::actor_t *heroi = nullptr;
|
||||||
int selected_option = GAMEOVER_CONTINUAR;
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ namespace modules
|
|||||||
heroi->flags = FLAG_ANIMATED;
|
heroi->flags = FLAG_ANIMATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loop()
|
bool loop()
|
||||||
{
|
{
|
||||||
if (input::keyPressed(SDL_SCANCODE_SPACE)) {
|
if (input::keyPressed(SDL_SCANCODE_SPACE)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ namespace modules
|
|||||||
{
|
{
|
||||||
namespace gameover
|
namespace gameover
|
||||||
{
|
{
|
||||||
#define GAMEOVER_CONTINUAR 0
|
|
||||||
#define GAMEOVER_EIXIR 1
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
int loop();
|
bool loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,15 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
#include "actor.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
#include "m_game.h"
|
#include "m_game.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "m_logo.h"
|
#include "m_logo.h"
|
||||||
#include "m_ingame.h"
|
#include "m_ingame.h"
|
||||||
#include "m_gameover.h"
|
#include "m_gameover.h"
|
||||||
|
#include "m_catslife.h"
|
||||||
#include "m_menu_tecles.h"
|
#include "m_menu_tecles.h"
|
||||||
#include "m_menu_audio.h"
|
#include "m_menu_audio.h"
|
||||||
|
|
||||||
@@ -21,8 +25,9 @@
|
|||||||
#define M_GAME 2
|
#define M_GAME 2
|
||||||
#define M_INGAME 3
|
#define M_INGAME 3
|
||||||
#define M_GAMEOVER 4
|
#define M_GAMEOVER 4
|
||||||
#define M_MENU_TECLES 5
|
#define M_CATSLIFE 5
|
||||||
#define M_MENU_AUDIO 6
|
#define M_MENU_TECLES 6
|
||||||
|
#define M_MENU_AUDIO 7
|
||||||
|
|
||||||
int current_module = M_LOGO;
|
int current_module = M_LOGO;
|
||||||
int zoom = 3;
|
int zoom = 3;
|
||||||
@@ -124,9 +129,13 @@ bool game::loop()
|
|||||||
modules::ingame::init(); current_module = M_INGAME;
|
modules::ingame::init(); current_module = M_INGAME;
|
||||||
}
|
}
|
||||||
} else if (option==GAME_DEAD) {
|
} else if (option==GAME_DEAD) {
|
||||||
|
if (actor::stats::catsLife()) {
|
||||||
|
modules::catslife::init(); current_module = M_CATSLIFE;
|
||||||
|
} else {
|
||||||
modules::gameover::init(); current_module = M_GAMEOVER;
|
modules::gameover::init(); current_module = M_GAMEOVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case M_INGAME:
|
case M_INGAME:
|
||||||
option = modules::ingame::loop();
|
option = modules::ingame::loop();
|
||||||
@@ -140,6 +149,14 @@ bool game::loop()
|
|||||||
modules::menu::init(); current_module = M_MENU;
|
modules::menu::init(); current_module = M_MENU;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case M_MENU_TECLES:
|
||||||
if (modules::menu_tecles::loop() == MENU_TECLES_TORNAR) {
|
if (modules::menu_tecles::loop() == MENU_TECLES_TORNAR) {
|
||||||
modules::menu::init(); current_module = M_MENU;
|
modules::menu::init(); current_module = M_MENU;
|
||||||
|
|||||||
@@ -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 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)
|
void load(int room, const int door)
|
||||||
{
|
{
|
||||||
if (room > MAX_ROOMS || room < 0) {
|
if (room > MAX_ROOMS || room < 0) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace room
|
|||||||
{
|
{
|
||||||
void init();
|
void init();
|
||||||
void load(int room, const int door=-1);
|
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 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 update();
|
||||||
void draw();
|
void draw();
|
||||||
|
|||||||
Reference in New Issue
Block a user