/* PROGRAM : MISS.C AUTHOR : Jay Vaughan DATE : February 15, 1992 PURPOSE : Classic version of Missile Command for the ATARI Portfolio. NOTES : Uses the GRLIB library to perform graphics functions. VERSION : 1.0 (JAY) - February 15, 1992 - rudimentary version programmed, incomplete. */ /* Header files */ #include #include #include "grlib.h" #include "miss.h" #define RSHIFT 1 #define LSHIFT 2 #define NUMLSPTS 10 /* Number of points in the landscape */ #define NUMCITIES 3 /* Number of cities on the screen */ #define NUMMISL 5 /* Number of missiles on the screen at once */ /* Game variables */ int numshots=3; /* # of shots the user can fire at one time */ int i; /* Used globally as an index variable */ int x1, y1, x2, y2; /* Generic position variables */ int lives=3; /* Number of lives left */ int mislcnt=0; /* The current missile being drawn */ int chspeed=5; /* How fast the cross hair moves */ struct l_s_point l_s[NUMLSPTS] = { {17,54}, {31,53}, {42,55}, {58,51}, {71,53}, {89,56}, {101,52}, {120,57}, {131,51}, {155,53} }; struct cityrec city[NUMCITIES] = { {30,53,CITYSAFE}, {71,53,CITYSAFE}, {120,56,CITYSAFE} }; struct mislrec misl[NUMMISL] = { {15,10,MISLDEAD,SLOW,RIGHT}, {55,10,MISLDEAD,SLOW,STRAIGHT}, {45,10,MISLDEAD,MEDIUM,LEFT}, {35,10,MISLDEAD,FAST,RIGHT}, {30,10,MISLDEAD,SLOW,STRAIGHT} }; struct c_h_rec c_h = {80,27}; struct c_h_rec oc_h; void drawcities() { for (i=0;i48)|| (misl[mislcnt].status==MISLDEAD)) initmisl(mislcnt); else { color=1; dot(misl[mislcnt].x, misl[mislcnt].y); dot(misl[mislcnt].x-misl[mislcnt].dir, misl[mislcnt].y-misl[mislcnt].speed); misl[mislcnt].y+=misl[mislcnt].speed; misl[mislcnt].x+=misl[mislcnt].dir; } mislcnt=mislcnt10?c_h.x:10; c_h.y=c_h.y<47?c_h.y:47; c_h.y=c_h.y>10?c_h.y:10; } void crosshair() { if ((oc_h.x != c_h.x) || (oc_h.y != c_h.y)) { color=0; dot(oc_h.x-1, oc_h.y); dot(oc_h.x+1, oc_h.y); dot(oc_h.x, oc_h.y+1); dot(oc_h.x, oc_h.y-1); oc_h.x=c_h.x; oc_h.y=c_h.y; } color=1; dot(c_h.x-1, c_h.y); dot(c_h.x+1, c_h.y); dot(c_h.x, c_h.y+1); dot(c_h.x, c_h.y-1); } void main() { initplayfield(); while(lives>0) { missile(); keyboard(); crosshair(); } getch(); videomode(TEXT); }