home *** CD-ROM | disk | FTP | other *** search
- /* BOB Demo
- ** --------
- ** Blits a Worm to screen using a BOB structure. This version does not include
- ** the sound from the asm version.
- **
- */
-
- #include <proto/games.h>
- #include <proto/exec.h>
-
- struct GMSBase *GMSBase;
- extern struct ExecBase *SysBase;
-
- struct GameScreen *GameScreen;
- struct RestoreList *RestoreList;
- struct Picture *PIC_Bobs;
-
- #define AMT_PLANES 5
- #define TRUE 1
- #define FALSE 0
-
- struct Picture PIC_Background = {
- PCV1, /* Version header */
- 0, /* Source data */
- 320,0,256, /* Width, Height */
- AMT_PLANES, /* Amount of Planes */
- 0, /* Amount of colours */
- 0, /* Source palette */
- LORES|COL12BIT, /* Screen mode */
- ILBM, /* Destination */
- GETPALETTE, /* Parameters */
- "GAMESLIB:data/IFF.Pic320"
- };
-
- WORD FrameList[] = {
- 0,0,0,0,
- 32,0,0,0,
- 64,0,0,0,
- 96,0,0,0,
- 128,0,0,0,
- 160,0,0,0,
- 192,0,0,0,
- 224,0,0,0,
- 256,0,0,0,
- 288,0,0,0,
- 0,48,0,0,
- 32,48,0,0,
- 64,48,0,0,
- -1
- };
-
- struct BOB BOB_Rambo = {
- BBV1, /* Structure version */
- 0,0, /* Graphics & Mask data */
- 0, /* Current frame */
- FrameList, /* Pointer to frame list */
- 0, /* Page Width */
- 32,32/8,24, /* Width, Width in bytes, Height */
- 150,150, /* X/Y destination */
- 0,0, /* Border restriction LeftX/8, TopY */
- 0,0, /* Border restrictions RightX/8, EndY */
- 0,0, /* Amount of planes */
- 0, /* Size of plane, not required */
- RESTORE|GENMASKS|CLIP, /* Attributes */
- 0 /* Picture struct (Bob origin) */
- };
-
- void Demo(void);
-
- /*=========================================================================*/
-
- void main(void)
- {
- if (GMSBase = (struct GMSBase *) OpenLibrary("games.library",0))
- {
- SetUserPrefs(0);
- if (AllocBlitter() == ERR_OK)
- {
- if (AllocAudio() == ERR_OK)
- {
- if (GameScreen = AddScreenTags(TAGS,NULL,
- GSA_Planes,AMT_PLANES,
- GSA_ScrMode,LORES|COL12BIT,
- GSA_ScrWidth,320,
- GSA_ScrHeight,256,
- GSA_ScrType,ILBM,
- GSA_Attrib,DBLBUFFER,
- TAGEND))
- {
- PIC_Background.Data = GameScreen->MemPtr2;
- if (LoadPic(&PIC_Background) == ERR_OK)
- {
- GameScreen->Palette = PIC_Background.Palette;
- UpdatePalette(GameScreen);
- SwapBuffers(GameScreen);
- CopyBuffer(GameScreen,BUFFER1,BUFFER2);
- if (RestoreList = InitRestore(2,1))
- {
- if (PIC_Bobs = LoadPicTags(TAGS,NULL,
- PCA_Planes,AMT_PLANES,
- PCA_ScrType,ILBM,
- PCA_Options,VIDEOMEM,
- PCA_File,"GAMESLIB:data/IFF.Rambo",
- TAGEND))
- {
- BOB_Rambo.Picture = PIC_Bobs;
- if (InitBOB(GameScreen,&BOB_Rambo) == ERR_OK)
- {
- ShowScreen(GameScreen);
- Demo();
- FreeBOB(&BOB_Rambo);
- }
- FreePic(PIC_Bobs);
- }
- FreeRestore(RestoreList);
- }
- FreePic(&PIC_Background);
- }
- DeleteScreen(GameScreen);
- }
- FreeAudio();
- }
- FreeBlitter();
- }
- CloseLibrary((struct Library *)GMSBase);
- }
- }
-
- /*=========================================================================*/
-
- void Demo(void)
- {
- ULONG mouse=0;
- UWORD anim=0,fire=FALSE;
-
- InitJoyPorts();
-
- do
- {
- Restore(GameScreen,RestoreList);
- DrawBOB(GameScreen,&BOB_Rambo,RestoreList,BUFFER2);
- WaitSVBL();
- SwapBuffers(GameScreen);
-
- /* Animate the Worm's movements */
-
- anim++;
-
- if (fire == FALSE) {
- if (anim > 5) {
- anim = 0;
- BOB_Rambo.Frame++;
- if (BOB_Rambo.Frame > 9)
- BOB_Rambo.Frame = 0;
- }
- }
- else if (anim > 1) {
- anim = 0;
- if (BOB_Rambo.Frame < 10)
- BOB_Rambo.Frame = 9;
-
- BOB_Rambo.Frame++;
-
- if (BOB_Rambo.Frame > 12) {
- if (mouse & MB_LMB)
- BOB_Rambo.Frame = 11;
- else {
- BOB_Rambo.Frame = 0;
- fire = FALSE;
- }
- }
- }
-
- /* Get the user input */
-
- mouse = ReadJoyPort(JPORT1,JT_ZBXY);
- BOB_Rambo.XCoord += GetX(mouse);
- BOB_Rambo.YCoord += GetY(mouse);
- if (mouse & MB_LMB)
- fire = TRUE;
-
- } while (!(mouse & MB_RMB));
- }
-
- /*=========================================================================*/
-