home *** CD-ROM | disk | FTP | other *** search
-
- /* Line Bounce
- ** -----------
- ** Line bouncing demo that works on a screen of any type of dimensions as
- ** specified by the user in GMSPrefs.
- **
- */
-
- #include <proto/games.h>
- #include <proto/exec.h>
-
- #define AMT_PLANES 1
-
- struct GMSBase *GMSBase;
- extern struct ExecBase *SysBase;
-
- UWORD Palette[] =
- {
- 0x0000,0x08ff
- };
-
- struct GameScreen GameScreen = {
- GSV1,
- 0,0,0, /* Screen Memory 1,2,3 */
- 0, /* ScreenLink */
- Palette, /* Address of palette */
- 0, /* Address of rasterlist */
- 2, /* Amount of colours in palette */
- 0,0, /* Screen Width and Height */
- 0,0,0, /* Picture Widths and Height */
- AMT_PLANES, /* Amount of Planes */
- 0,0, /* X/Y screen offset */
- 0,0, /* X/Y picture offset */
- DBLBUFFER, /* Special attributes */
- LORES|COL12BIT, /* Screen mode */
- 0, /* Screen type */
- };
-
- struct GameScreen *OurScreen = &GameScreen;
-
- /*=========================================================================*/
-
- void main(void)
- {
- ULONG mousestat;
- int sx,sy,ex,ey,dsx,dsy,dex,dey;
-
- if (GMSBase = (struct GMSBase *) OpenLibrary("games.library",0))
- {
- SetUserPrefs(0);
- if (AllocBlitter() == NULL)
- {
- if (AddScreen(OurScreen) == NULL)
- {
- sx = SlowRandom(OurScreen->ScrWidth); dsx = -1;
- sy = SlowRandom(OurScreen->ScrHeight); dsy = 2;
- ex = SlowRandom(OurScreen->ScrWidth); dex = 3;
- ey = SlowRandom(OurScreen->ScrHeight); dey = 1;
-
- ShowScreen(OurScreen);
-
- do
- {
- ClrScreen(OurScreen,BUFFER2);
- mousestat = ReadMouse(JPORT1);
- sx += dsx;
- sy += dsy;
- ex += dex;
- ey += dey;
-
- if(sx<0) { sx = 0; dsx = -(dsx); }
- if(sy<0) { sy = 0; dsy = -(dsy); }
- if(ex<0) { ex = 0; dex = -(dex); }
- if(ey<0) { ey = 0; dey = -(dey); }
-
- if(sx>OurScreen->ScrWidth-1) {
- sx = OurScreen->ScrWidth-1;
- dsx = -(dsx);
- }
-
- if(sy>OurScreen->ScrHeight-1) {
- sy = OurScreen->ScrHeight-1;
- dsy = -(dsy);
- }
-
- if(ex>OurScreen->ScrWidth-1) {
- ex = OurScreen->ScrWidth-1;
- dex = -(dex);
- }
-
- if(ey>OurScreen->ScrHeight-1) {
- ey = OurScreen->ScrHeight-1;
- dey = -(dey);
- }
-
- DrawUCLine(OurScreen,BUFFER2,sx,sy,ex,ey,1);
- WaitSVBL();
- SwapBuffers(OurScreen);
- } while (!(mousestat & MB_LMB));
-
- DeleteScreen(OurScreen);
- }
- FreeBlitter();
- }
- CloseLibrary((struct Library *)GMSBase);
- }
- }
-
-