/* PROGRAM : BALLS.C AUTHOR : Jay Vaughan DATE : 4 November 1991 DESCRIPTION : Simple graphics game for the Atari Portfolio, using the GRLIB functions I developed for my Portfolio. NOTE : See README.DOC for more information. Copyright (C) 1991, 1992 Jay Vaughan */ #include #include #include #include #include "grlib.h" #include "keyb.h" #include "gchar.h" #define FIELDWIDTH 239 #define FIELDDEPTH 63 #define SCOREX 60 #define SCOREY 28 #define MAXLOOPS 20 #define MAXBALLS 15 #define ON 1 #define OFF 0 #define DOWN 1 #define BOTTOM 63 #define TOP 0 #define LEFT 0 #define RIGHT 239 int score, oscore=0; /* Current score, last score */ int cb=0; /* Current ball */ int numb=0; /* Number of balls currently on the screen */ int loops=0; /* Number of loops */ int savecol; int catch_y=60; /* Catchers Y position */ int catch_x=50; /* Catchers X position */ int oldcatch_x=20; /* Catchers old X position */ int NUMBALLS=11; struct balldef { int xpos, ypos; /* The balls location on the field */ int oypos; /* The balls old y_pos */ int oxpos; /* The balls old x_pos */ int xdir; /* The direction of the ball */ int ydir; /* The direction of the ball */ int velocity; /* Velocity of the ball */ int currv; /* Speed counter */ int on; /* Boolean, 0=off 1=on */ }; struct balldef ball[MAXBALLS]; idelay(long time) { int n; for (n=0;n<=time;n++); } initb(i) int i; { ball[i].on=0; ball[i].xpos=0; ball[i].ypos=0; ball[i].velocity=ball[i].currv=1+random(3); } initbs() { int i; for (i=0;i=BOTTOM-2) { ball[cb].ydir*=-1; ball[cb].ypos=BOTTOM-2; } if (ball[cb].ypos<=TOP+2) { ball[cb].ydir*=-1; ball[cb].ypos=TOP+2; } if (ball[cb].xpos>=RIGHT-2) { ball[cb].xdir*=-1; ball[cb].xpos=RIGHT-2; } if (ball[cb].xpos<=LEFT+2) { ball[cb].xdir*=-1; ball[cb].xpos=LEFT+2; } /* { plotballoff(cb); initb(cb); } */ } } play() { while(NUMBALLS!=0) { if(keystate()&RSHIFT) { NUMBALLS=(NUMBALLS=NUMBALLS) numb=0; if (loops>MAXLOOPS) loops=0; else loops++; } } main() { init(); color=ON; play(); deinit(); }