diff --git a/README.md b/README.md index af744e5..9f8e807 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ See this repository: https://git.imzadi.de/acn/backgammon-vt100 * [Robots](Robots/) * [FindThatMine](FindThatMine/) * [Snake](Snake/) +* [Robot Chase](RobotChase/) ## More Games on the Interwebs diff --git a/RobotChase/CHASE.COM b/RobotChase/CHASE.COM new file mode 100644 index 0000000..54d6531 Binary files /dev/null and b/RobotChase/CHASE.COM differ diff --git a/RobotChase/LICENSE b/RobotChase/LICENSE new file mode 100644 index 0000000..9efd47e --- /dev/null +++ b/RobotChase/LICENSE @@ -0,0 +1,7 @@ +Copyright 2020 Andrew Pamment + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/RobotChase/README.md b/RobotChase/README.md new file mode 100644 index 0000000..7cb9003 --- /dev/null +++ b/RobotChase/README.md @@ -0,0 +1,43 @@ +# Robot Chase + +Copyright 2020 Andrew Pamment + +Based on the game "CHASE" appearing in the book +"More BASIC Computer Games" by David Ahl. + +The original files can be found here: http://members.iinet.net.au/~apamment/CPM/ + +## The game + +You are trapped in a maze of high voltage power fences and posts. There are also +killer robots trying to destroy you. + +Your only hope is to lure the robots into a fence or each other to destroy them. + +If things get hopeless, you can do a mega jump, but you could end up anywhere, +including on top of a power fence or a robot! + +## Keys + +Use the numpad to move, even diagonally. +Use ``J`` to jump and ``0`` to pass a round. + + 7 8 9 J - Jump + \ | / 0 - Pass + 4 - * - 6 + / | \ + 1 2 3 Q - Quit + + * - You + X - High Voltage Line + + - Killer Robot + +## Compiling + +Robot Chase is written in C for the ZXCC compiler which can be found in [z88dk](https://www.z88dk.org/). + +Use this command line (tested in Linux) to compile: + + zcc +cpm -lm -lndos -o CHASE.COM chase.c ansi.c + + diff --git a/RobotChase/ansi.c b/RobotChase/ansi.c new file mode 100644 index 0000000..5d17856 --- /dev/null +++ b/RobotChase/ansi.c @@ -0,0 +1,14 @@ +#include +#include "ansi.h" + +void clrscr() { + printf("\033[2J\033[1;1H"); +} + +void clrline() { + printf("\033[1K"); +} + +void gotoxy(int x, int y) { + printf("\033[%d;%dH", y, x); +} \ No newline at end of file diff --git a/RobotChase/ansi.h b/RobotChase/ansi.h new file mode 100644 index 0000000..c300361 --- /dev/null +++ b/RobotChase/ansi.h @@ -0,0 +1,8 @@ +#ifndef __ANSI_H__ +#define __ANSI_H__ + +extern void clrscr(); +extern void clrline(); +extern void gotoxy(int x, int y); + +#endif \ No newline at end of file diff --git a/RobotChase/chase.c b/RobotChase/chase.c new file mode 100644 index 0000000..16d78be --- /dev/null +++ b/RobotChase/chase.c @@ -0,0 +1,403 @@ +#include +#include +#include +#include + +#include "ansi.h" + +#define BOARD_WIDTH 40 +#define BOARD_HEIGHT 20 +#define BOT_COUNT 10 + +char board[BOARD_HEIGHT][BOARD_WIDTH]; +int posX, posY; +int robotX[BOT_COUNT]; +int robotY[BOT_COUNT]; +unsigned int robotCount; +short seed; +unsigned char color = 0; + +void displayStatus(char *text) { + gotoxy(5, 22); + clrline(); + printf("%s", text); +} + +void drawBoard() { + int i; + int j; + + for (i=0;i 0) { + newX = robotX[i]-1; + } else if (robotX[i] - posX < 0) { + newX = robotX[i]+ 1; + } else { + newX = robotX[i]; + } + + if (robotY[i] - posY > 0) { + newY = robotY[i]-1; + } else if (robotY[i] - posY < 0) { + newY = robotY[i]+ 1; + } else { + newY = robotY[i]; + } + + if (board[newY][newX] == 'X') { + robotCount--; + gotoxy(robotX[i] + 5, robotY[i] + 1); + printf(" "); + board[robotY[i]][robotX[i]] = ' '; + robotY[i] = -1; + robotX[i] = -1; + } else if (board[newY][newX] == '+') { + // destroy both robots; + for (j=0;j