home *** CD-ROM | disk | FTP | other *** search
/ Amoszine 4 / Amoszine 4 (Disk 1 of 3).adf / articles_source.LHA / articles_source / astrosmash.amos / astrosmash.amosSourceCode next >
Encoding:
AMOS Source Code  |  1992-02-26  |  3.3 KB  |  90 lines

  1. Rem ------------------------------------------------------------------------ 
  2. Rem --  Astro Smash    Coding: Eric Askilsrud (Redlense@u.washington.edu) -- 
  3. Rem --     A <10k program written with Amos 1.3, Jun 1992                 --   
  4. Rem -      See accompanying file for tutorial on this game's creation.    --     
  5. Rem ------------------------------------------------------------------------ 
  6. Dim XDIR#(1),YDIR#(1),X#(1),Y#(1),LK(1),I(1),AX#(16),AY#(16)
  7. Default 
  8. Flash Off : Hide : Curs Off : Paper 0 : Degree 
  9. For ANGLE=0 To 15
  10.  AX#(ANGLE+1)=0.5*Sin(ANGLE*22.5)
  11.  AY#(ANGLE+1)=-0.5*Cos(ANGLE*22.5)
  12. Next 
  13. Make Mask 
  14. While QUIT=0
  15.   TYPE=0 : For Z=0 To 1 : XDIR#(Z)=0.0 : YDIR#(Z)=0.0 : Next 
  16.   X#(1)=10.0 : Y#(1)=10.0 : I(1)=7 : X#(0)=300.0 : Y#(0)=180.0 : I(0)=15
  17.   INGAME=0 : Cls 
  18.   Locate ,2 : Centre "Astro Smash"
  19.   Locate ,4 : Centre "(Written in Amos 1.3)"
  20.   Locate ,8 : Centre "1) Reflective Walls "
  21.   Locate ,10 : Centre "2) Warp Space"
  22.   Locate ,13 : Centre "Q) Quit"
  23.   While TYPE=0 : A$=Inkey$ : If A$="1" Then TYPE=1
  24.                              If A$="2" Then TYPE=2
  25.                              If Upper$(A$)="Q"
  26.                                                Erase 1
  27.                                                  Run "Autoexec.Amos"
  28.                                                End 
  29.                              End If 
  30.   Wend 
  31.   Cls : If TYPE=1 Then Box 0,0 To 319,199
  32.   While INGAME=0
  33.    For P=0 To 1
  34.     K=Joy(P)
  35.     If K>15 Then K=K-16 : XDIR#(P)=XDIR#(P)+AX#(I(P)) : YDIR#(P)=YDIR#(P)+AY#(I(P)) : Gosub CHSPEED
  36.     If K=8 Then If Chanan(P)=0 Then I(P)=I(P)+1 : Gosub CHLOOP : Amal P*4,"A2,("+Str$(I(P))+",1)" : Amal On P*4
  37.     If K=4 Then If Chanan(P)=0 Then I(P)=I(P)-1 : Gosub CHLOOP : Amal P*4,"A2,("+Str$(I(P))+",1)" : Amal On P*4
  38.     If K=1 and LK(P)<>K Then Gosub BULLET
  39.     On TYPE Gosub BOUNCE,WARP
  40.     X#(P)=XDIR#(P)+X#(P) : Y#(P)=YDIR#(P)+Y#(P)
  41.     Sprite P*4,X Hard(X#(P)),Y Hard(Y#(P)),I(P)
  42.     Gosub CHECKBULLS
  43.     LK(P)=K
  44.     If Sprite Col(P*4)<>0 Then Boom : Sprite P*4,X Hard(X#(P)),Y Hard(Y#(P)),18 : INGAME=1 : Amal Off 
  45.    Next 
  46.    Wait Vbl 
  47.   Wend 
  48.   For Z=0 To 1
  49.    If Sprite Col(Z*4)<>0 Then Sprite Z*4,X Hard(X#(Z)),Y Hard(Y#(Z)),18
  50.   Next 
  51.   Sprite Update : Wait Vbl : Locate ,11 : Centre "Game Over" : Wait 40 : While Joy(1)<16 : Wend 
  52.   For Z=0 To 7 : Sprite Off Z : Next : Sprite Update 
  53. Wend 
  54. End 
  55. CHLOOP:
  56.  If I(P)>16 Then I(P)=1
  57.  If I(P)<1 Then I(P)=16
  58. Return 
  59. CHSPEED:
  60.  If XDIR#(P)>4.0 Then XDIR#(P)=4.0
  61.  If XDIR#(P)<-4.0 Then XDIR#(P)=-4.0
  62.  If YDIR#(P)>4.0 Then YDIR#(P)=4.0
  63.  If YDIR#(P)<-4.0 Then YDIR#(P)=-4.0
  64. Return 
  65. BOUNCE:
  66.  If X#(P)>304.0 Then X#=304.0 : XDIR#(P)=0.0-XDIR#(P) : Bell 1
  67.  If X#(P)<-3.0 Then X#=-3.0 : XDIR#(P)=0.0-XDIR#(P) : Bell 1
  68.  If Y#(P)>184.0 Then Y#=184.0 : YDIR#(P)=0.0-YDIR#(P) : Bell 1
  69.  If Y#(P)<-2.0 Then Y#=-2.0 : YDIR#(P)=0.0-YDIR#(P) : Bell 1
  70. Return 
  71. WARP:
  72.  If X#(P)>304.0 Then X#(P)=0.0
  73.  If X#(P)<0.0 Then X#(P)=304.0
  74.  If Y#(P)>184.0 Then Y#(P)=0.0
  75.  If Y#(P)<0.0 Then Y#(P)=184.0
  76. Return 
  77. BULLET:
  78.  Q=0
  79.  If P=0 Then For Z=1 To 3 : If Chanmv(Z)=0 Then Q=Z : Next 
  80.  If P=1 Then For Z=5 To 7 : If Chanmv(Z)=0 Then Q=Z : Next 
  81.  If Q=0 Then Return 
  82.  Shoot 
  83.  Sprite Q,X Hard(X#(P)+7)+30*AX#(I(P)),Y Hard(Y#(P)+8)+30*AY#(I(P)),17
  84.  Amal Q,"M "+Str$(Int(300*AX#(I(P))))+","+Str$(Int(300*AY#(I(P))))+",50" : Amal On Q
  85. Return 
  86. CHECKBULLS:
  87. For Z=1 To 7
  88.  If Z<>4 and Chanmv(Z)=0 Then Sprite Off Z
  89. Next 
  90. Return