home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / 601-625 / apd621 / harvey's_çollection / kingdom.amos / kingdom.amosSourceCode < prev   
AMOS Source Code  |  1986-08-03  |  8KB  |  283 lines

  1. '**************************
  2. '*                        *
  3. '*          Kingdom       *
  4. '*        -----------     *
  5. '*                        *
  6. '*        Written by      *
  7. '*       Stephen Hill     *  
  8. '*       Programmed by    *  
  9. '*        Harvey Ball     *  
  10. '*                        *
  11. '**************************
  12. Hide On 
  13. Dim D(11,2)
  14. Screen Open 4,320,256,16,Lowres
  15. Curs Off : Hide 
  16. Set Rainbow 0,0,218,"(8,1,8)","(8,1,8)",""
  17. Cls 0 : Paper 0 : Ink 0 : Pen 2 : Rainbow 0,0,30,218 : Locate ,5 : Centre "<[!!FreeWare!!]>" : Locate ,7 : Centre "<Written In Amos.>"
  18. Locate ,9 : Centre "---------"
  19. Pen 3 : Locate ,10 : Centre "Kingdom"
  20. Pen 2 : Locate ,11 : Centre "--------- "
  21. Locate ,20 : Centre "<Press A Key>" : Wave 0 To 15 : NOISE : Wait Key 
  22. Screen Open 0,320,255,4,Lowres
  23. Paper 0 : Curs Off : Cls 0
  24. Screen Display 0,128,70,,
  25. Screen Open 1,330,100,4,Lowres
  26. Paper 0 : Curs Off : Cls 0
  27. Screen Display 1,128,70,,
  28. Screen Open 2,320,100,4,Lowres
  29. Paper 0 : Curs Off : Cls 0
  30. Screen Display 2,128,170,,
  31. Screen Open 3,320,16,4,Lowres
  32. Curs Off : Paper 0 : Cls : Centre "<Kingdom> "
  33. Screen 2
  34. Gosub NEW_GAME
  35. Gosub CHECKIT
  36. Do 
  37. Gosub BUYIT
  38. If BUY=0 Then Gosub SELLIT
  39. Gosub PLANT
  40. Gosub FEED
  41. Gosub TURN
  42. Loop 
  43. NEW_GAME:
  44. A=0 : Cls 0 : Curs On : Locate 0,0 : Input "What is your name?";NAME$ : Print "Welcome to Fantazia,King ";NAME$ : Wait 100 : Cls : Curs Off 
  45. PEOPLE=1000+Rnd(200) : MONEY=PEOPLE*24
  46. SPEOPLE=PEOPLE
  47. GRAIN#=Rnd(1000)+3000 : NGRAIN#=GRAIN# : CROP=0 : SATISFACTION#=1
  48. PLANTED=0 : LOST=0 : FOOD#=0 : DEATH_TOLL=0
  49. YEAR=1 : GAMEOVER=0
  50. SUBSISTANCE=3 : BUY_PRICE=8+Rnd(3) : SELL_PRICE=BUY_PRICE-2
  51. LOST=0 : NEW_PEOPLE#=0 : FOOD_RATION#=0
  52. D(1,1)=PEOPLE : D(1,2)=GRAIN#
  53. Return 
  54. BYE: Pop : Stop 
  55. TURN:
  56. YIELD#=2+(Rnd(3)/10.0)
  57. CROP=PLANTED*YIELD# : LOST=Rnd(CROP/10+1)+CROP/10
  58. If CROP>10000 Then CROP=CROP-Rnd(5000)
  59. ROTTED=Rnd(NGRAIN#/3+1)
  60. GRAIN#=NGRAIN#+CROP-LOST
  61. FOOD_RATION#=FOOD#/PEOPLE
  62. NEW_PEOPLE#=FOOD#/SUBSISTANCE
  63. RAN#=(100+Rnd(4)-2)/100.0
  64. NEW_PEOPLE#=NEW_PEOPLE#*RAN#
  65. GROWTH#=NEW_PEOPLE#-PEOPLE
  66. PEOPLE=NEW_PEOPLE#
  67. BUY_PRICE=7+Rnd(4) : SELL_PRICE=BUY_PRICE-2
  68. If GROWTH#<0 Then STARVED=Abs(GROWTH#) : INFLUX=0 Else STARVED=0
  69. INFLUX=GROWTH#
  70. STATUS:
  71. Screen 0
  72. Curs Off : Cls 0
  73. Locate 0,1 : Print " In year";YEAR;" of King ";NAME$
  74. SATISFACTION#=FOOD_RATION#/SUBSISTANCE
  75. If INFLUX>0
  76. Locate 0,4 : Print INFLUX; : ARRIVED=ARRIVED+INFLUX
  77. Else 
  78. Locate 0,4 : Print " No     ";
  79. End If 
  80. Locate 7,4 : Print " People  entered the city "
  81. Locate 0,5 : Print STARVED; : Locate 7,5 : Print " People  starved"
  82. Locate 0,7 : Print CROP; : Locate 7,7 : Print " Bushels were grown"
  83. Locate 0,8 : Print LOST; : Locate 7,8 : Print " Bushels were eaten by Locusts"
  84. Locate 0,9 : Print ROTTED; : Locate 7,9 : Print " Bushels rotted  in the warehouse "
  85. Locate 0,11 : Print " Thy treasury   hath   ";MONEY;
  86. Locate 30,11 : Print "Bushels"
  87. Locate 0,13 : Print " Thy subjects   number  ";PEOPLE;
  88. Locate 30,13 : Print "Citizens"
  89. Screen To Front 0
  90. Wait 40
  91. Inc YEAR : D(YEAR,1)=PEOPLE : D(YEAR,2)=GRAIN#
  92. NGRAIN#=GRAIN# : PLANTED=0 : FOOD#=0
  93. Locate 0,17 : Clear Key 
  94. DEATH_TOLL=DEATH_TOLL+STARVED
  95. If YEAR<=10
  96. If SATISFACTION#>=1
  97. Print " Prosperity  reigns in Mundania!" : Print "ALL HAIL TO THE GOOD KING ";NAME$
  98. End If 
  99. If SATISFACTION#<1 and SATISFACTION#>0.9
  100. Print " Thy people are hungry!!!"
  101. End If 
  102. If SATISFACTION#<0.9 and SATISFACTION#>0.5
  103. Print " Thy people are starving!!!"
  104. End If 
  105. If SATISFACTION#<0.5
  106. Print 
  107. Print " Thy people are in revolt!!!"
  108. Print " Thy reign of terror ends at year ";YEAR
  109. Print " The bad King ";NAME$;" is DEAD!!"
  110. GAMEOVER=1
  111. End If 
  112. Else 
  113. Print 
  114. If PEOPLE>SPEOPLE and DEATH_TOLL<500
  115. Print " After ten happy years"
  116. Print " Your term of office has expired."
  117. End If 
  118. If DEATH_TOLL<400
  119. Print " Not bad! You only lost ";DEATH_TOLL;" people!"
  120. End If 
  121. If DEATH_TOLL>400 and DEATH_TOLL<1000
  122. Print " Your term of office has expired"
  123. Print "  Unfortunately, so have most of the     people!"
  124. End If 
  125. If DEATH_TOLL>1000
  126. Print " Your term of office has finally been    terminated"
  127. Print " Survivors are dancing in the streets!"
  128. End If 
  129. Print " During your rule ";DEATH_TOLL;" people starved"
  130. Print " And";ARRIVED;" new people settled in the city "
  131. GAMEOVER=1
  132. End If 
  133. Locate 0,25 : Centre "Press a key to continue" : Wait Key : Cline 
  134. If GAMEOVER Then Gosub GAME_OVER
  135. Gosub CHECKIT
  136. Screen To Back 0
  137. Screen 2
  138. Return 
  139. BUYIT:
  140. PRICE=BUY_PRICE
  141. If PRICE<2 Then PRICE=2
  142. Cls : Locate 0,0 : Centre "Buy Grain"
  143. OK=0
  144. Repeat 
  145. Locate 0,2 : Print "Grain costs ";PRICE;
  146. Locate 18,2 : Print " per bushel"
  147. Locate 0,3 : Print "You have   ";MONEY;
  148. Locate 18,3 : Print " pieces of gold"
  149. Locate 0,6 : Cline : Input "How many bushels wilt thou buy?";BUY
  150. If BUY=0
  151. OK=1
  152. End If 
  153. If BUY*PRICE>MONEY
  154. Print "You don't have enough money"
  155. Wait 40 : Locate 0,7 : Cline 
  156. Else 
  157. MONEY=MONEY-BUY*PRICE : GRAIN#=NGRAIN#+BUY : NGRAIN#=GRAIN#
  158. OK=1
  159. End If 
  160. Until OK
  161. Cls 
  162. Gosub CHECKIT
  163. Return 
  164. SELLIT: PRICE=SELL_PRICE
  165. Cls : Locate 0,0 : Centre "Sell Grain"
  166. Locate 0,2 : Print "Grain cost ";PRICE;
  167. Locate 18,2 : Print " per bushel"
  168. Locate 0,3 : Print "You have    ";NGRAIN#;
  169. Locate 18,3 : Print " bushels in the store"
  170. OK=0
  171. Repeat 
  172. Cline 
  173. Locate 0,6 : Input "How many bushels wilt thou sell?";SELL
  174. If SELL=0 Then OK=1
  175. If SELL>NGRAIN#
  176. Locate 0,7 : Print "You don't have enough grain"
  177. Wait 40 : Locate 0,7 : Cline 
  178. End If 
  179. MONEY=MONEY+SELL*PRICE : GRAIN#=NGRAIN#-SELL
  180. NGRAIN#=GRAIN# : OK=1
  181. Until OK
  182. Cls 
  183. Gosub CHECKIT
  184. Return 
  185. CHECKIT:
  186. Screen 1
  187. Cls 
  188. Locate 0,0 : Print " Year";YEAR;" of King ";NAME$
  189. Locate 0,2 : Print " Thy treasury containeth  ";MONEY;
  190. Locate 32,2 : Print " Gold"
  191. Locate 0,3 : Print " Thy warehouse holds      ";NGRAIN#
  192. Locate 32,3 : Print " Bushels"
  193. Locate 0,4 : Print " Thy subjects number     ";PEOPLE;
  194. Locate 32,4 : Print " People"
  195. Locate 0,6 : Print " Thou hast planted      ";PLANTED;
  196. Locate 32,6 : Print " Bushels"
  197. Locate 0,7 : Print " Thy people have     ";FOOD#;
  198. Locate 32,7 : Print " Bushels"
  199. Screen 2
  200. Return 
  201. PLANT:
  202. Cls : Locate 0,0 : Centre "Plant crops"
  203. Locate 0,3 : Print "Thou hast ";NGRAIN#;" bushels in the store"
  204. OK=0
  205. Repeat 
  206. Locate 0,5 : Cline : Input "How many bushels wilt thou plant?";PLANTED
  207. If PLANTED=0 Then Input "Are you sure?";AN$
  208. If(AN$="y") or(AN$="Y")
  209. OK=0
  210. End If 
  211. If PLANTED>NGRAIN#
  212. Print "You don't have enough grain" : Wait 40 : Cup : Cline 
  213. PLANTED=0
  214. Else 
  215. NGRAIN#=NGRAIN#-PLANTED : OK=1
  216. End If 
  217. Until OK
  218. Cls 
  219. Gosub CHECKIT
  220. Return 
  221. FEED:
  222. Cls : Locate 0,0 : Centre "Ration Food"
  223. Locate 0,3 : Print "Thou hast ";NGRAIN#;" bushels in the store"
  224. OK=0
  225. Repeat 
  226. Locate 0,5 : Cline : Input "What wilt thou feed to thy people?";FOOD#
  227. If FOOD#=0 Then Input "Are you sure?";AN$
  228. If(AN$="Y") or(AN$="y")
  229. OK=1
  230. End If 
  231. If FOOD#>NGRAIN#
  232. Print "There isn't enough grain" : FOOD#=0 : Wait 40 : Cup : Cline 
  233. Else 
  234. NGRAIN#=NGRAIN#-FOOD# : OK=1
  235. End If 
  236. Until OK
  237. Cls 
  238. Gosub CHECKIT
  239. Return 
  240. GAME_OVER:
  241. Screen Open 3,640,100,4,Hires : Curs Off : Cls 0
  242. NO_POINT=11 : MX_POINTS=11 : X=40 : Y=20 : W=25 : H=50
  243. MX_HEIGHT#=1200 : S=1 : MT$="Population" : BT$="Years " : ST$="People"
  244. P=3 : HSC=1 : VSC=0 : Ink 2,0,2
  245. T=1 : T$=MT$ : Gosub GRAPH4 : Ink 2,0,2 : Gosub SCALE2
  246. Screen 0 : Locate 0,25 : Print "Another Game?" : Input ANO$
  247. If(ANO$="n") or(ANO$="N")
  248. Stop 
  249. Else 
  250. Screen Close 3
  251. Cls : Screen 1 : Cls : Screen 2
  252. Cls : Screen To Back 0 : Gosub NEW_GAME : Return 
  253. End If 
  254. SCALE2:
  255. XA=X : YA=Y : V=MX_HEIGHT# : Gosub CNUM : YA=Y+H : V=VSC : Gosub CNUM
  256. YA=Y+H+20+Text Base : T$=BT$ : Gosub GCENTRE : T$=ST$ : Gosub VCENTRE
  257. For A=0 To MX_POINTS-1
  258. A$=Str$(A+HSC)-" " : Text X+A*W,Y+H+10,A$
  259. Next A
  260. Return 
  261. CNUM: V$=Str$(V)-" " : LM=Text Length(V$) : Text XA-LM,YA+Text Base,V$ : Return 
  262. GCENTRE:
  263. CX=W*MX_POINTS-Text Length(T$) : LX=XA+CX/2 : LY=YA-Text Base
  264. Text LX,LY,T$ : Return 
  265. VCENTRE:
  266. CH=8 : VH=H-Len(T$)*CH : SY=Y+Text Base+VH/2
  267. For C=1 To Len(T$) : C$=Mid$(T$,C,1) : Text SX,SY+(C-1)*CH,C$ : Next C
  268. Return 
  269. GRAPH4:
  270. SX=X+W*(MX_POINTS-1) : Box X,Y To SX+1,Y+H+3
  271. XA=X : YA=Y : SX=SX+16 : Gosub GCENTRE : SF#=H/(MX_HEIGHT#-1)
  272. PY=D(S,T)*SF# : Plot X,Y+H-PY : Draw X-2,Y+H-PY To X+2,Y+H-PY
  273. If NO_POINTS=S Then Return 
  274. For B=S+1 To NO_POINTS
  275. PY=D(B,T)*SF# : Draw To X+(B-S)*W+1,Y+H-PY
  276. Next B
  277. Set Paint 0 : Return 
  278. Procedure NOISE
  279. For L=79 To 0 Step -1
  280. Play 96-(20+(L/2)),0
  281. Wait 1
  282. Next L
  283. End Proc