home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 4: Demo 1 / almathera_demo1.bin / amos / cityeditor.amos / cityeditor.amosSourceCode < prev    next >
AMOS Source Code  |  1995-03-16  |  6KB  |  250 lines

  1. 'MAPREAD["map.1"]
  2. Def Scroll 1,0,0 To 320,256,-16,0
  3. Def Scroll 2,0,0 To 320,256,0,16
  4. Def Scroll 3,0,0 To 320,256,16,0
  5. Def Scroll 4,0,0 To 320,256,0,-16
  6. ' Open first screen for original picture 
  7. '
  8. Screen Open 1,320,256,16,Lowres
  9. Flash Off 
  10. Curs Off 
  11. '
  12. If Length(6)=0
  13.    Load Iff "city.iff",1
  14.    If Length(2)=0
  15.       Gosub _READICONS
  16.    End If 
  17.    Spack 1 To 6
  18. Else 
  19.    If Length(2)=0
  20.       Gosub _READICONS
  21.    End If 
  22.    Get Icon Palette 
  23.    Make Icon Mask 
  24.    Unpack 6
  25. End If 
  26. If Length(5)=0
  27.    Reserve As Data 5,32768
  28.    F$=Fsel$("*.Abk","","Please select a map file to load")
  29.    If F$=""
  30.       For N=0 To 32767 Step 2
  31.          Doke Start(5)+N,109+Rnd(1)*15+Rnd(2)
  32.       Next 
  33.    End If 
  34. End If 
  35. Double Buffer 
  36. Bob Update Off 
  37. '
  38. ' Create screen for drawing on 
  39. '
  40. Screen Open 2,320,256,16,Lowres
  41. Flash Off 
  42. Curs Off 
  43. Get Icon Palette 
  44. Cls 0
  45. Proc DISPLAY[0,19,0,15]
  46. Autoback 0
  47. '
  48. Screen To Front 2
  49. '
  50. XX=0 : YY=0
  51. INUM=44 : Rem water
  52. Limit Mouse 
  53. Do 
  54.    Repeat 
  55.       M=Mouse Key
  56.       K$=Inkey$
  57.    Until M<>0 or(K$<>"")
  58.    If K$<>""
  59.       If K$="f"
  60.          Locate 10,10
  61.          Print Border$("Please wait",1)
  62.          For N=0 To 32767 Step 2
  63.             Doke Start(5)+N,109+Rnd(1)*15+Rnd(2)
  64.          Next 
  65.          Proc DISPLAY[0,19,0,15]
  66.       End If 
  67.       A=Asc(K$)
  68.       DX=(A=29 and XX>0)-(A=28 and XX<108)
  69.       DY=(A=30 and YY>0)-(A=31 and YY<108)
  70.       SCROL=-(DX=1)-2*(DY=-1)-3*(DX=-1)-4*(DY=1)
  71.       XX=XX+DX : YY=YY+DY
  72.       Locate 10,10
  73.       If SCROL
  74.          Scroll SCROL
  75.          Proc DISPLAY[-19*(SCROL=1),-19*(SCROL<>3),-15*(SCROL=4),-15*(SCROL<>2)]
  76.       End If 
  77.    Else 
  78.       X=X Screen(X Mouse)/16
  79.       Y=Y Screen(Y Mouse)/16
  80.       Locate 2,2
  81.       If M>=2
  82.          ' display screen 1 
  83.          SCR=1
  84.          Screen To Front 1
  85.       Else 
  86.          If SCR=2
  87.             ' draw icon, update data area
  88.             Doke Start(5)+(X+XX)*2+(Y+YY)*256,INUM
  89.             Paste Icon X*16,Y*16,INUM
  90.          Else 
  91.             ' choose icon, change inum, revert to screen 2 
  92.             While Mouse Key
  93.             Wend 
  94.             INUM=X*15+Y+1
  95.             Screen To Front 2
  96.             SCR=2
  97.          End If 
  98.       End If 
  99.    End If 
  100.    Screen Swap 
  101. Loop 
  102. '
  103. '
  104. Procedure DISPLAY[X1,X2,Y1,Y2]
  105.    Shared XX,YY
  106.    Screen 2
  107.    For I=X1 To X2
  108.       For J=Y1 To Y2
  109.          S=Deek(Start(5)+(I+XX)*2+(J+YY)*256)
  110.          If S
  111.             Paste Icon I*16,J*16,S
  112.          Else 
  113.             Ink 0
  114.             Bar I*16,J*16 To I*16+15,J*16+15
  115.          End If 
  116.       Next 
  117.    Next 
  118. End Proc
  119. '
  120. _READICONS:
  121. For J=0 To 14
  122.    For I=0 To 19
  123.       Get Icon 1,I*15+J+1,I*16,J*16 To I*16+16,J*16+16
  124.    Next 
  125. Next 
  126. Return 
  127. '
  128. Procedure MAPREAD[M$]
  129.    Load Iff M$,5
  130.    For I=0 To 127
  131.       For J=0 To 127
  132.          On Point(I,J) Goto TILE,GROUND,GRASS,WATER,DAMTILE,DARKWALL
  133.          If Point(I+1,J)=0
  134.             If Point(I,J+1)=0
  135.                P=157
  136.             Else 
  137.                P=156
  138.             End If 
  139.          Else 
  140.             If Point(I,J+1)=0
  141.                P=142
  142.             Else 
  143.                P=141
  144.             End If 
  145.          End If 
  146.          Goto SKIP
  147.          TILE:
  148.          If Point(I,J+1)=0 or Point(I,J+1)=6
  149.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  150.                If Point(I-1,J)=0 or Point(I-1,J)=6
  151.                   P=9
  152.                Else 
  153.                   P=22
  154.                End If 
  155.             Else 
  156.                P=8
  157.             End If 
  158.          Else 
  159.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  160.                If Point(I-1,J)=0 or Point(I-1,J)=6
  161.                   P=7
  162.                Else 
  163.                   P=23
  164.                End If 
  165.             Else 
  166.                If Point(I-1,J)=0 or Point(I-1,J)=6
  167.                   P=24
  168.                Else 
  169.                   P=245
  170.                End If 
  171.             End If 
  172.          End If 
  173.          Goto SKIP
  174.          GROUND:
  175.          If Point(I,J+1)=0 or Point(I,J+1)=6
  176.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  177.                If Point(I-1,J)=0 or Point(I-1,J)=6
  178.                   P=6
  179.                Else 
  180.                   P=19
  181.                End If 
  182.             Else 
  183.                P=5
  184.             End If 
  185.          Else 
  186.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  187.                If Point(I-1,J)=0 or Point(I-1,J)=6
  188.                   P=4
  189.                Else 
  190.                   P=20
  191.                End If 
  192.             Else 
  193.                If Point(I-1,J)=0 or Point(I-1,J)=6
  194.                   P=21
  195.                Else 
  196.                   P=39+15*Rnd(2)
  197.                End If 
  198.             End If 
  199.          End If 
  200.          Goto SKIP
  201.          GRASS:
  202.          If Point(I,J+1)=0 or Point(I,J+1)=6
  203.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  204.                P=16
  205.             Else 
  206.                P=2
  207.             End If 
  208.          Else 
  209.             If Point(I-1,J+1)=0 or Point(I-1,J+1)=6
  210.                If Point(I-1,J)=0 or Point(I-1,J)=6
  211.                   P=1
  212.                Else 
  213.                   P=17
  214.                End If 
  215.             Else 
  216.                If Point(I-1,J)=0 or Point(I-1,J)=6
  217.                   P=18
  218.                Else 
  219.                   P=109+Rnd(2)+Rnd(1)*15
  220.                End If 
  221.             End If 
  222.          End If 
  223.          Goto SKIP
  224.          WATER:
  225.          P=79+Rnd(1)+Rnd(1)*15
  226.          Goto SKIP
  227.          DAMTILE:
  228.          P=236
  229.          Goto SKIP
  230.          DARKWALL:
  231.          If Point(I+1,J)=6
  232.             If Point(I,J+1)=6
  233.                P=155
  234.             Else 
  235.                P=154
  236.             End If 
  237.          Else 
  238.             If Point(I,J+1)=6
  239.                P=140
  240.             Else 
  241.                P=139
  242.             End If 
  243.          End If 
  244.          SKIP:
  245.          Doke Start(5)+I*2+J*256,P
  246.       Next 
  247.    Next 
  248.    Screen Close 5
  249. End Proc
  250. '