Recent Posts

Pages: 1 ... 3 4 [5] 6 7 ... 10
41
QB64 Discussion / Re: Small graphics programming challenge
« Last post by bplus on April 14, 2022, 10:56:54 am »
Hi @Richard Frost

There is naming problem with the Flag files see attached snap
  [ You are not allowed to view this attachment ]  
42
QB64 Discussion / Re: Small graphics programming challenge
« Last post by SMcNeill on April 14, 2022, 10:50:35 am »
He stopped halfway...  I've got this on here somewhere, except my version lets you click on the circles and use them as a pop-up menu.  :P
43
QB64 Discussion / Small graphics programming challenge
« Last post by Richard Frost on April 14, 2022, 10:31:33 am »
' Small programming challenge contained at:
'

' It's a boring hour and a half of some guy creating CSS code for a simple animation to:
' 1) Have 8 icons/pictures rotating in a circle, while pulsing
' 2) when one selected, stop all rotation, the pulsing of the selected item, and
'    identify the selected item
' Use any 8 pix you've got handy, or the flags I've attached here.
Code: QB64: [Select]
  1. Data albania,britain,canada,eu,us,japan,israel,china
  2. Screen _NewImage(800, 600, 32)
  3. For i = 1 To 8
  4.     Read name$(i)
  5.     pix(i) = _LoadImage("f_" + name$(i) + ".png")
  6. td = 1 '                                         throb direction
  7.         mx = _MouseX
  8.         my = _MouseY
  9.         mb = _MouseButton(1)
  10.     Wend
  11.     Cls
  12.     hl = 0 '                                     highlight
  13.     For i = 1 To 8
  14.         r = _D2R(i * 45 + aa) '                  angle in radians
  15.         x = 400 + 200 * Cos(r)
  16.         y = 300 + 200 * Sin(r)
  17.         tt = th '                                temporary throb = current
  18.         If mb And (Abs(x - mx) < 30) And (Abs(y - my) < 30) Then ' selected
  19.             tt = 0 '                             temporary throb off
  20.             hl = 1 '                             highlight on
  21.             _PrintString (x - 26, y - 50), name$(i)
  22.         End If
  23.         _PutImage (x - 30 + tt, y - 30 + tt)-(x + 30 - tt, y + 30 - tt), pix(i), 0
  24.     Next i
  25.     _Display '                                   optional, eliminates flickering
  26.     aa = (aa - (hl = 0)) Mod 360 '               angle advance
  27.     th = th + td '                               throb
  28.     If Abs(th) = 3 Then td = -td '               throb direction
  29.  
44
QB64 Discussion / Re: QB64 Bounty List
« Last post by SMcNeill on April 14, 2022, 09:01:10 am »
1. A good Inkey$ like alternative for $console:only on Win and Linux would give much business value for me

There's _CINP for Windows, which does what you're talking about, though it's never been ported into Linux yet.
45
QB64 Discussion / Re: QB64 Bounty List
« Last post by mdijkens on April 14, 2022, 03:27:47 am »
1. A good Inkey$ like alternative for $console:only on Win and Linux would give much business value for me
2. Shell with stdin and stdout; preferably with _Nowait (to get some multitasking functionality)
46
QB64 Discussion / Re: Has $Debug been working well for you?
« Last post by Richard on April 13, 2022, 11:14:06 am »
Although not going into specifics here, it was/is a great help - although floating point handling, as already noted is (and probably always still will be) an issue (and not referring to FLOAT which is a "problem" in itself).

Probably the best thing for me with $Debug was that it brought QB64 much closer to the already existing functionality of MS PDS 7.1 (upgrade to QB45) which I still use a lot (QB64 has a lot of catching up to what PDS could do).
47
QB64 Discussion / Re: QB64 Bounty List
« Last post by madscijr on April 13, 2022, 10:07:49 am »
One wish list item I'd offer a bounty for (if it's within my modest means!) would be getting QB64 to read separate input from multiple USB mice plugged into the computer.

Preferably this would be cross-platform (I did research a while back and it looked like it was possible for PC, Linux and Mac using different methods, not sure about DOS) but at least for Windows.

Microsoft's RawInput API can do it, and I found a ton of examples, but alas this is just beyond my capabilities and/or free time :-( so to anyone who can get it done, what's it worth to ya? LoL

Here are the discussions about it with links to research findings / related libraries / sample code / etc.:

reading multiple mice input with _DEVICES and _DEVICE$, or RawInput ?:

https://qb64forum.alephc.xyz/index.php?topic=3348.0

reading multiple mice input revisited / external library question:

https://qb64forum.alephc.xyz/index.php?topic=3695.0

events and malloc in QB64?:

https://qb64forum.alephc.xyz/index.php?topic=3766.0
48
QB64 Discussion / Re: QB64 Bounty List
« Last post by wiggins on April 12, 2022, 09:53:58 pm »
I just remembered that there is a bug list out there. 
49
QB64 Discussion / Re: QB64 Bounty List
« Last post by wiggins on April 12, 2022, 09:51:50 pm »
M1 Support is needed
Generate a smaller executable
50
Programs / Assassins 64: Blast from the past
« Last post by kinem on April 12, 2022, 09:39:22 pm »
This is a QB 64 version of the first-person shooter game that I made in QB 4.5 back in 2001. It was impressive back then simply because it was such a fast engine for QB 4.5; that's not really an issue anymore. The sprites are rather basic (no pun intended?), but this version features improved gameplay compared to the original, and a third weapon. The look of the game is otherwise the same, and most of the code is unchanged.

Code: QB64: [Select]
  1. '1PSA64-2.BAS by Dr. Jacques Mallah (jackmallah@yahoo.com)
  2. 'Compile with QB64
  3. DECLARE SUB endit () : DECLARE SUB onscreen () : DECLARE SUB paintsprites ()
  4. DECLARE SUB medkit.etc () : DECLARE SUB showhealth () : DECLARE SUB badguys ()
  5. DECLARE SUB yourmove () : DECLARE SUB time () : DECLARE SUB yourshot ()
  6. DECLARE SUB crashtest (bx!, by!, vx!, vy!) : DECLARE FUNCTION atan2! (y!, x!)
  7. DECLARE SUB showbadguy (b%) : DECLARE SUB showbadshot (x%) : DECLARE SUB showurshot (x%)
  8. DECLARE SUB raycast () : DECLARE SUB btexture (xx%, dd%, bcc%, c%, bcc2%)
  9. DECLARE SUB putcircle (x%, y%, R%, col%, circdis!) : DECLARE SUB showmed (b%)
  10. DECLARE SUB putbox (x1!, y1%, x2!, y2%, col%, boxdis!): declare sub readmap()
  11. DECLARE SUB intro () : DECLARE SUB maketables () : DECLARE SUB makeworld ()
  12. DECLARE SUB hLINE (x1%, x2%, y%, c%) : DECLARE SUB vline (x%, yt%, yb%, c%), keys()
  13. declare function lsight%(b%): ntx% = 7: sizey% = 30: sizex% = 60: shift = 49
  14. Dim kbmatrix%(128), odd%(319)
  15. Dim fmap%(sizex% - 1, sizey% - 1), wdis(319), testin%(ntx%, 63, 63), dsfc(319)
  16. Dim cmap%(sizex% - 1, sizey% - 1), sb1%(159, 199), st(1800), ct(1800), hicol%(255)
  17. Dim map%(sizex% - 1, sizey% - 1), tant(1800), xb%(1800), yb%(1800), sb2%(160 * 192 + 1)
  18. Dim lowcol%(-128 To 127), bicol%(255), atx%(319), ammo%(2), oammo%(2), stt(1800), ctt(1800)
  19. Call readmap: c% = nmeds% + nammo% - 1: ReDim med%(c%), scmed(c%), mx(c%), my(c%)
  20. ReDim medis(c%), medx(c%), medy(c%), dis(nspr%), spord%(nspr%), disi%(nspr%)
  21. ReDim sht(nshots%), shosht%(nshots%), shtx(nshots%), shty(nshots%), vshx(nshots%), vshy(nshots%)
  22. ReDim shtang%(nshots%), shtdis(nshots%), dela%(nshots%), shtht%(nshots%), plasma%(nshots%)
  23. ReDim bgh%(nbguysm1%), bgx(nbguysm1%), bgy(nbguysm1%), robo%(nbguysm1%)
  24. ReDim x(nbguysm1%), y(nbguysm1%), vbx(nbguysm1%), vby(nbguysm1%)
  25. ReDim scbg(nbguysm1%), bgang%(nbguysm1%), bgsht(nbguysm1%), lastx(nbguysm1%), lasty(nbguysm1%)
  26. ReDim bgshosht%(nbguysm1%), bgshtx(nbguysm1%), bgshty(nbguysm1%)
  27. ReDim bgvshx(nbguysm1%), bgvshy(nbguysm1%), bgshtdis(nbguysm1%)
  28. ReDim bgdela%(nbguysm1%), bgshtht%(nbguysm1%), active%(nbguysm1%): _FullScreen: delta.t = .1
  29. Call intro: maketables: makeworld: Get (0, 8)-(319, 199), sb2%()
  30.  
  31. main: raycast: keys: yourshot: time: yourmove: badguys: showhealth: medkit.etc
  32. Call paintsprites: onscreen: endit: GoTo main
  33.  
  34. spritedata:
  35. Data 0,6,2,1,0,4,""
  36.  
  37. 'Map: each character (>"0") is a color or texture
  38. '0 is empty space.  Outer walls must not contain any 0's, ?'s, or r's
  39. '1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, +, >, @, A are wall textures
  40. '4 is the map, A is the rainbow
  41. '? is an ice block "door"
  42. 'r is random: 50% chance of ice, else texture @
  43.  
  44. '. = empty, B = bad guy, R = robot, M = medkit, L = ammo, P = the President / player
  45. mapdata:
  46. Data "666666667546C66666666666666666666666666666666666666666666666"
  47. Data "6.R..?.......6....M6L..................RR?................L6"
  48. Data "6....1.......A.....?...................BB3................M6"
  49. Data "6....1.......@.....6662?266666662526666666666664?766666666?6"
  50. Data "6....1.......?.....6.....................6.................6"
  51. Data "6....1.......>.....6.....................?.................6"
  52. Data "6....1.......=.....6.....................6.................1"
  53. Data "6....?.......<.....666666666444666666666?6.................1"
  54. Data "6....2.......;.....6.........1...........6.......BBBB......1"
  55. Data "6....2.......:.....6..BBBB...2......B....?.................6"
  56. Data "6....2.......9.....6..BBBB...3...........6.................6"
  57. Data "6....2.......8.....6.........4...........6.................6"
  58. Data "6....?.......7.....6.........A777777777776666664?76666666666"
  59. Data "6....3.......6.....6.......................................6"
  60. Data "6....3.......5.....6.......................................6"
  61. Data "6....3.......4.....7.......................................6"
  62. Data "6....?.......3.....6.......................................6"
  63. Data "6....4BBB....2..R..6.......................................6"
  64. Data "6....4BBB....1LMMM612?45633?333333333333?33336.............6"
  65. Data "6....4BBB....6657666.....6...................6.............6"
  66. Data "6....4BBB....?.LLL.6.....6...................6.............6"
  67. Data "6....4BBB....?.MMM.6.....6.......BBB.........?.............6"
  68. Data "6....555555555555556.....r...................6.............6"
  69. Data "6.........?.....M..6.....6...................6666666466666?6"
  70. Data "6.........r........6.....6AAAAAAA?AAAAAAAAAA46.............3"
  71. Data "6.........r........A.........................6.............4"
  72. Data "6..B......r........A..BBBB...................?.............1"
  73. Data "6.........r.....P..A.........................6...RRRR......2"
  74. Data "6.........r.....L..A.............LLLLMMMM....6.............6"
  75. Data "6155555555555556AAA66666666666666AAA666656666666666656666666"
  76.  
  77. Function atan2 (y, x)
  78.     If x = 0 Then
  79.         If y > 0 Then atan2 = 90 Else If y < 0 Then atan2 = 270
  80.     ElseIf x > 0 Then
  81.         atan2 = (Atn(y / x) * 57.2958 + 360) Mod 360
  82.     Else
  83.         atan2 = (Atn(y / x) * 57.2958 + 180)
  84.     End If
  85.  
  86. Sub badguys
  87.     Shared nbguysm1%, testin%(), bgx(), bgy(), delta.t, bgh%(), dis()
  88.     Shared px, py, bx, by, vx, vy, fdt, scbg(), bgang%(), x(), y(), fram%, ph%
  89.     Shared bgsht(), bgshosht%(), bgvshx(), bgvshy(), ct(), st(), bgshtdis()
  90.     Shared inx%, iny%, map%(), fmap%(), bsa%, bgshtx(), bgshty(), bgdela%()
  91.     Shared bgshtht%(), nbguys%, vbx(), vby(), snd%, kills%, robo%(), active%(), lastx(), lasty()
  92.  
  93.     For x% = 0 To nbguysm1%
  94.     testin%(4, Int(bgx(x%)) + 2, Int(bgy(x%)) + 19) = 0: Next
  95.  
  96.     'bad guys: Note: I want to add some AI!
  97.     damp = .8 ^ fdt: sqrdt = Sqr(delta.t) * 6
  98.     For x% = 0 To nbguysm1%
  99.  
  100.         If bgh%(x%) > 0 Then
  101.             If lsight%(x%) Then
  102.                 active%(x%) = 1: lastx(x%) = bx: lasty(x%) = by
  103.             Else
  104.                 If active%(x%) = 1 Then active%(x%) = 2
  105.             End If
  106.  
  107.             bbgx = px - bgx(x%): bbgy = py - bgy(x%)
  108.             dis(x%) = Sqr(bbgx * bbgx + bbgy * bbgy) + .01
  109.  
  110.             chase = 2 * delta.t * (1 + robo%(x%)) * -(active%(x%) > 0)
  111.             bbgx = lastx(x%) - bgx(x%): bbgy = lasty(x%) - bgy(x%)
  112.             cdis = Sqr(bbgx * bbgx + bbgy * bbgy) + .01
  113.             If active%(x%) = 2 And cdis < .3 Then active%(x%) = 0
  114.  
  115.             vbx(x%) = vbx(x%) * damp + (Rnd - .5) * sqrdt + bbgx / cdis * chase
  116.             vby(x%) = vby(x%) * damp + (Rnd - .5) * sqrdt + bbgy / cdis * chase
  117.             If (px - bgx(x%)) ^ 2 + (py - bgy(x%)) ^ 2 < 1 Then
  118.                 vbx(x%) = vbx(x%) - bbgx / dis(x%) * fdt
  119.                 vby(x%) = vby(x%) - bbgy / dis(x%) * fdt
  120.                 vx = vx + bbgx / dis(x%) * fdt
  121.                 vy = vy + bbgy / dis(x%) * fdt
  122.             End If
  123.             svx% = Sgn(vbx(x%)): svy% = Sgn(vby(x%))
  124.             crashtest bgx(x%) + .15 * svx%, bgy(x%) + .15 * svy%, vbx(x%), vby(x%)
  125.             crashtest bgx(x%) - .15 * svx%, bgy(x%) + .15 * svy%, vbx(x%), vby(x%)
  126.             crashtest bgx(x%) + .15 * svx%, bgy(x%) - .15 * svy%, vbx(x%), vby(x%)
  127.             bgx(x%) = bgx(x%) + vbx(x%) * delta.t: bgy(x%) = bgy(x%) + vby(x%) * delta.t
  128.             scbg(x%) = 2 / (dis(x%) + .01)
  129.             bgang%(x%) = atan2(bgy(x%) - by, bgx(x%) - bx) * 5
  130.             delba% = (bgang%(x%) - bsa% + 1800) Mod 1800
  131.             x(x%) = delba% - scbg(x%) * 20: y(x%) = 100 - 25 * scbg(x%)
  132.  
  133.             'bad guy's shot
  134.             If bgsht(x%) <= 0 And active%(x%) = 1 Then
  135.                 bgsht(x%) = 20 + Rnd: bgshosht%(x%) = 1: 'create shot
  136.                 bgshtx(x%) = bgx(x%): bgshty(x%) = bgy(x%)
  137.                 bgsta% = (bgang%(x%) + 900) Mod 1800
  138.                 bgvshx(x%) = ct(bgsta%) * 7
  139.                 bgvshy(x%) = st(bgsta%) * 7
  140.             End If
  141.         End If
  142.  
  143.         'bad guy's shot
  144.         If bgsht(x%) > 0 And bgshosht%(x%) Then
  145.             crashtest bgshtx(x%), bgshty(x%), bgvshx(x%), bgvshy(x%)
  146.             k% = map%(inx%, iny%)
  147.             If k% Then
  148.                 bgshosht%(x%) = 0
  149.                 If k% = 15 And bgsht(x%) > 0 Then
  150.                     map%(inx%, iny%) = 0
  151.                     testin%(4, inx% + 2, iny% + 19) = 0
  152.                 End If
  153.             Else
  154.                 bgshtx(x%) = bgshtx(x%) + bgvshx(x%) * delta.t
  155.                 bgshty(x%) = bgshty(x%) + bgvshy(x%) * delta.t
  156.                 bbx = bgshtx(x%) - bx: bby = bgshty(x%) - by
  157.                 bgshtang% = atan2(bby, bbx) * 5
  158.                 bgshtdis(x%) = Sqr(bby * bby + bbx * bbx + .01)
  159.                 dis(x% + nbguys%) = bgshtdis(x%)
  160.                 'fix damage test
  161.                 If bgshtdis(x%) < .5 Then
  162.                     ph% = ph% - bgsht(x%) / 4 - 2.5 * (1 + robo%(x%)): bgshosht%(x%) = 0
  163.                     If snd% Then Sound 150, 1
  164.                     vx = vx + bgvshx(x%) * .05: vy = vy + bgvshy(x%) * .05
  165.                 End If
  166.                 'kill each other?
  167.                 For y% = 0 To nbguysm1%
  168.                     If x% <> y% And bgh%(y%) > 0 Then
  169.                         bsdis = Sqr((bgshty(x%) - bgy(y%)) ^ 2 + (bgshtx(x%) - bgx(y%)) ^ 2 + .01)
  170.                         If bsdis < .5 Then
  171.                             bgh%(y%) = bgh%(y%) - bgsht(x%) / 2 - 1: bgshosht%(x%) = 0
  172.                             vbx(y%) = vbx(y%) + bgvshx(x%) * .5: vby(y%) = vby(y%) + bgvshy(x%) * .5
  173.                             If bgh%(y%) < 1 Then
  174.                                 fmap%(Int(bgx(y%)), Int(bgy(y%))) = 4 + 4 * robo%(y%)
  175.                                 kills% = kills% + 1: Exit For
  176.                             End If
  177.                         End If
  178.                 End If: Next
  179.                 bgdela%(x%) = (bgshtang% - bsa% + 1800) Mod 1800
  180.                 bgshtht%(x%) = 30 / bgshtdis(x%)
  181.             End If
  182.         End If
  183.         If bgsht(x%) > 0 Then bgsht(x%) = bgsht(x%) - fdt
  184.  
  185.         If fram% / 2 = fram% \ 2 Then
  186.             testin%(4, Int(px) + 2, Int(py) + 19) = 1
  187.             If bgh%(x%) > 0 Then testin%(4, Int(bgx(x%)) + 2, Int(bgy(x%)) + 19) = 4 + 4 * robo%(x%)
  188.         End If
  189.     Next x%
  190.  
  191. Sub crashtest (bx, by, vx, vy): 'note vx & vy args must be byref
  192.     Shared map%(), delta.t, inx%, iny%
  193.     Static oinx%, oiny%, nallcl%, chn2%, xsign%, ysign%, k%, kx%, ky%
  194.  
  195.     oinx% = Int(bx): oiny% = Int(by): nallcl% = 1
  196.     px = bx + vx * delta.t: py = by + vy * delta.t
  197.     inx% = Int(px): iny% = Int(py)
  198.     ysign% = Sgn(vy): xsign% = Sgn(vx)
  199.     chn2% = (inx% - oinx%) * xsign% + (iny% - oiny%) * ysign%
  200.     k% = map%(inx%, iny%)
  201.     If inx% = oinx% Then horz% = 1
  202.     If iny% = oiny% Then vert% = 1
  203.     If chn2% = 2 Then
  204.         ys% = (1 + ysign%) \ 2: xs% = (1 + xsign%) \ 2
  205.         kx% = map%(oinx%, iny%): ky% = map%(inx%, oiny%)
  206.         tstang% = Sgn((px - bx) * (iny% + 1 - ys% - by) - (py - by) * (inx% + 1 - xs% - bx))
  207.         tst% = xsign% * ysign% * tstang%
  208.         If tst% = 1 And k% + ky% = 0 Then nallcl% = 0
  209.         If tst% = -1 And k% + kx% = 0 Then nallcl% = 0
  210.         If ky% = 0 Then
  211.             horz% = 1
  212.         Else
  213.             vert% = 1: k% = ky%: If tst% = 1 Then iny% = oiny%
  214.         End If
  215.         If kx% Then
  216.             horz% = 1: k% = kx%: If tst% = -1 Then inx% = oinx%
  217.         Else
  218.             vert% = 1
  219.         End If
  220.     End If: If k% = 0 Then nallcl% = 0
  221.     If nallcl% Then
  222.         If horz% And vert% And ky% = 0 And kx% = 0 Then
  223.             If tst% = 1 Then horz% = 0 Else vert% = 0
  224.         End If
  225.         If vert% Then vx = 0
  226.         If horz% Then vy = 0
  227.     End If
  228.  
  229. Function lsight% (b%)
  230.     Shared map%(), delta.t, inx%, iny%, px, py, bgx(), bgy()
  231.     delx = bgx(b%) - px: dely = bgy(b%) - py: delmag = Sqr(delx ^ 2 + dely ^ 2)
  232.     lx = px: ly = py: delx = delx / delmag / delta.t: dely = dely / delmag / delta.t: lt% = 0
  233.     Do: crashtest lx, ly, delx, dely: lx = lx + delx * delta.t: ly = ly + dely * delta.t
  234.         lt% = lt% + 1
  235.     Loop Until map%(inx%, iny%) Or lt% >= delmag
  236.     lsight% = (map%(inx%, iny%) = 0)
  237.  
  238. Sub endit
  239.     Shared kills%, nbguysm1%, nbguys%, kbmatrix%(), goon%, ph%, bgh%(), snd%
  240.  
  241.     If kbmatrix%(1) - 1 And ph% > 0 And kills% < nbguys% Then
  242.         goon% = 2
  243.     Else
  244.         goon% = goon% - 1
  245.     End If
  246.     If goon% = 0 Then
  247.         Locate 2, 1:
  248.         If kills% = nbguys% And ph% > 0 Then
  249.             Print "President Snore, you made it!": If snd% Then Play "mf gcfde"
  250.         Else
  251.             Print "You die"
  252.             For t% = 400 To 200 Step -20
  253.                 If snd% Then Sound t%, 1
  254.                 tim = Timer: Do: Loop Until Timer > tim
  255.             Next
  256.         End If
  257.         tim = Timer + .5: Do: Loop Until Timer > tim
  258.         Sleep 1: End
  259.     End If
  260.  
  261. Sub hLINE (x1%, x2%, y%, c%)
  262.     Shared sb1%(), hicol%(): ccc% = hicol%(c%) + c%
  263.     If x1% < 0 Then x1% = 0
  264.     If x2% > 319 Then x2% = 319
  265.     For x% = Int(x1% / 2) To Int(x2% / 2)
  266.         sb1%(x%, y%) = ccc%
  267.     Next
  268.  
  269. Sub intro: Shared snd%, nbguys%, nrobo%
  270.     Cls: Print "By Dr. Jacques Mallah", , "Assassins Edition.64"
  271.     Print: Print "In the year 3001 AD:"
  272.     Print "You, President Sal Snore of the United Snows of Antarctica,"
  273.     Print "are trapped in the Wight House with a bunch of guys trying to kill you. "
  274.     Print "They also reprogrammed your robot bodyguard(s).": Print
  275.     Print "Luckily, you have your trusty plasma gun (press 1) and machine gun (press 2)"
  276.     Print "and plas-cannon (press 3; uses plasma gun ammo)."
  277.     Print "Hiding's not your style.  You'll show them who's the boss!"
  278.     Print "Kill 'em all to win.  ("; nbguys% - nrobo%; " guy(s) and "; nrobo%; " robot(s))": Print
  279.     Print "use arrow forward, back to move; use arrow left, right to rotate"
  280.     Print "Alt to strafe with arrow left, right"
  281.     Print "Ctrl to shoot"
  282.     Print "To fight, try getting some distance and using strafe"
  283.     Print "Try shooting out some ice blocks"
  284.     Print "pick up ";: Color 0, 2: Print "-";: Color 7, 0: Print " ammo, and ";
  285.     Color 4, 15: Print "+";: Color 7, 0: Print " medical kits when needed"
  286.     Print "After starting, press Esc to take the easy way out - suicide!"
  287.     Print "press any key to start, SPACE for no sound": Print
  288.     Print "The # at the top left corner is frames per second"
  289.     Print "The bar at the bottom is your health."
  290.     Print "j to toggle cheat mode";
  291.     i$ = Input$(1): If i$ <> " " Then snd% = 1
  292.  
  293. Sub maketables
  294.     Shared st(), ct(), dsfc(), hicol%(), lowcol%(), bicol%(), atx%(), tant()
  295.     Shared xb%(), yb%(), spord%(), nspr%, stt(), ctt()
  296.     For tmp1% = 0 To 1800
  297.         st(tmp1%) = Sin(tmp1% * Atn(1) / 225): stt(tmp1%) = st(tmp1%) * 256
  298.         ct(tmp1%) = Cos(tmp1% * Atn(1) / 225): ctt(tmp1%) = ct(tmp1%) * 256
  299.     Next tmp1%
  300.     st(0) = 10 ^ -9: st(900) = 10 ^ -9: st(1800) = st(0)
  301.     stt(0) = 10 ^ -7: stt(900) = 10 ^ -7
  302.     ct(450) = 10 ^ -9: ct(1350) = 10 ^ -9
  303.     ctt(450) = 10 ^ -7: ctt(1350) = 10 ^ -7
  304.     For t% = 0 To 1800
  305.         sqct = Abs(1 / ct(t%)): sqt = Abs(1 / st(t%))
  306.         If sqt > sqct Then nn = sqct * 255 Else nn = sqt * 255
  307.         xb%(t%) = ct(t%) * nn: yb%(t%) = st(t%) * nn
  308.     tant(t%) = st(t%) / ct(t%): Next
  309.     yb%(0) = 0: yb%(900) = 0
  310.     xb%(450) = 0: xb%(1350) = 0
  311.     For x% = 0 To 319
  312.         atx%(x%) = Atn((x% - 160) * 3.14159 / 900) * 900 / 3.14159
  313.         dsfc(x%) = 100 / Abs(ct((atx%(x%) + 1800) Mod 1800))
  314.     Next
  315.     For c% = 0 To 255
  316.         hicol%(c%) = &H100 * (c% + &H100 * (c% > &H7F))
  317.         lowcol%(c% - 128) = c% - 128 - &H100 * ((c% - 128) < 0)
  318.         bicol%(c%) = &H100 * (c% + &H100 * (c% > &H7F)) + c%
  319.     Next
  320.     For x% = 0 To nspr%: spord%(x%) = x%: Next
  321.  
  322. Sub readmap
  323.     Shared fmap%(), sizex%, sizey%, testin%(), hicol%(), cmap%(), map%(), ntx%
  324.     Shared ph%, nbguysm1%, bgh%(), bgy(), bgx(), oldtim, nmeds%, medx(), medy()
  325.     Shared nshots%, med%(), ammo%(), weap$, px, py, sa, nmeds%, nammo%, robo%()
  326.     Shared maxshots%, nbguys%, nshots%, nspr%, nbguyst2%, nrobo%
  327.     Shared scmed(), mx(), my(), medis()
  328.     Shared F0%, F1%, F2%, F3%, F4%, F5%, bg$
  329.     DefInt N
  330.     Randomize Timer: nmeds% = 0: nammo% = 0: px = 17.5: py = 27.5: sa = 1190
  331.     Read F0%, F1%, F2%, F3%, F4%, F5%, bg$: nb = 0
  332.  
  333.     For y = 0 To sizey% - 1: Read i$: For x = 0 To sizex% - 1
  334.         ii$ = Mid$(i$, x + 1, 1): map%(x, y) = Asc(ii$) - 48
  335.         If ii$ = "." Then map%(x, y) = 0
  336.             If ii$ = "B" Or ii$ = "R" Then nb = nb + 1: If ii$ = "R" Then nrobo% = nrobo% + 1
  337.             If map%(x, y) = 66 Then map%(x, y) = 16 + (Rnd < .5)
  338.             If map%(x, y) < 0 Then map%(x, y) = map%(x, y) + 256
  339.             If y = 0 Or x = 0 Or y = sizey% - 1 Or x = sizex% - 1 Then
  340.                 If map%(x, y) = 0 Then map%(x, y) = 18
  341.                 If map%(x, y) = 15 Then map%(x, y) = 14
  342.             End If
  343.             If ii$ = "M" Then nmeds% = nmeds% + 1
  344.             If ii$ = "L" Then nammo% = nammo% + 1
  345.             If ii$ = "P" Then px = x + .5: py = y + .5: map%(x, y) = 0
  346.     Next: Next
  347.  
  348.     maxshots% = 9: nbguys% = nb: nbguysm1% = nbguys% - 1: nbguyst2% = nbguys% * 2
  349.     nshots% = maxshots%: nspr% = maxshots% + nbguyst2% + nmeds% + nammo%
  350.  
  351.  
  352. Sub makeworld
  353.     Shared fmap%(), sizex%, sizey%, testin%(), hicol%(), cmap%(), map%(), ntx%
  354.     Shared ph%, nbguysm1%, bgh%(), bgy(), bgx(), oldtim, nmeds%, medx(), medy()
  355.     Shared nshots%, med%(), ammo%(), weap$, px, py, sa, nmeds%, nammo%, robo%()
  356.     Shared maxshots%, nbguys%, nshots%, nspr%, snd%
  357.     Shared scmed(), mx(), my(), medis()
  358.     Shared F0%, F1%, F2%, F3%, F4%, F5%, bg$
  359.     DefInt N, T, X-Y
  360.     Screen 13: nb = 0: nm = 0: nam = nmeds%: If snd% Then Play "mb"
  361.     nshots% = 1: weap$ = " plasma gun": ammo%(0) = 24: ammo%(1) = 200
  362.  
  363.     For y = 1 To sizey% - 2: For x = 1 To sizex% - 2
  364.  
  365.         If map%(x, y) = 18 Then map%(x, y) = 0: bgx(nb) = x + .5: bgy(nb) = y + .5: nb = nb + 1
  366.             If map%(x, y) = 34 Then
  367.                 map%(x, y) = 0: bgx(nb) = x + .5: bgy(nb) = y + .5: robo%(nb) = 1: nb = nb + 1
  368.             End If
  369.             If map%(x, y) = Asc("M") - 48 Then
  370.                 medx(nm) = x + .5: medy(nm) = y + .5: map%(x, y) = 0: med%(nm) = 1: nm = nm + 1 'meds
  371.             End If
  372.             If map%(x, y) = Asc("L") - 48 Then
  373.                 medx(nam) = x + .5: medy(nam) = y + .5: map%(x, y) = 0: med%(nam) = 1: nam = nam + 1 'ammo
  374.             End If
  375.  
  376.     Next: Next
  377.  
  378.     For t = 0 To ntx%: For x = 0 To 63: For y = 0 To 63
  379.         testin%(t, x, y) = (t * 14 + Sqr((x - 32) ^ 2 + (y - 32 - Rnd * t) ^ 2)) Mod 256
  380.         testin%(t, x, y) = testin%(t, x, y) + hicol%(t + 1 + (Rnd < .1))
  381.     Next: Next: Next
  382.  
  383.     For x = 2 To 61: For y = 19 To 48
  384.     testin%(4, x, y) = map%(x - 2, y - 19): Next: Next
  385.     For x = 0 To 59: For y = 0 To 29: fmap%(x, y) = ((x + y) Mod 16) + 128
  386.         If map%(x, y) = 15 Then fmap%(x, y) = 15
  387.             Next: Next: For x = 16 To 18: For y = 26 To 28
  388.     fmap%(x, y) = 208: Next: Next
  389.     fmap%(39, 15) = -7: fmap%(24, 10) = -2: fmap%(17, 25) = 0
  390.     For x = 20 To 35: fmap%(x, 25) = 20 - x: Next
  391.  
  392.     For x = 0 To 59: For y = 0 To 29: cmap%(x, y) = 26
  393.         If x / 2 = x \ 2 Or y / 2 = y \ 2 Then cmap%(x, y) = 27
  394.             If x / 2 = x \ 2 And y / 2 = y \ 2 Then cmap%(x, y) = 15
  395.             Next: Next: For x = 16 To 18: For y = 26 To 28
  396.     cmap%(x, y) = 208: Next: Next: cmap%(17, 27) = 15
  397.  
  398.     Color 16: Print "Abandon": Print "all dope"
  399.     Print "Your ad": Print "  here:": Print " $100": Print " Call"
  400.     Print " 1-800-": Print " EATS": Print "  ???": Print " QB 64"
  401.     Print " I  $": Print: Print " Wight": Print " House": Print " HIT"
  402.     Print: Print " Who's": Print "da man?": Print " Please": Print "recycle"
  403.     Print "   JM": For x = 0 To 63: For y = 0 To 15
  404.         If Point(x, y) Then testin%(1, x, y + 1) = 15
  405.             If Point(x, y + 16) Then testin%(5, x, y + 8) = 0
  406.             If Point(x, y + 32) Then testin%(5, x, y + 24) = 0
  407.             If Point(x, y + 48) Then testin%(5, x, y + 40) = 0
  408.             If Point(x, y + 64) Then testin%(6, x, y + 32) = 7
  409.             If Point(x, y + 80) Then testin%(2, x, y + 1) = 4
  410.             If Point(x, y + 96) Then testin%(4, x, y + 1) = 15
  411.             If Point(x, y + 112) And y < 8 Then testin%(5, x, y + 56) = 0
  412.             If Point(x, y + 128) Then testin%(3, x, y + 48) = 1
  413.             If Point(x, y + 144) Then testin%(0, x, y + 48) = 6
  414.             If Point(x, y + 160) Then testin%(7, x, y + 32) = 9
  415.     Next: Next: Color 15
  416.     For x = 0 To 63: For y = 0 To 63
  417.         t = 15: If (Rnd * 60 > y) Then t = 24 + Rnd * 6
  418.             testin%(7, x, y) = (testin%(7, x, y) And &HFF) + hicol%(t)
  419.     Next: Next
  420.  
  421.     ph% = 100: For x% = 0 To nbguysm1%: bgh%(x%) = 100: If robo%(x%) Then bgh%(x%) = 1250
  422.         If bgx(x%) = 0 Then
  423.             randloc:
  424.             bgx(x%) = Int(Rnd * (sizex% - 1) + 1) + .5
  425.             bgy(x%) = Int(Rnd * (sizey% - 1) + 1) + .5
  426.             If map%(Int(bgx(x%)), Int(bgy(x%))) GoTo randloc
  427.         End If
  428.     Next: oldtim = Timer
  429.  
  430.  
  431. DefSng T, X-Y
  432. Sub medkit.etc: 'medkits and ammo boxes
  433.     Shared nmeds%, medis(), nbguyst2%, maxshots%, medx(), medy(), scmed(), dis()
  434.     Shared mx(), my(), ph%, bx, by, bgx(), bgy(), bgh%(), med%(), nbguysm1%, bsa%
  435.     Shared ammo%(), nammo%, robo%()
  436.  
  437.     For x% = 0 To nmeds% + nammo% - 1
  438.         If med%(x%) Then
  439.             medis(x%) = Sqr((bx - medx(x%)) ^ 2 + (by - medy(x%)) ^ 2)
  440.             dis(x% + nbguyst2% + maxshots% + 1) = medis(x%)
  441.             scmed(x%) = 3 / (dis(x% + nbguyst2% + maxshots% + 1) + .01)
  442.             bgang% = atan2(medy(x%) - by, medx(x%) - bx) * 5
  443.             delba% = (bgang% - bsa% + 1800) Mod 1800
  444.             mx(x%) = delba% - scmed(x%) * 10: my(x%) = 100 + 15 * scmed(x%)
  445.             If medis(x%) < .36 Then
  446.                 If x% < nmeds% And ph% < 95 Then
  447.                     med%(x%) = 0: ph% = ph% + 35: If ph% > 98 Then ph% = 98
  448.                 End If
  449.                 If x% >= nmeds% Then
  450.                     med%(x%) = 0: ammo%(0) = ammo%(0) + 16: ammo%(1) = ammo%(1) + 100
  451.                 End If
  452.             End If
  453.             For y% = 0 To nbguysm1%
  454.                 If bgh%(y%) > 0 And robo%(y%) = 0 Then
  455.                     bsdis = (bgx(y%) - medx(x%)) * (bgx(y%) - medx(x%)) + (bgy(y%) - medy(x%)) * (bgy(y%) - medy(x%))
  456.                     If med%(x%) And bsdis < .6 And bgh%(y%) < 95 And y% <> 8 And x% < nmeds% Then
  457.                         med%(x%) = 0: bgh%(y%) = bgh%(y%) + 35: If bgh%(y%) > 98 Then bgh%(y%) = 98
  458.                     End If
  459.             End If: Next
  460.     End If: Next
  461.  
  462.  
  463. Sub onscreen
  464.     Shared bitex%, fire, sb1%(), mg%, omg%, weap$, ammo%(), oammo%(), sb2%()
  465.     Shared kills%, okills%, oofram%, ofram%
  466.  
  467.     bitex% = 1: t% = (fire > 0) * 15: hLINE 155, 166, 100, -t%
  468.     vline 160, 96, 104, 15 + t%: bitex% = 0
  469.  
  470.     'draw on screen
  471.     Wait &H3DA, 8: 'wait for screen refresh
  472.  
  473.     For x% = 0 To 159: For y% = 8 To 199
  474.         sb2%(2 + x% + 160 * (y% - 8)) = sb1%(x%, y%)
  475.     Next: Next
  476.     Put (0, 8), sb2%(), PSet
  477.  
  478.  
  479.     If mg% <> omg% Or kills% > okills% Or ammo%(mg% And 1) <> oammo%(mg% And 1) Then
  480.         Locate 1, 10: Print weap$;
  481.         Print Using " ####"; ammo%(mg% And 1);
  482.         Print Using " ammo ### "; kills%;: Print "kill";
  483.         If kills% <> 1 Then Print "s"; Else Print " ";
  484.         omg% = mg%: okills% = kills%: oammo%(mg% And 1) = ammo%(mg% And 1)
  485.     End If
  486.     If oofram% <> ofram% Then
  487.         Locate 1, 1: Print Using "### fps"; ofram%;: oofram% = ofram%
  488.     End If
  489.  
  490.  
  491. Sub paintsprites
  492.     Shared nspr%, spord%(), dis(), nbguyst2%, nbguys%, maxshots%, disi%()
  493.  
  494.     'This uses the painter's algorithm with an exchange sort to show sprites
  495.     For x% = 0 To nspr%: disi%(spord%(x%)) = dis(spord%(x%)) * 512: Next
  496.     For x% = 0 To nspr% - 1: For y% = x% + 1 To nspr%
  497.         If disi%(spord%(y%)) > disi%(spord%(x%)) Then Swap spord%(x%), spord%(y%)
  498.         Next: Next: For xx% = 0 To nspr%
  499.         If spord%(xx%) < nbguys% Then
  500.             showbadguy spord%(xx%)
  501.         ElseIf spord%(xx%) < nbguyst2% Then
  502.             showbadshot spord%(xx%) - nbguys%
  503.         ElseIf spord%(xx%) < nbguyst2% + maxshots% + 1 Then
  504.             showurshot spord%(xx%) - nbguyst2%
  505.         Else
  506.             showmed spord%(xx%) - nbguyst2% - maxshots% - 1
  507.     End If: Next xx%
  508.  
  509.  
  510. Sub putbox (x1, y1%, x2, y2%, col%, boxdis)
  511.     Shared wdis()
  512.     For x% = x1 To x2
  513.         If x% >= 0 And x% < 320 Then
  514.             If boxdis < wdis(x%) Then vline x%, y1%, y2%, col%
  515.         End If
  516.     Next
  517.  
  518. Sub putcircle (x%, y%, R%, col%, circdis)
  519.     Shared wdis()
  520.     xb% = x% - R% + 1: xt% = x% + R% - 1
  521.     If xb% > -1 And xb% < 320 Then
  522.         If circdis < wdis(xb%) Then showc% = 1
  523.     End If
  524.     If xt% > -1 And xt% < 320 Then
  525.         If circdis < wdis(xt%) Then showc% = showc% + 1
  526.     End If
  527.     If showc% = 1 Then
  528.         For xx% = xb% To xt%
  529.             If xx% > -1 And xx% < 320 Then
  530.                 If circdis < wdis(xx%) Then
  531.                     shthtx% = R% * Sqr(1 - (xx% - x%) * (xx% - x%) / R% / R%) * .8
  532.                     vline xx%, y% - shthtx%, y% + shthtx%, col%
  533.                 End If
  534.             End If
  535.         Next
  536.     ElseIf showc% = 2 Then
  537.         For xx% = xb% To xt%
  538.             shthtx% = R% * Sqr(1 - (xx% - x%) * (xx% - x%) / R% / R%) * .8
  539.             vline xx%, y% - shthtx%, y% + shthtx%, col%
  540.         Next
  541.     End If
  542.  
  543. Sub raycast
  544.     Shared wdis(), odd%(), st(), ct(), dsfc(), atx%(), hicol%(), testin%()
  545.     Shared map%(), fmap%(), cmap%(), bicol%(), sb1%(), ntx%, gm%, xb%(), yb%()
  546.     Shared sizex%, sizey%, lowcol%(), bx, by, efa%, px, py, bsa%, sa, stt(), ctt()
  547.     bx = px: by = py: efa% = (sa + 1960) Mod 1800: bsa% = sa
  548.     bxx% = bx * 256: byy% = by * 256: TIMR = Timer * 10: nttx% = 2 * ntx% + 1
  549.     sizexf% = sizex% * 256: sizeyf% = sizey% * 256
  550.  
  551.     For x% = 0 To 319
  552.         t% = (efa% + atx%(x%) + 1800) Mod 1800: xx% = x% \ 2
  553.  
  554.         If xx% = x% \ 2 Then
  555.             rxx% = bxx%: ryy% = byy%: oinx% = rxx% \ 256: oiny% = ryy% \ 256
  556.             inx% = oinx%: iny% = oiny%: ysign% = Sgn(yb%(t%)): xsign% = Sgn(xb%(t%))
  557.             ys% = (1 - ysign%) \ 2: xs% = (1 - xsign%) \ 2
  558.             yss& = ys% * 256 - byy%: xss& = xs% * 256 - bxx%
  559.  
  560.             'find dis & col
  561.             oldi: Do: rxx% = rxx% + xb%(t%): ryy% = ryy% + yb%(t%)
  562.                 oinx% = inx%: oiny% = iny%
  563.                 inx% = rxx% \ &H100: iny% = ryy% \ &H100
  564.                 k% = map%(inx%, iny%)
  565.                 chn2% = (inx% - oinx%) * xsign% + (iny% - oiny%) * ysign%
  566.             Loop Until chn2% = 2 Or k%
  567.             If chn2% = 2 Then
  568.                 kx% = map%(oinx%, iny%)
  569.                 ky% = map%(inx%, oiny%)
  570.                 If k% + kx% + ky% = 0 GoTo oldi
  571.                 tst% = xsign% * ysign% * Sgn((rxx% - bxx%) * (iny% * 256 + yss&) - (ryy% - byy%) * (inx% * 256 + xss&))
  572.                 If (tst% = 1 And k% + ky% = 0) Or (tst% <= 0 And k% + kx% = 0) GoTo oldi
  573.             End If
  574.             horz% = 0: If inx% = (rxx% - xb%(t%)) \ &H100 Then horz% = chn2% And 1
  575.  
  576.             If chn2% = 2 Then
  577.                 If tst% > 0 Then
  578.                     If ky% Then k% = ky%: iny% = oiny% Else horz% = 1
  579.                 Else
  580.                     If kx% Then horz% = 1: k% = kx%: inx% = oinx%
  581.                 End If
  582.             End If
  583.         End If
  584.  
  585.         If horz% Then
  586.             wdis(x%) = (iny% * 256 + yss&) / stt(t%)
  587.             If t% > 1780 Or t% < 20 Or (t% > 880 And t% < 920) Then
  588.                 dis = (inx% * 256 + xss&) / ctt(t%): If dis > wdis(x%) Then wdis(x%) = dis
  589.             End If
  590.             xfrac = bx + wdis(x%) * ct(t%)
  591.             bcc% = Int((xfrac - Int(xfrac)) * 63.9): If ys% = 0 Then bcc% = 63 - bcc%
  592.         Else
  593.             wdis(x%) = (inx% * 256 + xss&) / ctt(t%)
  594.             If (t% > 1330 And t% < 1370) Or (t% > 430 And t% < 470) Then
  595.                 dis = (iny% * 256 + yss&) / stt(t%): If dis > wdis(x%) Then wdis(x%) = dis
  596.             End If
  597.             xfrac = by + wdis(x%) * st(t%)
  598.             bcc% = Int((xfrac - Int(xfrac)) * 63.9): If xs% Then bcc% = 63 - bcc%
  599.         End If
  600.  
  601.         dd% = dsfc(x%) / wdis(x%): odd%(x%) = dd%
  602.  
  603.         'load view to buffer
  604.         If x% And 1 Then
  605.             afx% = ctt(t%) * dsfc(x%): afy% = stt(t%) * dsfc(x%): yt% = dd% + 1
  606.             fixfloor:
  607.             If yt% < 92 Then
  608.                 fcxp% = (bxx% + afx% \ yt%): fcyp% = (byy% + afy% \ yt%)
  609.                 If fcxp% <= 0 Or fcyp% <= 0 Or fcxp% >= sizexf% Or fcyp% >= sizeyf% Then
  610.                     sb1%(xx%, yt% + 99) = 0: sb1%(xx%, 100 - yt%) = 0: yt% = yt% + 1: GoTo fixfloor
  611.                 End If
  612.             End If
  613.             For y% = yt% To 92
  614.                 fcxp% = (bxx% + afx% \ y%): fcx% = fcxp% \ &H100
  615.                 fcyp% = (byy% + afy% \ y%): fcy% = fcyp% \ &H100
  616.                 flor% = fmap%(fcx%, fcy%)
  617.                 If flor% > 0 Then
  618.                     sb1%(xx%, y% + 99) = bicol%(flor%)
  619.                 ElseIf flor% >= -ntx% Then
  620.                     sb1%(xx%, y% + 99) = (testin%(-flor%, (fcxp% \ 4) And &H3F, (fcyp% \ 4) And &H3F) And &HFF) + hicol%(testin%(-flor%, (fcxp% \ 4) And &H3F, (fcyp% \ 4) And &H3F) And &HFF)
  621.                 Else
  622.                     flor% = -flor% - ntx% - 1
  623.                     fcxp% = (fcxp% \ 4) And &H3F: fcyp% = (fcyp% \ 4) And &H3F
  624.                     tst% = (testin%(flor%, fcxp%, fcyp%) And &HFF00)
  625.                     sb1%(xx%, y% + 99) = lowcol%((testin%(flor%, fcxp%, fcyp%) And &HFF00) \ 256) + tst%
  626.                 End If
  627.                 sb1%(xx%, 100 - y%) = bicol%(cmap%(fcx%, fcy%))
  628.             Next
  629.         End If
  630.         If k% = nttx% + 1 Then k% = 0
  631.         If k% > nttx% Then
  632.             kx% = k%: If k% = 17 Then kx% = Int(TIMR + xfrac * 40) And &HFF
  633.             yb% = 99 + dd%: If yb% > 191 Then yb% = 191
  634.             yt% = 100 - dd%: If yt% < 8 Then yt% = 8
  635.             If x% And 1 Then
  636.                 For y% = yt% To yb%: sb1%(xx%, y%) = (sb1%(xx%, y%) And &HFF) + hicol%(kx%): Next
  637.             Else
  638.                 For y% = yt% To yb%: sb1%(xx%, y%) = (sb1%(xx%, y%) And &HFF00) + kx%: Next
  639.             End If
  640.         ElseIf x% And 1 Then
  641.             If dd% > 31 Then
  642.                 hmd% = 100 - dd%: df% = (dd% + 4) \ 32: dof& = dd%: kx% = k% - ntx% - 1
  643.                 For yfrac% = 0 To 63: yt% = hmd% + (yfrac% * dof&) \ &H20: yb% = yt% + df%
  644.                     If yt% < 8 Then yt% = 8
  645.                     If yb% > &HBF Then yb% = &HBF
  646.                     If k% <= ntx% Then
  647.                         tst% = hicol%(testin%(k%, bcc%, yfrac%) And &HFF) + (testin%(k%, obcc%, yfrac%) And &HFF)
  648.                     Else
  649.                         tst% = (testin%(kx%, bcc%, yfrac%) And &HFF00) + lowcol%((testin%(kx%, obcc%, yfrac%) And &HFF00) \ 256)
  650.                     End If
  651.                 For y% = yt% To yb%: sb1%(xx%, y%) = tst%: Next: Next
  652.             Else
  653.                 yb% = 2 * dd% - 1: hmd% = 100 - dd%
  654.                 If k% <= ntx% Then
  655.                     For y% = hmd% To 99 + dd%: yfrac% = ((y% - hmd%) * 63) \ yb%
  656.                         sb1%(xx%, y%) = hicol%(testin%(k%, bcc%, yfrac%) And &HFF) + (testin%(k%, obcc%, yfrac%) And &HFF)
  657.                     Next
  658.                 Else
  659.                     kx% = k% - ntx% - 1
  660.                     For y% = hmd% To 99 + dd%: yfrac% = ((y% - hmd%) * 63) \ yb%
  661.                         sb1%(xx%, y%) = (testin%(kx%, bcc%, yfrac%) And &HFF00) + lowcol%((testin%(kx%, obcc%, yfrac%) And &HFF00) \ 256)
  662.                     Next
  663.                 End If
  664.             End If
  665.         End If
  666.     obcc% = bcc%: Next
  667.  
  668. Sub showbadguy (b%)
  669.     Shared bgh%(), scbg(), x(), y(), dis(), F0%, F1%, F2%, F3%, F4%, F5%, wdis(), robo%(), active%()
  670.     If bgh%(b%) > 0 Then
  671.  
  672.         If x(b%) >= 0 And x(b%) <= 319 Then
  673.             If dis(b%) < wdis(x(b%)) Then showb% = 1: 'active%(b%) = 1
  674.         End If
  675.         xt% = x(b%) + scbg(b%) * 40
  676.         If xt% >= 0 And xt% < 320 Then
  677.             If dis(b%) < wdis(xt%) Then showb% = 1: 'active%(b%) = 1
  678.         End If
  679.         If showb% Then
  680.             If robo%(b%) Then F1% = 7
  681.             putbox x(b%) + scbg(b%) * 16, y(b%) + 0, x(b%) + scbg(b%) * 24, y(b%) + scbg(b%) * 2, F0%, dis(b%)
  682.             putbox x(b%) + scbg(b%) * 15, y(b%) + scbg(b%) * 2, x(b%) + scbg(b%) * 25, y(b%) + scbg(b%) * 10, F1%, dis(b%)
  683.             putbox x(b%) + scbg(b%) * 10, y(b%) + scbg(b%) * 10, x(b%) + scbg(b%) * 30, y(b%) + scbg(b%) * 40, b%, dis(b%)
  684.             putbox x(b%), y(b%) + scbg(b%) * 11, x(b%) + scbg(b%) * 10, y(b%) + scbg(b%) * 20, b%, dis(b%)
  685.             putbox x(b%) + scbg(b%) * 30, y(b%) + scbg(b%) * 11, x(b%) + scbg(b%) * 40, y(b%) + scbg(b%) * 20, b%, dis(b%)
  686.             putbox x(b%), y(b%) + scbg(b%) * 20, x(b%) + scbg(b%) * 5, y(b%) + scbg(b%) * 40, b%, dis(b%)
  687.             putbox x(b%) + scbg(b%) * 35, y(b%) + scbg(b%) * 20, x(b%) + scbg(b%) * 40, y(b%) + scbg(b%) * 40, b%, dis(b%)
  688.             putbox x(b%) + scbg(b%) * 10, y(b%) + scbg(b%) * 40, x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 70, F3%, dis(b%)
  689.             putbox x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 40, x(b%) + scbg(b%) * 30, y(b%) + scbg(b%) * 70, F3%, dis(b%)
  690.             putbox x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 40, x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 50, F3%, dis(b%)
  691.             putbox x(b%) + scbg(b%) * 7, y(b%) + scbg(b%) * 70, x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 75, F4%, dis(b%)
  692.             putbox x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 70, x(b%) + scbg(b%) * 33, y(b%) + scbg(b%) * 75, F4%, dis(b%)
  693.             putbox x(b%) + scbg(b%) * 5, y(b%) + scbg(b%) * 35, x(b%) + scbg(b%) * 15, y(b%) + scbg(b%) * 40, F1%, dis(b%)
  694.             putbox x(b%) + scbg(b%) * 25, y(b%) + scbg(b%) * 35, x(b%) + scbg(b%) * 35, y(b%) + scbg(b%) * 40, F1%, dis(b%)
  695.             putbox x(b%) + scbg(b%) * 15, y(b%) + scbg(b%) * 25, x(b%) + scbg(b%) * 25, y(b%) + scbg(b%) * 35, F5%, dis(b%)
  696.             putbox x(b%) + scbg(b%) * 16, y(b%) + scbg(b%) * 3, x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 4, 0, dis(b%)
  697.             putbox x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 3, x(b%) + scbg(b%) * 24, y(b%) + scbg(b%) * 4, 0, dis(b%)
  698.             putbox x(b%) + scbg(b%) * 16, y(b%) + scbg(b%) * 4, x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 4, 7, dis(b%)
  699.             putbox x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 4, x(b%) + scbg(b%) * 24, y(b%) + scbg(b%) * 4, 7, dis(b%)
  700.             putbox x(b%) + scbg(b%) * 17, y(b%) + scbg(b%) * 4, x(b%) + scbg(b%) * 17, y(b%) + scbg(b%) * 4, 0, dis(b%)
  701.             putbox x(b%) + scbg(b%) * 23, y(b%) + scbg(b%) * 4, x(b%) + scbg(b%) * 23, y(b%) + scbg(b%) * 4, 0, dis(b%)
  702.             putbox x(b%) + scbg(b%) * 20, y(b%) + scbg(b%) * 5, x(b%) + scbg(b%) * 20, y(b%) + scbg(b%) * 6, 114, dis(b%)
  703.             putbox x(b%) + scbg(b%) * 18, y(b%) + scbg(b%) * 8, x(b%) + scbg(b%) * 22, y(b%) + scbg(b%) * 8, 4, dis(b%)
  704.             F1% = 6
  705.         End If
  706.     End If
  707.  
  708. Sub showbadshot (x%)
  709.     Shared bgsht(), bgshosht%(), bgdela%(), bgshtht%(), bgshtdis(), robo%()
  710.     If bgsht(x%) > 0 And bgshosht%(x%) Then
  711.         putcircle bgdela%(x%), 100, bgshtht%(x%), 4 + robo%(x%), bgshtdis(x%)
  712.     End If
  713.  
  714. Sub showhealth
  715.     Shared gm%, ogm%, ph%, oph%
  716.     If gm% Then ph% = 100
  717.     If ph% - oph% Or gm% - ogm% Then
  718.         For y% = 194 To 199
  719.             hLINE 0, 319 * ph% / 100, y%, 1 + 14 * gm%
  720.             hLINE 319 * ph% / 100 + 1, 319, y%, 4
  721.         Next: ogm% = gm%: oph% = ph%
  722.     End If
  723.  
  724. Sub showmed (b%)
  725.     Shared med%(), scmed(), mx(), my(), medis(), nmeds%
  726.     '    Print b%, nmeds%
  727.     If med%(b%) Then
  728.         c% = (b% < nmeds%)
  729.         putbox mx(b%) + 0, my(b%) + 0, mx(b%) + scmed(b%) * 20, my(b%) + scmed(b%) * 20, 2 - 13 * c%, medis(b%)
  730.         putbox mx(b%) + scmed(b%) * 8, my(b%) + scmed(b%) * 3, mx(b%) + scmed(b%) * 13, my(b%) + scmed(b%) * 17, 2 - 2 * c%, medis(b%)
  731.         putbox mx(b%) + scmed(b%) * 3, my(b%) + scmed(b%) * 8, mx(b%) + scmed(b%) * 17, my(b%) + scmed(b%) * 13, -4 * c%, medis(b%)
  732.     End If
  733.  
  734. Sub showurshot (x%)
  735.     Shared mg%, fb%, sht(), shosht%(), dela%(), shtdis(), shtht%(), plasma%()
  736.     If plasma%(x%) = 0 And sht(x%) > 0 And shosht%(x%) Then putcircle dela%(x%), 100 + 30 / shtdis(x%), shtht%(x%) / 3 + 1, 0, shtdis(x%)
  737.     If plasma%(x%) = 1 And sht(x%) > 0 And shosht%(x%) Then putcircle dela%(x%), 100 + 10 / shtdis(x%), shtht%(x%) * 1.5, 13, shtdis(x%)
  738.  
  739. Sub time
  740.     Shared ofram%, delta.t, fdt, kbmatrix%(), gm%, fram%
  741.     Static oldtimer&, oldtim, afram%, godit
  742.  
  743.     fram% = fram% + 1
  744.     If Int(Timer) - oldtimer& Then
  745.         ofram% = fram%: fram% = 0: oldtimer& = Int(Timer)
  746.     End If
  747.  
  748.     afram% = afram% + 1
  749.     If oldtim <> Timer Then
  750.         delta.t = delta.t * .8 + (Timer - oldtim) * .2 / afram%
  751.         oldtim = Timer: afram% = 0
  752.         If delta.t > .1 Or delta.t < 0 Then delta.t = .1
  753.         fdt = 14 * delta.t
  754.     End If
  755.  
  756.     If kbmatrix%(36) And Timer > godit Then
  757.         If gm% Then gm% = 0 Else gm% = 1: 'cheat mode
  758.         godit = (Timer + 1) Mod 86400
  759.     End If
  760.  
  761.  
  762. Sub vline (x%, yt%, yb%, c%)
  763.     Static y%, xx%
  764.     Shared sb1%(), hicol%(), odd%(), bicol%(), bitex%: xx% = x% \ 2
  765.     If yt% < 8 Then yt% = 8
  766.     If yb% > 191 Then yb% = 191
  767.     If bitex% Then
  768.         For y% = yt% To yb%: sb1%(xx%, y%) = bicol%(c%): Next
  769.     ElseIf x% And 1 Then
  770.         For y% = yt% To yb%
  771.         sb1%(xx%, y%) = (sb1%(xx%, y%) And &HFF) + hicol%(c%): Next
  772.     Else
  773.         For y% = yt% To yb%: sb1%(xx%, y%) = (sb1%(xx%, y%) And &HFF00) + c%: Next
  774.     End If
  775.  
  776. Sub yourmove
  777.     Shared kbmatrix%(), ct(), st(), efa%, shift, delta.t, fdt
  778.     Shared px, py, sa, va, vx, vy, testin%(), bx, by
  779.     If kbmatrix%(56) Then
  780.         If kbmatrix%(77) Then
  781.             vx = vx + ct((efa% + 450) Mod 1800) * shift * delta.t
  782.             vy = vy + st((efa% + 450) Mod 1800) * shift * delta.t
  783.         End If
  784.         If kbmatrix%(75) Then
  785.             vx = vx + ct((efa% + 1350) Mod 1800) * shift * delta.t
  786.             vy = vy + st((efa% + 1350) Mod 1800) * shift * delta.t
  787.         End If
  788.     Else
  789.         If kbmatrix%(77) Then va = va + shift * 90 * delta.t
  790.         If kbmatrix%(75) Then va = va - shift * 90 * delta.t
  791.     End If
  792.     If kbmatrix%(72) Then
  793.         vx = vx + ct(efa%) * shift * delta.t
  794.         vy = vy + st(efa%) * shift * delta.t
  795.     End If
  796.     If kbmatrix%(80) Then
  797.         vx = vx - ct(efa%) * shift * delta.t
  798.         vy = vy - st(efa%) * shift * delta.t
  799.     End If
  800.     svx% = Sgn(vx): svy% = Sgn(vy)
  801.     crashtest px + .15 * svx%, py + .15 * svy%, vx, vy
  802.     crashtest px - .15 * svx%, py + .15 * svy%, vx, vy
  803.     crashtest px + .15 * svx%, py - .15 * svy%, vx, vy
  804.     px = px + vx * delta.t: py = py + vy * delta.t
  805.     sa = (sa + va * delta.t) Mod 1800
  806.     damp = 2 ^ -fdt
  807.     vx = vx * damp: vy = vy * damp: va = va * damp
  808.     testin%(4, Int(bx) + 2, Int(by) + 19) = 0
  809.  
  810. Sub yourshot
  811.     Shared kbmatrix%(), nshots%, weap$, sht(), ammo%(), shosht%(), bx, by, mg%
  812.     Shared fdt, delta.t, snd%, fb%, ct(), st(), vshx(), vshy(), maxshots%
  813.     Shared sizex%, sizey%, shtx(), shty(), map%(), inx%, iny%, testin%()
  814.     Shared shtang%(), shtdis(), dis(), dela%(), shtht%(), fmap%(), efa%, sa, plasma%()
  815.     Shared nbguys%, nbguysm1%, bgh%(), bgx(), bgy(), vbx(), vby(), fire, kills%, robo%()
  816.     Static kk%
  817.  
  818.     If fire > 0 Then fire = fire - fdt * nshots%
  819.  
  820.     If kbmatrix%(2) Then mg% = 0: kk% = 0: nshots% = 1: weap$ = " plasma gun"
  821.     If kbmatrix%(3) Then mg% = 1: nshots% = 10: weap$ = "machine gun"
  822.     If kbmatrix%(4) Then mg% = 2: nshots% = 10: weap$ = "plas-cannon"
  823.  
  824.     If kbmatrix%(29) And fire <= 0 And sht(kk%) <= 0 And ammo%(mg% And 1) > 0 Then
  825.         sht(kk%) = 20: shosht%(kk%) = 1: ammo%(mg% And 1) = ammo%(mg% And 1) - 1: 'create shot
  826.         shtx(kk%) = bx: shty(kk%) = by: fire = 18: If snd% Then Sound 200, 1
  827.         vshx(kk%) = ct(efa%) * 10: vshy(kk%) = st(efa%) * 10
  828.         plasma%(kk%) = 1 - (mg% And 1)
  829.         kk% = kk% + 1: If kk% = nshots% Then kk% = 0
  830.     End If
  831.  
  832.     For x% = 0 To maxshots%
  833.         If shtx(x%) < 1 Or shtx(x%) > sizex% - 1 Or shty(x%) < 0 Or shty(x%) > sizey% - 1 Then shosht%(x%) = 0
  834.         If sht(x%) > 0 Then sht(x%) = sht(x%) - fdt
  835.         If sht(x%) > 0 And shosht%(x%) Then
  836.             crashtest shtx(x%), shty(x%), vshx(x%), vshy(x%)
  837.             k% = map%(inx%, iny%)
  838.             If k% Then shosht%(x%) = 0
  839.             shtx(x%) = shtx(x%) + vshx(x%) * delta.t: shty(x%) = shty(x%) + vshy(x%) * delta.t
  840.             If k% = 15 And sht(x%) > 0 Then
  841.                 map%(inx%, iny%) = 0
  842.                 testin%(4, inx% + 2, iny% + 19) = 0
  843.             End If
  844.  
  845.             shtang%(x%) = atan2(shty(x%) - by, shtx(x%) - bx) * 5
  846.             shtdis(x%) = Sqr((shty(x%) - by) ^ 2 + (shtx(x%) - bx) ^ 2 + .01)
  847.             dis(x% + nbguys% * 2) = shtdis(x%)
  848.             dela%(x%) = (shtang%(x%) - sa + 1800) Mod 1800
  849.             shtht%(x%) = 30 / shtdis(x%)
  850.  
  851.             'damage test
  852.             For y% = 0 To nbguysm1%
  853.                 bsdis = (shty(x%) - bgy(y%)) * (shty(x%) - bgy(y%)) + (shtx(x%) - bgx(y%)) * (shtx(x%) - bgx(y%))
  854.                 If bsdis < .36 And bgh%(y%) > 0 Then
  855.                     If bsdis < .16 Then bgh%(y%) = bgh%(y%) - sht(x%) / 2 - 5: shosht%(x%) = 0
  856.                     'vbx(y%) = vbx(y%) + vshx(x%) * .1: vby(y%) = vby(y%) + vshy(x%) * .1
  857.                     If plasma%(x%) Then
  858.                         bgh%(y%) = bgh%(y%) - sht(x%) * 1.5 - 50: shosht%(x%) = 0
  859.                         'vbx(y%) = vbx(y%) + vshx(x%) * .5: vby(y%) = vby(y%) + vshy(x%) * .5
  860.                     End If
  861.                     If bgh%(y%) < 1 Then
  862.                         fmap%(Int(bgx(y%)), Int(bgy(y%))) = 4 + 4 * robo%(y%): kills% = kills% + 1
  863.                         If snd% Then Sound 180, 5
  864.                     End If
  865.             End If: Next
  866.     End If: Next
  867.     'If sht(0) < 0 Then fb% = 0
  868.  
  869.  
  870. Sub keys
  871.     Shared kbmatrix%()
  872.     i% = Inp(96): i$ = InKey$: kbmatrix%(i% And 127) = -(i% < 128)
  873.  
Pages: 1 ... 3 4 [5] 6 7 ... 10