home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / spx10.zip / SPX_DOC.ZIP / SPX_GEO.DOC < prev    next >
Text File  |  1993-05-05  |  6KB  |  187 lines

  1. { SPX Library Version 1.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_GEO is the geomorph "tile map" handling unit.  It allows you to
  4. scroll large maps.  The maps are composed of sprites that are aligned
  5. next to each other like a tile floor.
  6.  
  7. See DEMO4.PAS for an example
  8.  
  9. ───────────────────────────────────────────────────────────────────────────
  10. type
  11.   Pmorph = ^Tmorph;
  12.   Tmorph = object
  13.  
  14.  
  15. VARIABLES:
  16.      gosx,gofsy:byte:   Used internally.  Indicates the pixel offset of
  17.                         the map;
  18.      ts:byte:           Used internally.  Indicates the sprite size of
  19.                         the tiles in shifted bits. ie.
  20.  
  21.                                4x4 tile  ts=2
  22.                                8x8 tile  ts=3
  23.                              16x16 tile  ts=4
  24.                              32x32 tile  ts=5
  25.      gv_width:          Width of sprites to display. (in tiles amount);
  26.      gv_height:         Height of sprites to display. (in tiles);
  27.      gmx,gmy:           Width and height of geomorph (in tiles);
  28.      gsx,gsy:           Width and height of tile (in pixels);
  29.      hvx,hvy:           Used internally; = gv_width div 2,gv_height div 2;
  30.      smapx,smapy:       Top-left corner region of geomorph;
  31.  
  32.   ---------------------------------------------------
  33.   constructor Tmorph.init(geomx,geomy,gvw,gvh,scrx,scry:integer);
  34.  
  35.      Sets up the object.
  36.  
  37.      GEOMX:     Width of geomorph (in tiles);
  38.      GEOMY:     Height of geomorph (in tiles);
  39.      GVW:       Width of tiles to display (in tiles);
  40.      GVH:       Height of tiles to display (in tiles);
  41.      SCRX,SCRY: Top-left corner region of geommorph
  42.  
  43.   ---------------------------------------------------
  44.   destructor Tmorph.done; virtual;
  45.  
  46.   Deallocates the object
  47.  
  48.   ---------------------------------------------------
  49.   function Tmorph.geomap(x,y:integer):integer;virtual;
  50.  
  51.   Returns the tile number at the (X,Y) coordinate.
  52.  
  53.     X,Y:  Tile positon of geomorph (in tiles)
  54.  
  55.   OVERRIDE: Always
  56.  
  57.   ---------------------------------------------------
  58.   procedure Tmorph.drawmap(vx,vy:integer);virtual;
  59.  
  60.   Displays the geomorph on the active page.
  61.  
  62.     VX,VY:  Center position area of geomorph to display.
  63.             (in pixels)
  64.  
  65.             VX is usually in the range 0..geomorph_width*sprite_width-1
  66.             VY is usually in the range 0..geomorph_height*sprite_height-1
  67.  
  68.     NOTES:  To use, geomorh tiles width and height must be the same, and
  69.     must be: 4x4, 8x8, 16x16, 32x32 etc.
  70.  
  71.     Change the variable (ts) to reflect sprite size
  72.  
  73.        4x4 tile    ts=2
  74.        8x8 tile    ts=3
  75.        16x16 tile  ts=4
  76.        32x32 tile  ts=5
  77.  
  78.   ---------------------------------------------------
  79.   procedure Tmorph.drawmap_wd(vx,vy:integer);virtual;
  80.  
  81.   Same as Tmorph.drawmap. Displays the geomorph on the active page.  Faster
  82.   calcuations than Tmorph.drawmap
  83.  
  84.   VX,VY:  Center position area of geomorph to display.
  85.             (in pixels)
  86.  
  87.             VX is usually in the range 0..geomorph_width*sprite_width-1
  88.             VY is usually in the range 0..geomorph_height*sprite_height-1
  89.  
  90.   NOTES:  To use, geomorh tiles width and height must be the same, and
  91.     must be: 4x4, 8x8, 16x16, 32x32 etc.
  92.  
  93.     change the variable (ts) to reflect sprite size
  94.  
  95.        4x4 tile    ts=2
  96.        8x8 tile    ts=3
  97.        16x16 tile  ts=4
  98.        32x32 tile  ts=5
  99.  
  100.   ---------------------------------------------------
  101.   procedure Tmorph.drawmap_n16(vx,vy:integer);virtual;
  102.  
  103.   Same as drawmap. Displays the geomorph on the active page
  104.  
  105.   VX,VY:  Center position area of geomorph to display.
  106.             (in pixels)
  107.  
  108.             VX is usually in the range 0..geomorph_width*sprite_width-1
  109.             VY is usually in the range 0..geomorph_height*sprite_height-1
  110.  
  111.   Tiles width and height can be any size
  112.  
  113.     Change the variables (gsx),(gsy) to the tile's width and height.
  114.  
  115.   ---------------------------------------------------
  116.   procedure Tmorph.placegeo(x,y,geonum:integer);virtual;
  117.  
  118.   Called from Tmorph.drawmap/drawmap_n16.  Displays a tile on the screen.
  119.  
  120.     X,Y:     Top-left position of tile to display;
  121.     GEONUM:  Tile number to display
  122.  
  123.   OVERRIDE: Often
  124.  
  125.   Usually your override procedure would look something like:
  126.  
  127.     procedure TMyMorph.placegeo(x,y,geonum);
  128.     begin
  129.       fput(x,y,geo_tiles[geonum]^);
  130.     end;
  131.  
  132.   ---------------------------------------------------
  133.   procedure Tmorph.placegeo_wd(nd:word;geonum:integer);virtual;
  134.  
  135.   Called from Tmorph.drawmap_wd.  Displays tile on the screen.
  136.  
  137.     ND:      Offset of the top-left position of tile to display;
  138.     GEONUM:  Tile number to display
  139.  
  140.   OVERRIDE: Often
  141.   ---------------------------------------------------
  142.   procedure Tmorph.nogogeo_wd(nd:word);virtual;
  143.  
  144.   Called from Tmorph.drawmap_wd.  Is called when a tile is
  145.   out of range.
  146.  
  147.   ---------------------------------------------------
  148.   procedure Tmorph.nogogeo(x,y:integer);virtual;
  149.  
  150.   Called from Tmorph.drawmap/drawmap_n16.  Is called when a tile is
  151.   out of range.
  152.  
  153.   ---------------------------------------------------
  154.   procedure Tmorph.pre_map; virtual;
  155.  
  156.   Called before each drawing of the geomorph.
  157.  
  158.   ---------------------------------------------------
  159.   procedure Tmorph.post_map; virtual;
  160.  
  161.   Called after each drawing of the geomorph.
  162.  
  163. ───────────────────────────────────────────────────────────────────────────
  164. function loadGMP(f:string;var piclist,map):integer;
  165.  
  166.   Load a .GMP file from disk.
  167.  
  168.   F:        DOS file name of GMP file to load;
  169.   PICLIST:  Array of pointer to hold the tiles;
  170.   MAP:      Array of byte or word to hold the map
  171.  
  172.   Returns the number of tiles in the GMP file.
  173.  
  174.   The example below loads a 100,100 GMP file:
  175.  
  176.   const
  177.     gmx  = 100;
  178.     gmy  = 100;
  179.  
  180.   var
  181.     geo_tiles : array[1..100] of pointer;
  182.     MyMap     : array[0..gmy-1,0..gmx-1] of byte;
  183.     geos      : integer;
  184.  
  185.   begin
  186.     geos := LoadGMP('MyGMP.GMP',geo_tiles,MyMap);
  187.   end;