Add basic gesture flavor text, add some debug tools for the SDL2

frontend
This commit is contained in:
blitzdoughnuts 2024-12-03 22:20:23 -05:00
parent 9db26c2d68
commit 0c75019708
7 changed files with 115 additions and 37 deletions

BIN
ASSETS/debug.ase Normal file

Binary file not shown.

View file

@ -37,6 +37,7 @@
- Walking, jumping (DONE, jumping is scrapped)
- State system (DONE)
- Sprites and animations
- Maybe an optional system where animation frames can be picked by the frontend to do optimized animations that reuse frames?
- Properly implement cutscene-ish events
- Books:
- Hamie:

BIN
NMARE.xm

Binary file not shown.

View file

@ -63,12 +63,13 @@ Made by blitzdoughnuts
#define FLAG_STEPDEBOUNCE 1 << 4 // for player, flag to not spam step sounds on a frame
#define FLAG_HASCOAT 1 << 5 // for player: does the player have the coat?
#define FLAG_HALTANIM 1 << 6 // stops animations from looping
#define FLAG_REVERSEANIM 1 << 7 // animations play backwards
#define FLAG_REVERSEANIM 1 << 7 // animations play backwards (frames go backward from max)
#define INTER_ACTIVE 1 << 7 // for interactibles; is this interactible active?
// game flags for e.g. routes
#define FLAG_HAMIEBOOK 1 // player has read Hamie's photobook?
#define FLAG_LIMEBOOK 1 << 1 // player has read the hospital handbook?
#define FLAG_LIMEBOOK 1 << 1 // player has read the hospital handbook?
#define FLAG_MUG 1 << 2 // player drank the mug?
// player states
#define PSTATE_NORMAL 0
@ -153,16 +154,29 @@ Made by blitzdoughnuts
// Gesture interactions with INTERTYPE_GESTUREs
// Basically flavor text
#define GESTURE_INVALID "There's nothing interesting here."
#define GESTURE_BED "Most people wouldn't want to sleep on a piled up blanket. I do, though."
#define GESTURE_COMPUTER "I don't really do much with this. Most of the stuff I see on the... \"Internet\" is just mindless political blabber."
#define GESTURE_BADGE "Aha, my Limetown Hospital badge! Sometimes I wonder why I feel such a strong connection with this thing."
#define GESTURE_KNIFE "Some blades are meant for precision. This is more like a weapon."
#define GESTURE_DONUT "What is a donut doing here? It may not be safe to eat, considering I have no clue how long it's been sitting here."
#define GESTURE_MIRROR "Now I can look into my eyes, my soul, and see just how cracked it is. Maybe even something behind me..."
#define GESTURE_YOU "This guy gives me some serious... uh... I'm not even sure how to describe it. I just feel very weird around him."
#define GESTURE_STOOL "Now where could the bartender be?" // may not be used, Gesturing with a stool can let you sit on it
#define GESTURE_RECEPTIONIST "God, I hate the world I live in... If only my psychiatry experience could help me figure out why I do." // receptionist desk
#define GESTURE_OUTDOORS "Why is the sky red? It's not even dawn."
#define GESTURE_BURNING "..."
#define GESTURE_GASOLINE "It isn't hard to put two and two together here now."
#define GESTURE_INVALID 0
#define GESTURESTR_INVALID "There's nothing interesting here."
#define GESTURE_BED 1
#define GESTURESTR_BED "Most people wouldn't want to sleep on a piled up blanket. I do, though."
#define GESTURE_COMPUTER 2
#define GESTURESTR_COMPUTER "I don't really do much with this. Most of the stuff I see on the... \"Internet\" is just mindless political blabber."
#define GESTURE_BADGE 3
#define GESTURESTR_BADGE "Aha, my Limetown Hospital badge! Sometimes I wonder why I feel such a strong connection with this thing."
#define GESTURE_KNIFE 4
#define GESTURESTR_KNIFE "Some blades are meant for precision. This is more like a weapon."
#define GESTURE_DONUT 5
#define GESTURESTR_DONUT "What is a donut doing here? It may not be safe to eat, considering I have no clue how long it's been sitting here."
#define GESTURE_MIRROR 6
#define GESTURESTR_MIRROR "Now I can look into my eyes, my soul, and see just how cracked it is. Maybe even something behind me..."
#define GESTURE_YOU 7
#define GESTURESTR_YOU "This guy gives me some serious... uh... I'm not even sure how to describe it. I just feel very weird around him."
#define GESTURE_STOOL 8
#define GESTURESTR_STOOL "Now where could the bartender be?" // may not be used, Gesturing with a stool can let you sit on it
#define GESTURE_RECEPTIONIST 9
#define GESTURESTR_RECEPTIONIST "God, I hate the world I live in... If only my psychiatry experience could help me figure out why I do." // receptionist desk
#define GESTURE_OUTDOORS 10
#define GESTURESTR_OUTDOORS "Why is the sky red? It's not even dawn."
#define GESTURE_BURNING 11
#define GESTURESTR_BURNING "..."
#define GESTURE_GASOLINE 12
#define GESTURESTR_GASOLINE "It isn't hard to put two and two together here now."

41
game.h
View file

@ -38,7 +38,7 @@ Made by blitzdoughnuts
#define INTER_LIMIT 32 // how many interactibles can be on a level at a time?
#define WINTITLE "Wake to Hell"
#define VERSION_NUMBER "0.2.0a"
#define VERSION_NUMBER "0.2.1a"
#define WTH_keyPressed(keyvalue) (input_keys & keyvalue) && !(input_prevkeys & keyvalue)
// easy way to check if a key was down but NOT held, saves space for comment rambling
@ -87,6 +87,22 @@ uint8_t level; // all rooms, 256 is overkill but overkill is what's needed
uint8_t fade, fademode; // fade variables, basically alpha
uint8_t fadespeed;
char *gestures[13] = {
GESTURESTR_INVALID,
GESTURESTR_BED,
GESTURESTR_COMPUTER,
GESTURESTR_BADGE,
GESTURESTR_KNIFE,
GESTURESTR_DONUT,
GESTURESTR_MIRROR,
GESTURESTR_YOU,
GESTURESTR_STOOL,
GESTURESTR_RECEPTIONIST,
GESTURESTR_OUTDOORS,
GESTURESTR_BURNING,
GESTURESTR_GASOLINE
};
uint8_t options[3];
uint8_t input_keys;
@ -95,7 +111,6 @@ uint8_t xtrakeys;
void saveGame();
void loadGame();
// frontend, please add details
uint8_t addObject(int nx, int ny, uint8_t objType) {
#ifdef WTHCOMPILER_DEBUG
@ -117,6 +132,7 @@ uint8_t addObject(int nx, int ny, uint8_t objType) {
switch (objType)
{
case INTERTYPE_DOOR:
// open door if it spawns over the player
if (plr.x >= interacts[index].x - 40 && plr.x < interacts[index].x + 40) interacts[index].flags ^= 1 << 2;
break;
case INTERTYPE_YOU:
@ -161,9 +177,11 @@ static inline void LoadInRoom() {
addObject(-360, 0, INTERTYPE_MOVEBLOCK);
addObject(615, GROUNDLEVEL, INTERTYPE_DOOR);
interacts[4].vars[0] = ROOM_OUTDOORS;
addObject(408, GROUNDLEVEL, INTERTYPE_GESTURE);
interacts[5].vars[0] = GESTURE_COMPUTER;
if (!(plr.artifacts & (1 << ARTIFACT_KNIFE))) {
addObject(-156, 140, INTERTYPE_ARTIFACT);
interacts[5].vars[0] = ARTIFACT_KNIFE;
interacts[6].vars[0] = ARTIFACT_KNIFE;
};
break;
case ROOM_OUTDOORS: // outside of house
@ -186,7 +204,9 @@ static inline void LoadInRoom() {
interacts[ addObject(270, GROUNDLEVEL, INTERTYPE_DOOR) ].vars[0] = ROOM_HOSPITAL;
break;
case ROOM_HOSPITAL: // hospital main lobby (badge artifact)
if (plr.artifacts >= 15) interacts[ addObject(-20, GROUNDLEVEL, INTERTYPE_DOOR) ].vars[0] = 10;
// if you DON'T have all the artifacts, allow exiting of the room
// TO-DO: cutscene of the door slamming
if (!(plr.artifacts >= 15)) interacts[ addObject(-20, GROUNDLEVEL, INTERTYPE_DOOR) ].vars[0] = 10;
break;
case ROOM_H_PATIENTS:
addObject(0, 0, INTERTYPE_MOVEBLOCK);
@ -495,6 +515,19 @@ void step() {
{
case PSTATE_NORMAL:
if (!(plr.flags & FLAG_CANTMOVE)) {
if (WTH_keyPressed(KEY_GESTURE)) {
uint8_t found = 0;
for (uint8_t i = 0; i < interacts_count; i++) {
if (interacts[i].objID != INTERTYPE_GESTURE) continue;
if (interacts[i].x - 30 <= plr.x && interacts[i].x + 30 >= plr.x) {
puts(gestures[interacts[i].vars[0]]);
found = 1;
break;
};
};
if (!found) puts(gestures[0]);
};
if ((input_keys & KEY_LEFT) && plr.hsp > -3) {
plr.hsp_sub -= SUBPIXELUNIT_ACCURACY / 8;
plr.animindex = WTH_PLR_WALK_SPR;

View file

@ -19,19 +19,9 @@ Made by blitzdoughnuts
#include "game.h" // keep in mind, MAIN can still access variables from the game!
#ifndef EDITMODE
#define EDITMODE 0
#endif
// for aspect correction
#define CAM_VERTOFFSET ((HEIGHT - 270) / 4)
#if EDITMODE == 1
uint8_t editkeys;
uint8_t editkeys_prev;
#endif
// the hackiest debug feature TO DATE
// lookup table for font offsets, to offset the character afterwards to the left by this amount
static const uint8_t fontOffsets_left[90] = {
21, 12, 3, 11, 7, 14, 22, 20, 20, 4, 4, 21, 1, 20, 11, // 33-47
@ -59,7 +49,7 @@ Mix_Chunk *sfx[12];
SDL_Texture *wintext;
SDL_Texture *plrsprites[10];
SDL_Texture *sprites[20];
SDL_Texture *sprites[21];
SDL_Rect dspdest_rect; // this is the DESTINATION, aka screen position
SDL_Rect fade_rect; // used for fading in/out
@ -87,6 +77,12 @@ uint32_t demoPointer;
static const char str_wintitle[] = WINTITLE; // it's only here to cut down redundancies
#endif
#ifdef WTH_DEBUG
uint8_t DEBUG_keys;
uint8_t DEBUG_lastkeys;
uint8_t DEBUG_objSel;
#endif
void drawRepeatingSprite(SDL_Texture *sprite, int x, int y) {
int _x = x;
dspdest_rect.x = x;
@ -308,6 +304,11 @@ void draw() {
case INTERTYPE_BOOK:
drawSpriteSheeted(sprites[WTH_SPR_BOOK_HAMIE], (interacts[i].x - 32) - cam.x, (interacts[i].y - 32) - cam.y, ((interacts[i].flags & 1 << 2) || interacts[i].vars[1]) ? 1 : 0, 64, 64, 0);
break;
#ifdef WTH_DEBUG
case INTERTYPE_GESTURE:
drawSprite(sprites[20], (interacts[i].x - 75) - cam.x, (interacts[i].y - 100) - cam.y);
break;
#endif
}
};
@ -413,25 +414,53 @@ void keys() {
}
#ifdef WTH_DEBUG
editkeys = 0;
int mx, my;
int win_width, win_height;
SDL_GetMouseState(&mx, &my);
SDL_GetWindowSize(win, &win_width, &win_height);
if (keystates[SDL_SCANCODE_1]) addObject(
if (keystates[SDL_SCANCODE_5]) DEBUG_keys ^= 1;
if (keystates[SDL_SCANCODE_1]) DEBUG_keys ^= 2;
if (keystates[SDL_SCANCODE_2]) DEBUG_keys ^= 4;
if (keystates[SDL_SCANCODE_HOME]) DEBUG_keys ^= 8;
if (keystates[SDL_SCANCODE_END]) DEBUG_keys ^= 16;
if (keystates[SDL_SCANCODE_INSERT]) DEBUG_keys ^= 32;
if (keystates[SDL_SCANCODE_PAGEUP]) DEBUG_keys ^= 64;
#define DEBUG_pressed(key) ((DEBUG_keys ^ key) && !(DEBUG_lastkeys ^ key))
if (DEBUG_pressed(1)) addObject(
(mx - cam.x) / (win_width / WIDTH),
(my - cam.y) / (win_height / HEIGHT),
INTERTYPE_COAT
);
if (keystates[SDL_SCANCODE_2]) editkeys = 1;
if (editkeys != 0 && editkeys_prev == 0) {
if (DEBUG_pressed(2)) {
level--;
LoadInRoom();
};
if (DEBUG_pressed(4)) {
level++;
LoadInRoom();
};
editkeys_prev = editkeys;
editkeys = 0;
if (DEBUG_pressed(8)) {
DEBUG_objSel--;
printf("OBJECT SELECTED: %i\n", DEBUG_objSel);
};
if (DEBUG_pressed(16)) {
DEBUG_objSel++;
printf("OBJECT SELECTED: %i\n", DEBUG_objSel);
};
if (DEBUG_pressed(32)) {
interacts[DEBUG_objSel].x -= 16;
printf("%i\n", interacts[DEBUG_objSel].x);
};
if (DEBUG_pressed(64)) {
interacts[DEBUG_objSel].x += 16;
printf("%i\n", interacts[DEBUG_objSel].x);
};
DEBUG_lastkeys = DEBUG_keys;
DEBUG_keys = 0;
if (keystates[SDL_SCANCODE_BACKSPACE]) {
puts("== DEBUG PRINT START ==");
@ -548,6 +577,7 @@ int main(int argc, char *argv[]) {
sprites[WTH_SPR_DECOR_HATRACK] = IMG_LoadTexture(render, "sprites/decor_hatrack.png");
sprites[WTH_SPR_BOOK_HAMIE] = IMG_LoadTexture(render, "sprites/book.png");
sprites[WTH_SPR_READ_HAMIE] = IMG_LoadTexture(render, "sprites/read_hamie.png");
sprites[20] = IMG_LoadTexture(render, "sprites/DEBUG_gesture.png");
running = 1;
SDL_Event event;

BIN
sprites/DEBUG_gesture.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B