Advertisement
kbmonkey

starship (TIC-80 source)

Jul 31st, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.67 KB | None | 0 0
  1. -- title:  starship
  2. -- author: wesley werner
  3. -- desc:   for ludum dare #39, theme:
  4. --          running out of power.
  5. --       you pilot a starship and recharge
  6. --       your fuel cells from solar radiation.
  7. --       z: shields
  8. --   x: fire phasers
  9. -- script: lua
  10.  
  11. IDDQD=false
  12.  
  13. -- screen size in pixels
  14. MAP_W=240
  15. MAP_H=136
  16.  
  17. -- screen size in map cells
  18. CELLS_W=MAP_W/8
  19. CELLS_H=MAP_H/8
  20.  
  21. -- other wessels in play
  22. MAX_WESSELS=30
  23.  
  24. -- minimum distance for attack
  25. FIRING_RANGE=4
  26.  
  27. SFX_BEAM=4
  28. SFX_CHARGE=2
  29. SFX_EXPLODE=3
  30.  
  31. -- ticks to pass before closing a message box
  32. READ_TIMEOUT=100
  33.  
  34. t=0
  35.  
  36. -- variables
  37. state="intro"
  38. mapx=90
  39. mapy=50
  40. wessels={}
  41. plr=nil
  42. stars={}
  43. suns=nil
  44. hazards={}
  45. planets=nil
  46. mission=nil
  47.  
  48. -- each new mission destination planet
  49. -- gets a name and this list is reduced.
  50. -- when all names are used up the game
  51. -- is won. there is a chance that a
  52. -- planet is called upon again, in that
  53. -- case the names list is not reduced.
  54. planet_names={
  55.  "Hadrian",
  56.  "Knara Prime",
  57.  "Frixion Prime",
  58.  "Epona",
  59.  "Zelos",
  60.  "Carina 3",
  61.  "Vendrizi 9",
  62.  "Beta Atheni",
  63.  "Helion 8",
  64.  "Arkanna",
  65. }
  66.  
  67. mission_types={
  68.  {note="escort ambassador Spock",
  69.      result="He says to live long and prosper"},
  70.     {note="transport some medical supplies",
  71.      result="You join them in a celebratory meal"},
  72.     {note="deliver much needed vacines",
  73.      result="The planet rejoyces at your arrival"},
  74.     {note="deliver sealed containers",
  75.      result="You get a brief thanks"},
  76.     {note="escort admiral kurtz",
  77.      result="You receive his gratitude"},
  78.     {note="transport plasma infusers",
  79.      result="You feel pretty good about it"},
  80.     {note="escort ambassador Sarek",
  81.      result="He asks somberly about Spock"},
  82.     {note="deliver some food rations",
  83.      result="You are praised for your effort"},
  84.     {note="locate missing commander Data",
  85.      result="He was rescued from mercinaries"},
  86. }
  87.    
  88.  
  89. function init_wessels()
  90.  -- define the wessels in play.
  91.     -- the player is wessel 1 and has a
  92.     -- unique position - it stays centred
  93.     wessels[1]={
  94.         sprite=256,
  95.         x=105,  -- position in map coords
  96.         y=60,
  97.         speed=1,    -- move speed
  98.         xvel=0, -- movement velocity
  99.         yvel=0,
  100.         power=100
  101.         }
  102.  
  103.  --AI WESSELS
  104.     for i=2,MAX_WESSELS do
  105.         wessels[i]={
  106.             sprite=272,
  107.             x=math.floor(math.random()*MAP_W),
  108.             y=math.floor(math.random()*MAP_H),
  109.             speed=0.1,  -- move speed
  110.             xvel=0, -- movement velocity
  111.             yvel=0,
  112.             power=50
  113.             }
  114.     end
  115.    
  116. end
  117.  
  118.  
  119. function init_player()
  120.  
  121.     plr=wessels[1]
  122.  
  123. end
  124.  
  125.  
  126. function init_hazards()
  127.  
  128.     -- define hazardous tiles
  129.    
  130.     -- speed=factor (0 blocks)
  131.    
  132.     local ice={
  133.         name="ice nebula",
  134.         speed=0.5,
  135.         }
  136.  
  137.     local fire={
  138.         name="fire nebula",
  139.         speed=0.2,
  140.         }
  141.    
  142.     local elec={
  143.      name="electric nebula",
  144.         speed=0.7,
  145.         }
  146.  
  147.     hazards={
  148.      [145]=ice,
  149.      [160]=ice,
  150.      [161]=ice,
  151.      [162]=ice,
  152.      [177]=ice,
  153.  
  154.         [148]=fire,
  155.         [163]=fire,
  156.         [164]=fire,
  157.         [165]=fire,
  158.         [180]=fire,
  159.  
  160.   [151]=elec,
  161.   [166]=elec,
  162.   [167]=elec,
  163.   [168]=elec,
  164.   [183]=elec,
  165.  
  166.     }
  167.  
  168. end
  169.  
  170.  
  171. function engage()
  172.  trace("warp factor 5 engage!")
  173.  init_planets()
  174.     init_suns()
  175.     init_stars()
  176.     init_wessels()
  177.     init_player()
  178.     init_hazards()
  179. end
  180.  
  181.  
  182. function init_stars()
  183.  local n=30
  184.  for i=1,n do
  185.      stars[i]={
  186.                 x=math.random() * MAP_W,
  187.                 y=(i/n) * MAP_H,
  188.                 c=i%4==0 and 2 or i%9==0 and 8 or 3
  189.         }
  190.  end
  191. end
  192.  
  193.  
  194. function init_planets()
  195.  
  196.  -- catalogue planets on the map
  197.     planets={}
  198.    
  199.     local sprites={
  200.      [48]=true,
  201.      [50]=true,
  202.      [52]=true,
  203.      [54]=true,
  204.      [56]=true,
  205.      [58]=true
  206.     }
  207.  
  208.     for x=1,MAP_W do
  209.      for y=1,MAP_H do
  210.          local i=mget(x,y)
  211.             if sprites[i] then
  212.              table.insert(planets,{x=x,y=y,name=name})
  213.             end
  214.      end
  215.     end
  216.    
  217. end
  218.  
  219.  
  220. function init_suns()
  221.  
  222.  -- catalogue suns on the map
  223.     suns={}
  224.  
  225.     local sprites={
  226.      [16]=true,
  227.         [18]=true,
  228.         [20]=true,
  229.         [22]=true,
  230.         [24]=true,
  231.         [26]=true,
  232.         [28]=true,
  233.     }
  234.                    
  235.     for x=1,MAP_W do
  236.      for y=1,MAP_H do
  237.          local i=mget(x,y)
  238.             if sprites[i] then
  239.              table.insert(suns,{x=x,y=y,power=100})
  240.             end
  241.      end
  242.     end
  243.    
  244. end
  245.  
  246.  
  247. function update_suns()
  248.  -- suns generate power
  249.  if t%30==0 then
  250.      for k,v in pairs(suns) do
  251.          if v.power<100 then
  252.              v.power = v.power+1
  253.             end
  254.     end
  255.  end
  256. end
  257.  
  258.  
  259. function update_stars()
  260.  
  261.     for k,v in pairs(stars) do
  262.  
  263.      -- move as parallax to luminosity
  264.         v.x = v.x - (v.c * plr.xvel * 0.01)
  265.         v.y = v.y - (v.c * plr.yvel * 0.01)
  266.        
  267.         -- wrap stars
  268.         if v.x<0 then
  269.             v.x=MAP_W
  270.         elseif v.x>MAP_W then
  271.          v.x=0
  272.         end
  273.         if v.y<0 then
  274.          v.y=MAP_H
  275.         elseif v.y>MAP_H then
  276.          v.y=0
  277.         end
  278.  
  279.     end
  280.  
  281. end
  282.  
  283.  
  284. function draw_sunpower()
  285.     for k,v in pairs(suns) do
  286.      if v.power>0 and in_view(v.x,v.y) then
  287.          local color=14+(t%60)/30
  288.             local x=8*(v.x-mapx+0.9)
  289.             local y=8*(v.y-mapy+1.5)
  290.             local radius=(v.power/100)*8+8
  291.       circb(x,y,radius,color)
  292.         end
  293.     end
  294. end
  295.  
  296.  
  297. function draw_stars()
  298.  for k,v in pairs(stars) do
  299.      pix(v.x, v.y, v.c)
  300.     end
  301. end
  302.  
  303.  
  304. function handle_input()
  305.  
  306.  if state=="play" then
  307.  
  308.     local delay = 6
  309.    
  310.         -- move left or right
  311.         if btn(2) then
  312.             plr.xvel=-plr.speed
  313.         elseif btn(3) then
  314.          plr.xvel=plr.speed
  315.         else
  316.          plr.xvel=0
  317.         end
  318.    
  319.      -- move up or down
  320.         if btn(0) then
  321.             plr.yvel=-plr.speed
  322.         elseif btn(1) then
  323.          plr.yvel=plr.speed
  324.         else
  325.          plr.yvel=0
  326.         end
  327.        
  328.         -- firing
  329.         if btn(5) then
  330.          plr.firing=true
  331.          plr.shielded=false
  332.         elseif btn(4) then
  333.          plr.shielded=true
  334.          plr.firing=false
  335.         else
  336.          plr.shielded=false
  337.             plr.firing=false
  338.         end
  339.  
  340.     elseif state=="mission review" then
  341.  
  342.         if t>READ_TIMEOUT then
  343.          if btn()~=0 then
  344.           state="play"
  345.          end
  346.         end
  347.        
  348.     elseif state=="mission success" then
  349.  
  350.         if t>READ_TIMEOUT then
  351.          if btn()~=0 then
  352.              mission=nil
  353.                 -- no more planet names left for
  354.                 -- missions means game win!
  355.                 if #planet_names==0 then
  356.                  state="win"
  357.                 else
  358.            state="play"
  359.                 end
  360.          end
  361.         end
  362.  
  363.  elseif state=="intro" then
  364.         if t>READ_TIMEOUT then
  365.          if btn()~=0 then
  366.        state="play"
  367.             end
  368.         end
  369.  end
  370.  
  371. end
  372.  
  373.  
  374. function track_map()
  375.  
  376.  -- map tracks the player
  377.     if plr.xvel or plr.yvel then
  378.         mapx=math.floor(plr.x)-(CELLS_W/2)%MAP_W
  379.         mapy=math.floor(plr.y)-(CELLS_H/2)%MAP_H
  380.     end
  381.  
  382. end
  383.  
  384.  
  385. -- WESSEL MOVEMENT
  386. function update_wessels()
  387.  
  388.  if t%10==0 then
  389.  
  390.      for i=#wessels,1,-1 do
  391.            
  392.             local v=wessels[i]
  393.            
  394.             if i>1 then
  395.              move_ai(v)
  396.                 if v.destroyed then
  397.                  table.remove(wessels,i)
  398.                     sfx(SFX_EXPLODE,"C-2",60)
  399.                 end
  400.             end
  401.            
  402.             local x = v.x
  403.             local y = v.y
  404.    
  405.       -- accelerate the wessel
  406.             x=(x+v.xvel)%MAP_W
  407.             y=(y+v.yvel)%MAP_H
  408.            
  409.             -- store orientation
  410.             if v.xvel~=0 then
  411.                 v.orient = v.xvel<0 and 1 or 0
  412.             end
  413.            
  414.          -- check for blocker sprites
  415.             local m=mget(x,y)
  416.             local hazard = hazards[m]
  417.            
  418.             if hazard then
  419.              v.hazard_note=hazard.name
  420.                 if hazard.speed == 0 then
  421.                  -- blocks movement
  422.                     v.xvel = 0
  423.                     v.yvel = 0
  424.                     x = v.x
  425.                     y = v.y
  426.                 elseif hazard.speed then
  427.                  -- affects movement
  428.            x = v.x + (v.xvel * hazard.speed)
  429.            y = v.y + (v.yvel * hazard.speed)
  430.                 end
  431.             else
  432.              v.hazard_note=nil
  433.             end
  434.    
  435.                 v.x=x
  436.                 v.y=y
  437.        
  438.         end
  439.        
  440.     end
  441.  
  442. end
  443.  
  444.  
  445. function move_ai(wessel)
  446.  
  447.  local r=math.random()
  448.    
  449.     -- random movement
  450.     if r<0.1 then
  451.      wessel.xvel=math.random(-1,1)
  452.     elseif r>0.9 then
  453.      wessel.yvel=math.random(-1,1)
  454.     end
  455.    
  456.     -- attacks
  457.     local d=dist(wessel.x,wessel.y,plr.x,plr.y)
  458.     if d<FIRING_RANGE then
  459.      -- in firing range
  460.      wessel.firing=true
  461.  
  462.         -- player takes damage
  463.         if not plr.shielded then
  464.             plr.power=plr.power-5
  465.         end
  466.  
  467.         -- enemy takes damage
  468.         if plr.firing==true then
  469.          wessel.power=wessel.power-5
  470.         end
  471.  
  472.         -- enemy destroyed
  473.         if wessel.power<0 then
  474.          wessel.destroyed=true
  475.         end
  476.  
  477.         -- play sound
  478.         if plr.firing then
  479.             sfx(SFX_BEAM,"C-5",20)
  480.         else
  481.             sfx(SFX_BEAM,"C-4",20)
  482.         end
  483.  
  484.     else
  485.      wessel.firing=false
  486.        
  487.     end
  488.  
  489. end
  490.  
  491.  
  492. function draw_wessels()
  493.    
  494.     -- draw relative to map position
  495.     for i,v in ipairs(wessels) do
  496.  
  497.      if in_view(v.x, v.y) then
  498.  
  499.          -- wessel sprite
  500.             spr(v.sprite,
  501.                 screenx(v.x),
  502.                 screeny(v.y),
  503.                 0,  -- colorkey
  504.                 2,  -- scale
  505.                 v.orient)
  506.            
  507.             -- enemy wessel is firing
  508.          if i>1 then
  509.                 if v.firing==true then
  510.            
  511.              line(
  512.                      screenx(v.x)+4,
  513.                         screeny(v.y)+4,
  514.                         screenx(plr.x)+4,
  515.                         screeny(plr.y)+4,
  516.                         (t%10)/5+13)
  517.  
  518.                     -- wessel health bar
  519.                     rectb(
  520.                      screenx(v.x),
  521.                         screeny(v.y),
  522.                         math.max(1,16*(v.power/100)),
  523.                         2,
  524.                         9)
  525.                    
  526.                     -- draw player shield hit
  527.                     if plr.shielded then
  528.                      circb(
  529.                          screenx(plr.x)+8,
  530.                             screeny(plr.y)+8,
  531.                             (t%10)/5+12,
  532.                             11)
  533.  
  534.                     end
  535.                 end
  536.             end
  537.  
  538.         end
  539.        
  540.     end
  541.  
  542. end
  543.  
  544.  
  545. function screenx(n)
  546.  -- converts a map tile to screen coord
  547.     return 8*(n-mapx)
  548. end
  549.  
  550.  
  551. function screeny(n)
  552.  -- converts a map tile to screen coord
  553.     return 8*(n-mapy)
  554. end
  555.  
  556.  
  557. function draw_map()
  558.  
  559.     map(mapx,mapy,
  560.         30, -- width
  561.         17, -- height
  562.         0,  -- offset x and y
  563.         0,
  564.         0        -- colorkey
  565.     )
  566.  
  567. end
  568.  
  569.  
  570. function draw_sector()
  571.  
  572.  local x=math.floor((mapx+(CELLS_W/2)%240)/30)+1
  573.     local y=math.floor((mapy+(CELLS_H/2)%136)/17)+1
  574.  print("SECT "..x..":"..y,160,0,7)
  575.    
  576.     -- minimap
  577.     spr(266,220,0)
  578.     spr(267,228,0)
  579.     spr(282,220,8)
  580.     spr(283,228,8)
  581.     pix(218+(16*x/8),(16*y/8)-2,15)
  582.    
  583.     -- mission sector
  584.     if mission then
  585.      pix(mission.mapx,mission.mapy,6)
  586.     end
  587.    
  588. end
  589.  
  590.  
  591. function draw_powerbar()
  592.  
  593.  local pwr=(plr.power/100)*12
  594.     local color=8
  595.  
  596.     if plr.charging then
  597.         -- charging
  598.         color=11
  599.         print("+",0,1)
  600.     elseif plr.power<30 then
  601.         -- warning
  602.         color=6
  603.         print("!",0,(t%60)/30+1)
  604.     end
  605.  
  606.  -- battery
  607.  spr(270,8,0,0)
  608.  spr(271,16,0,0)
  609.     rect(9,2,pwr,4,color)
  610.    
  611.     -- shields
  612.     if not plr.shielded then
  613.     spr(268,26,0,0)
  614.     else
  615.     spr(269,26,0,0)
  616.     end
  617.  
  618.     -- weapons
  619.     if not plr.firing then
  620.     spr(284,36,0,0)
  621.     else
  622.     spr(285,36,0,0)
  623.     end
  624.  
  625.     -- print hazard note
  626.     if plr.hazard_note and t%60>30 then
  627.      print(plr.hazard_note,50,0,6)
  628.     end
  629.  
  630. end
  631.  
  632.  
  633. function dist(ax,ay,bx,by)
  634.  local dx=math.pow(ax-bx,2)
  635.  local dy=math.pow(ay-by,2)
  636.  return math.sqrt(dx+dy)
  637. end
  638.  
  639.  
  640. function update_poweruse()
  641.  
  642.  -- player is on a sun
  643.     if t%30==0 and plr.power<100 then
  644.      plr.charging=false
  645.      for k,sun in pairs(suns) do
  646.          if sun.power>0 then
  647.                 if in_view(sun.x, sun.y) then
  648.                  -- player is near this sun
  649.                  local d=dist(sun.x,sun.y,plr.x,plr.y)
  650.                     if d<2 then
  651.                      plr.power=plr.power+8
  652.                         sun.power=sun.power-8
  653.                         plr.charging=true
  654.                         sfx(SFX_CHARGE,"E-1",80)
  655.                         -- set sun cooldown
  656.                         if sun.power<0 then
  657.                          sun.power=-100
  658.                         end
  659.                     end
  660.           end
  661.             end
  662.         end
  663.     end
  664.    
  665.  -- reduce player power while moving
  666.     if t%10==0 and plr.power>0 then
  667.      if plr.xvel~=0 or plr.yvel~=0 then
  668.          plr.power = plr.power-1
  669.         end
  670.     end
  671.    
  672.     -- shielding and firing
  673.     if t%10==0 then
  674.      if plr.shielded==true then
  675.       plr.power=plr.power-0.3
  676.         elseif plr.firing==true then
  677.       plr.power=plr.power-0.3
  678.         end
  679.     end
  680.    
  681.     -- death
  682.     if plr.power<=0 then
  683.      state="dead"
  684.         sfx(SFX_EXPLODE,"C-2",120)
  685.     end
  686.  
  687. end
  688.  
  689.  
  690. function in_view(x, y)
  691.  
  692.  -- returns if the points are in view
  693.  local dx = x-mapx
  694.     local dy = y-mapy
  695.  
  696.     return dx>-3 and dx <CELLS_W and
  697.         dy>=-3 and dy<CELLS_H
  698.  
  699. end
  700.  
  701.  
  702. function draw_gameover()
  703.  local x=MAP_W/4
  704.     local y=MAP_H/3
  705.  print("GAME OVER",x+1,y,2,false,2)
  706.  print("GAME OVER",x,y,15,false,2)
  707.  print("You ran out of power!",x+1,y*2,1)
  708.  print("You ran out of power!",x,y*2,15)
  709. end
  710.  
  711.  
  712. function near_planet()
  713.  
  714.  -- gets a nearby planet
  715.     for k,v in pairs(planets) do
  716.   if in_view(v.x,v.y) then
  717.          local d=dist(v.x,v.y,plr.x,plr.y)
  718.             if not v.visited and d<2 then
  719.              return v
  720.             end
  721.         end
  722.  end
  723.  
  724. end
  725.  
  726.  
  727. function far_planet()
  728.  
  729.  -- gets a remotely far planet
  730.     local plan=nil
  731.    
  732.     while not plan do
  733.      plan=planets[math.random(#planets)]
  734.      local d=dist(plan.x,plan.y,plr.x,plr.y)
  735.         if plan.visited or d<10 then
  736.          plan=nil
  737.         end
  738.     end
  739.    
  740.     return plan
  741.    
  742. end
  743.  
  744.  
  745. function update_mission()
  746.  
  747.  -- reduce processing
  748.     if t%100~=0 then return end
  749.    
  750.  -- find nearby planet
  751.     local planet=near_planet()
  752.    
  753.     if planet and mission then
  754.  
  755.     -- test mission success
  756.         if mission.planet==planet.name then
  757.          -- visited planets don't offer new missions
  758.          planet.visited=true
  759.             -- reset t: it controls input timeout
  760.             state="mission success"
  761.             t=0
  762.         end
  763.        
  764.     elseif planet and not mission then
  765.        
  766.         -- get a new mission
  767.         mission=mission_types[math.random(#mission_types)]
  768.        
  769.         -- to a remote planet
  770.         local dest=far_planet()
  771.        
  772.         -- that should have a name
  773.         if not dest.name then
  774.          dest.name=table.remove(planet_names)
  775.         end
  776.        
  777.         -- precalculate mission destination
  778.         -- on minimap
  779.      local mapx=math.floor(dest.x/30)+1
  780.         local mapy=math.floor(dest.y/17)+1
  781.         mapx=(16*mapx/8)+218
  782.         mapy=(16*mapy/8)-2
  783.  
  784.         mission.planet=dest.name
  785.         state="mission review"
  786.         mission.mapx=mapx
  787.         mission.mapy=mapy
  788.        
  789.         -- reset t: it controls input timeout
  790.         t=0
  791.    
  792.     end
  793.    
  794. end
  795.  
  796.  
  797. function draw_missionbar()
  798.  
  799.  -- draw current mission on screen
  800.     if mission then
  801.      printc(mission.note,120,130,3)
  802.     end
  803.    
  804. end
  805.  
  806.  
  807. function draw_box()
  808.      rect(10,10,220,126,1)
  809.      rectb(10,10,220,126,2)
  810. end
  811.  
  812.  
  813. function draw_mission_review()
  814.  
  815.  -- draw a mission review box
  816.     if mission then
  817.      draw_box()
  818.      printc("NEW MISSION:",120,20,15)
  819.      printc(mission.note,120,60,8)
  820.      printc("destination: "..mission.planet,120,70,10)
  821.   if t>READ_TIMEOUT then
  822.       printc("press any key",120,120,7)
  823.         end
  824.  end
  825.  
  826. end
  827.  
  828.  
  829. function draw_mission_success()
  830.  
  831.  -- draw a mission success box
  832.     if mission then
  833.      draw_box()
  834.      printc("MISSION SUCCESS!",120,20,15)
  835.      printc(mission.note,120,40,8)
  836.      printc("to "..mission.planet,120,50,10)
  837.      printc(mission.result,120,70,8)
  838.   if t>READ_TIMEOUT then
  839.       printc("press any key",120,120,7)
  840.         end
  841.  end
  842.  
  843. end
  844.  
  845.  
  846. --Prints text where x is the center of text.
  847. function printc(s,x,y,c)
  848.  local w=print(s,0,-8)
  849.  print(s,x-(w/2),y,c or 15)
  850. end
  851.  
  852.  
  853. function draw_winscreen()
  854.  draw_box()
  855.  printc("After a long journey exploring",120,20,15)
  856.  printc("the galaxy, you retire on the",120,30,15)
  857.  printc("Eden planet, living in comfort",120,40,15)
  858.  printc("while everyone delivers fresh",120,50,15)
  859.  printc("fruit and craft cheeses to you.",120,60,15)
  860.  printc("Ah this is the life!",120,70,14)
  861.  printc("Created by wesley for Ludum Dare #39",120,80,13)
  862.  printc("press ctrl-r to play again",120,128,7)
  863.  
  864.  -- wessel sprite
  865.     spr(plr.sprite,
  866.         100,
  867.         80,
  868.         0,  -- colorkey
  869.         6,  -- scale
  870.         plr.orient)
  871.  
  872. end
  873.  
  874.  
  875. function draw_intro()
  876.  
  877.  draw_box()
  878.  printc("Welcome!",120,20,15)
  879.  printc("You are a starship captain, you explore",120,30,15)
  880.  printc("the galaxy and help others on the way.",120,40,15)
  881.  printc("Z key - engage shields",120,50,8)
  882.  printc("X key - fire phasers (auto aims)",120,60,8)
  883.  printc("Fly over suns to recharge your power",120,70,14)
  884.  printc("Dock at planets to complete missions",120,80,14)
  885.  printc("You retire after 10 missions",120,90,15)
  886.  printc("restart the game with ctrl-R",120,100,15)
  887.  printc("Created by wesley for Ludum Dare #39",120,110,13)
  888.  printc("press any key",120,120,7)
  889.  
  890.  -- shield sprite
  891.     spr(269,190,48,0,1)
  892.  -- weapons sprite
  893.     spr(285,210,58,0,1)
  894.  
  895. end
  896.  
  897.  
  898. function TIC()
  899.  
  900.     cls(0)
  901.  
  902.     handle_input()
  903.  
  904.  if state=="play" then
  905.      update_wessels()
  906.         update_stars()
  907.         update_suns()
  908.         track_map()
  909.         update_poweruse()
  910.         update_mission()
  911.         if IDDQD then plr.power=100 end
  912.     end
  913.  
  914.     draw_stars()
  915.     draw_sunpower()
  916.     draw_map()
  917.     draw_wessels()
  918.     draw_powerbar()
  919.     draw_missionbar()
  920.     draw_sector()
  921.  
  922.     if state=="mission review" then
  923.      draw_mission_review()
  924.     elseif state=="mission success" then
  925.      draw_mission_success()
  926.     elseif state=="dead" then
  927.      draw_gameover()
  928.     elseif state=="win" then
  929.      draw_winscreen()
  930.     elseif state=="intro" then
  931.      draw_intro()
  932.     end
  933.  
  934.     t=t+1
  935. end
  936.  
  937. engage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement