home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
100-199
/
ff132.lzh
/
Berserk
/
graph.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-03-13
|
1KB
|
78 lines
/* :ts=8 bk=0 */
#include <exec/types.h>
#include <intuition/intuition.h>
extern void *OpenLibrary(), *OpenWindow();
struct NewWindow windef = {
320, 0, 320, 100,
-1, -1,
NULL,
WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH,
NULL, NULL,
(UBYTE *) "Graph output",
NULL, NULL,
0, 0, 0, 0,
WBENCHSCREEN
};
struct Window *win;
void *IntuitionBase, *GfxBase;
main ()
{
register struct RastPort *rp;
float gravity, v1, start, end, step, x, y;
openstuff ();
rp = win -> RPort;
printf ("Enter gravity: ");
scanf ("%f", &gravity);
printf ("Enter initial velocity: ");
scanf ("%f", &v1);
printf ("Enter start and ending X: ");
scanf ("%f %f", &start, &end);
printf ("Enter step rate: ");
scanf ("%f", &step);
for (x=start; x<=end; x+=step) {
y = -gravity * (x*x) + v1*x;
WritePixel (rp, (long) x+20, (long) (97.-y/2.));
}
getchar ();
getchar ();
closestuff ();
}
openstuff ()
{
if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L)))
die ("-=RJ=-'s missing.");
if (!(GfxBase = OpenLibrary ("graphics.library", 0L)))
die ("Dale's missing.");
if (!(win = OpenWindow (&windef)))
die ("Window painted shut.");
}
closestuff ()
{
if (win) CloseWindow (win);
if (GfxBase) CloseLibrary (GfxBase);
if (IntuitionBase) CloseLibrary (IntuitionBase);
}
die (str)
char *str;
{
puts (str);
closestuff ();
exit (20);
}