home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / E / Sprites / Sprites32.e < prev   
Encoding:
Text File  |  1997-01-10  |  2.6 KB  |  81 lines

  1. /* Sprite example
  2. ** --------------
  3. ** This example shows you how to set up a 16 colour AGA sprite with an
  4. ** X axis of 32 pixels.
  5. ** 
  6. ** The sprite is attached to the mouse, so try moving it around a bit.
  7. */
  8.  
  9. MODULE 'games','games/games','exec/memory'
  10.  
  11. PROC main()
  12.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, sparkie:PTR TO sprite,
  13.        zbxy:LONG, timer:LONG
  14.  
  15.    palette := [
  16.     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
  17.     $0000,$0688,$0466,$0344,$0CC0,$0980,$0870,$0650,
  18.     $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF,
  19.     $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
  20.    ]:INT;
  21.  
  22.    screen  := [
  23.     GSV1,0,              -> GameScreen Version 
  24.     0,0,0,               -> Screen_Mem1,2,3 
  25.     0,                   -> ScreenLink 
  26.     palette,             -> Address of Palette 
  27.     0,                   -> Address of RasterList 
  28.     32,                  -> Amount of colours 
  29.     320,256,             -> Screen Width, Height 
  30.     0,0,0,               -> Picture Width, Height  
  31.     1,                   -> Amt_Planes 
  32.     0,0,                 -> Top Of Screen, X/Y 
  33.     0,0,                 -> X/Y pic offsets 
  34.     SPRITES OR NOSCRBDR, -> Special attributes 
  35.     LORES OR COL12BIT,   -> Screen mode 
  36.     INTERLEAVED          -> Screen type 
  37.    ]:gamescreen;
  38.  
  39.    sparkie := [
  40.     SPV1,0,         -> Version number
  41.     0,              -> Bank Number 0
  42.     0,              -> Ptr to graphic
  43.     100,100,        -> Beginning X/Y positions
  44.     0,              -> Current frame
  45.     32,21,          -> Width, Height
  46.     16,             -> Amt of colours
  47.     16,             -> Colour start in palette
  48.     2,              -> Amt of planes
  49.     HIRES,          -> Resolution attributes
  50.     0,              -> Position in relation to playfields
  51.     0               -> Special attributes.
  52.    ]:sprite;
  53.  
  54.    IF gmsbase := OpenLibrary('games.library',0)
  55.       SetUserPrefs(0)
  56.       IF (AddScreen(screen) = ERR_OK)
  57.          sparkie.data := SmartLoad('GAMESLIB:data/sparkie32.raw',0,MEMF_CHIP)
  58.          InitSprite(screen,sparkie)
  59.          UpdateSprite(screen,sparkie)
  60.          ShowScreen(screen)
  61.          zbxy := ReadMouse(JPORT1)
  62.  
  63.          REPEAT
  64.            IF (timer++ AND $1)
  65.               IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
  66.            ENDIF
  67.            zbxy := ReadMouse(JPORT1)
  68.            sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
  69.            sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
  70.            WaitSVBL()
  71.            UpdateSprite(screen,sparkie)
  72.          UNTIL !(zbxy AND MB_LMB)
  73.  
  74.       FreeMemBlock(sparkie.data);
  75.       DeleteScreen(screen)        
  76.       ENDIF
  77.    CloseLibrary(gmsbase)
  78.    ENDIF
  79. ENDPROC
  80.  
  81.