I don't even know what I'm doing anymore.

This commit is contained in:
Scott Duensing 2021-03-11 20:36:37 -06:00
parent 4f08699513
commit 16c45b6ab0
2 changed files with 23 additions and 78 deletions

View file

@ -27,7 +27,6 @@
#include <stddclmr.h> #include <stddclmr.h>
#define JOEY_MAIN
#include "joey.h" #include "joey.h"
#ifdef JOEY_IIGS #ifdef JOEY_IIGS
segment "warehouse"; segment "warehouse";
@ -197,7 +196,6 @@ void fontPrint(jlImgT *font, jint16 cx, jint16 cy, const char *what, ...);
void gamePlay(void); void gamePlay(void);
void gameSave(void); void gameSave(void);
void imageShow(jlImgT *image); void imageShow(jlImgT *image);
bool inputRead(byte *key);
byte menuDraw(const char *titleShow, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY); byte menuDraw(const char *titleShow, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY);
jint16 menuHandle(const char *titleShow, const char *menuItems[], jint16 selected); jint16 menuHandle(const char *titleShow, const char *menuItems[], jint16 selected);
bool menuMain(void); bool menuMain(void);
@ -245,7 +243,6 @@ void avatarCrateHide(byte x1, byte y1, bool pushing) {
void avatarCrateShow(void) { void avatarCrateShow(void) {
jlImgDisplay(savedScreen1);
avatarDraw(AVATAR_X_ON_SCREEN, AVATAR_Y_ON_SCREEN, avatarFacing, 0); avatarDraw(AVATAR_X_ON_SCREEN, AVATAR_Y_ON_SCREEN, avatarFacing, 0);
} }
@ -542,23 +539,23 @@ void gamePlay(void) {
byte tile = 0; byte tile = 0;
while (playing && !jlUtilMustExit()) { while (playing && !jlUtilMustExit()) {
if (inputRead(&key)) { if (jlUtilInputRead(&key)) {
avatarXLast = avatarX; avatarXLast = avatarX;
avatarYLast = avatarY; avatarYLast = avatarY;
switch (key) { switch (key) {
case 27: case JOEY_INPUT_SECONDARY:
playing = menuMain(); playing = menuMain();
break; break;
case 13: case JOEY_INPUT_PRIMARY:
//paletteShow();
if (1 == menuHandle("Reset Level?", menuReset, 0)) { if (1 == menuHandle("Reset Level?", menuReset, 0)) {
puzzleReset(); puzzleReset();
puzzleForceFullRedraw(); puzzleForceFullRedraw();
} }
break; break;
case 'I': case JOEY_INPUT_UP:
case 'i':
// Can we move up? // Can we move up?
tile = puzzleNow[avatarX][avatarY - 1]; tile = puzzleNow[avatarX][avatarY - 1];
if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) {
@ -573,8 +570,7 @@ void gamePlay(void) {
} }
break; break;
case 'J': case JOEY_INPUT_LEFT:
case 'j':
// Can we move left? // Can we move left?
tile = puzzleNow[avatarX - 1][avatarY]; tile = puzzleNow[avatarX - 1][avatarY];
if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) {
@ -589,8 +585,7 @@ void gamePlay(void) {
} }
break; break;
case 'K': case JOEY_INPUT_RIGHT:
case 'k':
// Can we move right? // Can we move right?
tile = puzzleNow[avatarX + 1][avatarY]; tile = puzzleNow[avatarX + 1][avatarY];
if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) {
@ -605,8 +600,7 @@ void gamePlay(void) {
} }
break; break;
case 'M': case JOEY_INPUT_DOWN:
case 'm':
// Can we move down? // Can we move down?
tile = puzzleNow[avatarX][avatarY + 1]; tile = puzzleNow[avatarX][avatarY + 1];
if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) {
@ -668,7 +662,7 @@ void imageShow(jlImgT *image) {
jlImgDisplay(image); jlImgDisplay(image);
jlDisplayPresent(); jlDisplayPresent();
while (!inputRead(&key) && !jlUtilMustExit()) { while (!jlUtilInputRead(&key) && !jlUtilMustExit()) {
// Do nothing // Do nothing
} }
@ -677,44 +671,6 @@ void imageShow(jlImgT *image) {
} }
bool inputRead(byte *key) {
static bool debounceController = false;
*key = 0;
// Keyboard
if (jlKeyPressed()) {
while (jlKeyPressed()) {
*key = jlKeyRead();
}
return true;
}
// Joystick
if (jlGameGetAxis(0) < -50) *key = 'J';
if (jlGameGetAxis(0) > 50) *key = 'K';
if (jlGameGetAxis(1) < -50) *key = 'I';
if (jlGameGetAxis(1) > 50) *key = 'M';
if (jlGameGetButton(0)) *key = 13;
if (jlGameGetButton(1)) *key = 27;
// Debounce Joystick Input
if (debounceController) {
*key = 0;
return false;
} else {
if (*key != 0) {
debounceController = true;
return true;
}
}
debounceController = false;
return false;
}
byte menuDraw(const char *title, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY) { byte menuDraw(const char *title, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY) {
jint16 count = 0; jint16 count = 0;
@ -802,19 +758,18 @@ jint16 menuHandle(const char *title, const char *menuItems[], jint16 selected) {
lastY = ypos; lastY = ypos;
last = (selected == 0 ? 1 : 0); last = (selected == 0 ? 1 : 0);
while (inMenu && !jlUtilMustExit()) { while (inMenu && !jlUtilMustExit()) {
if (inputRead(&key)) { if (jlUtilInputRead(&key)) {
switch (key) { switch (key) {
case 27: case JOEY_INPUT_SECONDARY:
inMenu = false; inMenu = false;
break; break;
case 13: case JOEY_INPUT_PRIMARY:
result = selected; result = selected;
inMenu = false; inMenu = false;
break; break;
case 'I': case JOEY_INPUT_UP:
case 'i':
if (selected > 0) { if (selected > 0) {
selected--; selected--;
ypos -= 16; ypos -= 16;
@ -824,8 +779,7 @@ jint16 menuHandle(const char *title, const char *menuItems[], jint16 selected) {
} }
break; break;
case 'M': case JOEY_INPUT_DOWN:
case 'm':
if (selected < count - 1) { if (selected < count - 1) {
selected++; selected++;
ypos += 16; ypos += 16;
@ -1139,22 +1093,21 @@ void puzzleSelect(void) {
lastY = -1; lastY = -1;
while (inMenu && !jlUtilMustExit()) { while (inMenu && !jlUtilMustExit()) {
if (inputRead(&data)) { if (jlUtilInputRead(&data)) {
avatarXLast = avatarX; avatarXLast = avatarX;
avatarYLast = avatarY; avatarYLast = avatarY;
switch (data) { switch (data) {
case 27: case JOEY_INPUT_SECONDARY:
inMenu = false; inMenu = false;
break; break;
case 13: case JOEY_INPUT_PRIMARY:
// Actually loaded and redrawn in play loop. // Actually loaded and redrawn in play loop.
puzzleCurrent = p; puzzleCurrent = p;
inMenu = false; inMenu = false;
break; break;
case 'I': case JOEY_INPUT_UP:
case 'i':
// Case when we'll land in the 'dangling' line. // Case when we'll land in the 'dangling' line.
if (p <= dangling) { if (p <= dangling) {
p = puzzleCount - (dangling - p); p = puzzleCount - (dangling - p);
@ -1169,8 +1122,7 @@ void puzzleSelect(void) {
} }
break; break;
case 'J': case JOEY_INPUT_LEFT:
case 'j':
if (p > 1) { if (p > 1) {
p--; p--;
} else { } else {
@ -1178,8 +1130,7 @@ void puzzleSelect(void) {
} }
break; break;
case 'K': case JOEY_INPUT_RIGHT:
case 'k':
if (p < puzzleCount) { if (p < puzzleCount) {
p++; p++;
} else { } else {
@ -1187,8 +1138,7 @@ void puzzleSelect(void) {
} }
break; break;
case 'M': case JOEY_INPUT_DOWN:
case 'm':
// Are we moving down from the 'dangling' line? // Are we moving down from the 'dangling' line?
if (p > (cols * (cols - 1))) { if (p > (cols * (cols - 1))) {
p = dangling - (puzzleCount - p); p = dangling - (puzzleCount - p);
@ -1308,14 +1258,14 @@ void titleShow(void) {
} }
int main(void) { void joeyMain(void) {
jint16 i = 0; jint16 i = 0;
jint16 j = 0; jint16 j = 0;
jint16 x = 0; jint16 x = 0;
jint16 y = 0; jint16 y = 0;
FILE *in = NULL; FILE *in = NULL;
jlUtilStartup("Warehouse"); jlUtilTitleSet("Warehouse");
// Get something on the screen as quickly as possible. // Get something on the screen as quickly as possible.
titleShow(); titleShow();
@ -1410,6 +1360,4 @@ int main(void) {
jlStnFree(tilesS); jlStnFree(tilesS);
jlImgFree(tilesI); jlImgFree(tilesI);
jlImgFree(fontI); jlImgFree(fontI);
jlUtilShutdown();
} }

BIN
warehouse/tiles.xcf (Stored with Git LFS)

Binary file not shown.