bob@imspw6.UUCP (Bob Burch) (10/10/88)
From Ted Holden at HTE:
It appears to me as if Zortech C++, TurboC, and most of the packages
designed to work with TurboC might be used in a mix-match kind of way.
MicroSoft, of course, includes all kinds of quirks in their compilers
and obj formats to prevent such things being done with their products.
In particular, the TurboC version of the MetaGraphics package links
straight into Zortech C++ as if totally designed for it i.e. everybody
simply did everything by the book and, by the grace of God, it works.
MetaWindow (the TurboC version available from Programmers' Connection
for something like $75), is the fastest and best of the DOS graphics
packages by a goodly margin.
The following (simple-minded) sample of code is totally sufficient
to move varying numbers of circles and squares around on an EGA screen
as quickly as one might wish, simultaneously; in fact, one will notice
that I'm using timing loops to slow it down for human viewers. A
quick perusal of this code should serve as proof positive that anybody
writing games in anything other than Zortech C++ from now on would
have to be crazy.
....................................................................
....................................................................
#include <string.h>
#include <stdio.h>
#include <stream.hpp>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "c:\tc\mw\GRconst.h"
#include "c:\tc\mw\GRports.h"
#include "c:\tc\mw\GRextrn.h"
#include <process.h>
#include <conio.h>
int i,j,k,l,ii,jj,kk,ll;
int xa,ya, x,y, ox,oy, h,h0, penColr,maxColr;
int xx, yy, zz;
int GrafixCard,CommPort;
rect scrnR,vR;
char c1,c2,c3;
int pxtbits, pxtplanes, pxtwidth, pxtheight, pxtrwbytes;
int pxbbits, pxbplanes, pxbwidth, pxbheight, pxbrwbytes;
int pxslrbits, pxslrplanes, pxslrwidth, pxslrheight, pxslrrwbytes;
int pxsudbits, pxsudplanes, pxsudwidth, pxsudheight, pxsudrwbytes;
metaPort *theport; /* pointer to default MetaWINDOW port */
bitmap *thebmap; /* pointer to default MetaWINDOW bitmap */
char *p2rowtable[350];
long p2ptr;
rect srec, drec;
rect uurec, ddrec, llrec, rrrec;
FILE *outf;
int icolor = 1;
int ipage = 0;
int xstroke = 15;
int ystroke = 15;
char *rfont1;
void OpenWindow (rect *,char *);
void CloseWindow (rect *);
void SetRect(rect *, int, int, int, int);
void FrameOval(rect *);
void PenMode(int);
class grobj
{
protected:
rect rr;
int x,y;
public:
grobj(int xx, int yy)
{
PenMode(2);
x = xx; y = yy;
SetRect(&rr,xx,yy,xx+20,yy+20);
}
grobj(grobj & othergro)
{
PenMode(2);
x = othergro.x; y = othergro.y;
SetRect(&rr,x,y,x+20,y+20);
}
virtual void goup() {}
virtual void godown() {}
virtual void goleft() {}
virtual void goright() {}
};
class ball : public grobj
{
public:
ball(int xx, int yy) : (xx, yy)
{
FrameOval(&rr);
}
ball( ball & otherball) : (otherball.x, otherball.y)
{
rr = otherball.rr;
FrameOval(&rr);
}
void goup()
{
if(y > 20)
{
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
y--;
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
}
}
void godown()
{
if(y < 320)
{
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
y++;
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
}
}
void goleft()
{
if( x > 20)
{
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
x--;
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
}
}
void goright()
{
if(x < 620)
{
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
x++;
SetRect(&rr,x,y,x+20,y+20);FrameOval(&rr);
}
}
}; // end subclass ball
class rectg : public grobj
{
public:
rectg(int xx, int yy) : (xx, yy)
{
FrameRect(&rr);
}
rectg( rectg & otherectg) : (otherectg.x, otherectg.y)
{
rr = otherectg.rr;
FrameRect(&rr);
}
void goup()
{
if(y > 20)
{
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
y--;
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
}
}
void godown()
{
if(y < 320)
{
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
y++;
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
}
}
void goleft()
{
if( x > 20)
{
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
x--;
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
}
}
void goright()
{
if(x < 620)
{
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
x++;
SetRect(&rr,x,y,x+20,y+20);FrameRect(&rr);
}
}
}; // end subclass rectg
void main(argc, argv)
int argc;
char *argv[];
{
GrQuery(argc,argv); /* execution begins */
i = InitGrafix(-GrafixCard);
if(i == -1)
{
printf("\nERROR - MetaWINDOW Graphics Driver not installed!\n");
exit(1);
}
if(i == -2)
{
printf("\nERROR 2 from InitGrafix: - Undefined DEVMODE Specification");
printf("\nDevice %d is not supported in this MetaWINDOW version.\n",GrafixCard);
exit(1);
}
GetPort(&theport);
thebmap = theport->portBMap;
x = y = zz = 0;
ScreenRect(&scrnR); EraseRect(&scrnR); SetDisplay(GrafPg0);
PenMode(2);
grobj* obj1;
ball aaz(100, 100), bbz(150, 100);
rectg ccz(200,100);
for(i=0;i<55;i++){obj1 = &aaz;obj1->goright();
obj1 = &bbz;obj1->goright();
obj1 = &ccz;obj1->goright();
for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<55;i++){obj1 = &aaz;obj1->godown();
obj1 = &bbz;obj1->godown();
obj1 = &ccz;obj1->godown();
for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<55;i++){obj1 = &aaz;obj1->goleft();
obj1 = &bbz;obj1->goleft();
obj1 = &ccz;obj1->goleft();
for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<55;i++){obj1 = &aaz;obj1->goup();
obj1 = &bbz;obj1->goup();
obj1 = &ccz;obj1->goup();
for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<200;i++){obj1=&ccz;obj1->goright();for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<200;i++){obj1 = &bbz;obj1->godown();for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<110;i++){obj1 = &bbz;obj1->goleft();for(ii=0;ii<2000;ii++)j=2+2;}
for(i=0;i<55;i++)
{
obj1 = &aaz;obj1->goright();
obj1 = &bbz;obj1->goup();
obj1 = &ccz;obj1->godown();
for(ii=0;ii<2000;ii++)j=2+2;}
}
#include "grquery.c"