Skip to content

Instantly share code, notes, and snippets.

@andrewrcollins
Created January 6, 2012 02:34
Show Gist options
  • Save andrewrcollins/1568661 to your computer and use it in GitHub Desktop.
Save andrewrcollins/1568661 to your computer and use it in GitHub Desktop.
#TJHSST ~ Survive! ~ A Sea Full Of Danger And Oceans Of Fun!
/* Survive */
#include <stdio.h>
#include <stdlib.h>
#include "conio.h"
/* The playing grid is OCEANXxOCEANY. */
#define OCEANX 13
#define OCEANY 12
/* These are the types of landforms there are in the game. */
#define OPENSEA 0
#define BEACH 1
#define FOREST 2
#define MOUNTAIN 3
/* SAFETY and REEF are catch-alls for the hexagons which
have special meanings. */
#define SAFETY 4
#define REEF 5
/* The actual playing grid is not symetrical, to make up for
this some loose ends need to be taken care of. Later... */
#define EDGE 6
/* START is where Sea Serpents should be placed at
the beginning of the game. */
#define START 7
/* The structure used to for each hexagon in the grid. */
struct seatype {
int type;
};
/* This is the basic setup of the island, later I'll add
an island editor of some kind so that customized islands
can be created, after I finish this though. */
struct configure {
int x,y,type;
} initial[] =
{ {0,0,SAFETY}, {1,0,SAFETY}, {11,0,SAFETY}, {12,0,SAFETY},
{0,10,SAFETY}, {1,11,SAFETY}, {11,11,SAFETY}, {12,10,SAFETY},
{3,0,REEF}, {9,0,REEF}, {0,1,REEF}, {12,1,REEF}, {0,9,REEF},
{3,11,REEF}, {9,11,REEF}, {12,9,REEF},
{2,0,START}, {11,1,START}, {1,10,START}, {10,10,START}, {6,5,START},
{0,11,EDGE}, {2,11,EDGE}, {4,11,EDGE}, {6,11,EDGE},
{8,11,EDGE}, {10,11,EDGE}, {12,11,EDGE},
{6,3,MOUNTAIN}, {6,4,MOUNTAIN}, {5,5,MOUNTAIN}, {7,5,MOUNTAIN},
{5,6,MOUNTAIN}, {7,6,MOUNTAIN}, {6,6,MOUNTAIN}, {6,7,MOUNTAIN},
{6,2,FOREST}, {5,3,FOREST}, {7,3,FOREST}, {5,4,FOREST}, {7,4,FOREST},
{4,4,FOREST}, {8,4,FOREST}, {4,5,FOREST}, {8,5,FOREST}, {4,6,FOREST},
{8,6,FOREST}, {5,7,FOREST}, {7,7,FOREST}, {5,8,FOREST}, {7,8,FOREST},
{6,8,FOREST},
{5,2,BEACH}, {7,2,BEACH}, {4,3,BEACH}, {8,3,BEACH}, {3,4,BEACH},
{9,4,BEACH}, {3,5,BEACH}, {9,5,BEACH}, {3,6,BEACH}, {9,6,BEACH},
{3,7,BEACH}, {9,7,BEACH}, {4,7,BEACH} ,{8,7,BEACH}, {5,9,BEACH},
{7,9,BEACH}
};
/* The following are messages and pictures found on the back of
the island pieces. */
char *messages[] = {
"Kill a Shark",
"Harpoon\na Whale",
"Whale dives\n to any\nvacant space",
"Shark swims\n to any\nvacant space",
" Sea Serpent\ndives to any\nvacant space",
"Dolphin takes\n one of your\n swimmers\n 3 spaces",
" Move one\nof your boats\n 3 spaces",
"BOAT",
"SHARK",
"WHALE",
"WHIRLPOOL",
"EXPLOSION" };
int main()
{
struct seatype ocean[OCEANY][OCEANX];
setup(ocean);
}
int setup(ocean)
struct seatype ocean[OCEANY][OCEANX];
{
int cnt,cnti;
/* Clear out the ocean. */
for(cnt=0;cnt<OCEANY;cnt++)
for(cnti=0;cnti<OCEANX;cnti++)
ocean[cnt][cnti].type=OPENSEA;
/* Initialize all the spots that need to be initialized. */
for(cnt=0;cnt<(sizeof(initial)/sizeof(struct configure));cnt++)
ocean[initial[cnt].y][initial[cnt].x].type=initial[cnt].type;
/*-=-=-=-=-=-=-= For editting purposes. =-=-=-=-=-=-=-*/
textbackground(BLUE);
clrscr();
for(cnt=0;cnt<OCEANY;cnt++)
for(cnti=0;cnti<OCEANX;cnti++) {
gotoxy(cnti*2+2,cnt*2+!(cnti%2)+2);
switch(ocean[cnt][cnti].type) {
case OPENSEA :
textcolor(LIGHTCYAN);
putch((char)176);
break;
case REEF :
textcolor(CYAN);
putch((char)247);
break;
case START :
textcolor(GREEN);
putch((char)159);
break;
/* I don't care.
case EDGE :
textcolor(DARKGRAY);
putch('X');
break;
*/
case SAFETY :
textcolor(BROWN);
putch('I');
break;
case MOUNTAIN :
textcolor(LIGHTGRAY);
putch((char)219);
break;
case BEACH :
textcolor(YELLOW);
putch((char)177);
break;
case FOREST :
textcolor(LIGHTGREEN);
putch((char)178);
break;
}
}
/*-=-=-=-=-=-=-= For editting purposes. =-=-=-=-=-=-=-*/
}
@andrewrcollins
Copy link
Author

A C program found on an old 5.25 floppy disk from when I was a nerd at Thomas Jefferson High School for Science and Technology between 1988 and 1992.

survive.jpg

Anyone can do whatever they'd like to with this program--if anything.

I remain a "Sea serpent dives to any vacant space"-type nerd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment