SHARE
TWEET

Swoosh

Drablos Jan 11th, 2012 283 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diffsettings = {
  2. {240, 32},
  3. {280, 22},
  4. {310, 18},
  5. {330, 12},
  6. {350, 10},
  7. {370, 7},
  8. {390, 6},
  9. {400, 5},
  10. {420, 5},
  11. {450, 5}
  12. }
  13.  
  14. function setup()
  15.     displayMode(FULLSCREEN_NO_BUTTONS)
  16.     diff = 1
  17.     nextdiff = 1200
  18.     state = "intro"
  19.     lives = 2
  20.     points = 0
  21.    
  22.     debug = false
  23.     showfps = false
  24.     frames = {}
  25.    
  26.     streaks = Streaks()
  27.     ship = Ship()
  28.     rocks = Rocks()
  29.     font = Font()
  30.     pickups = Pickups()
  31.    
  32.     ship.py = 0 - ship.height
  33.    
  34.     rockspeed = diffsettings[1][1]
  35.     rocks.newrock = diffsettings[1][2]
  36. end
  37.  
  38. function draw()
  39.     background(0, 0, 0)
  40.     noSmooth()
  41.    
  42.     if debug then
  43.         translate(0.25 * WIDTH, 0.25 * HEIGHT)
  44.         scale(0.5, 0.5)
  45.        
  46.         pushStyle()
  47.         fill(255, 255, 255, 10)
  48.         rect(0, 0, WIDTH, HEIGHT)
  49.         popStyle()
  50.     end
  51.    
  52.     if showfps then
  53.         table.insert(frames, DeltaTime)
  54.        
  55.         t = 0
  56.         fps = 0
  57.         longest = 0
  58.         for i,v in ipairs(frames) do
  59.             t = t + v
  60.             fps = fps + 1
  61.             if v > longest then
  62.                 longest = v
  63.             end
  64.         end
  65.         for i,v in ipairs(frames) do
  66.             if t < 1 then
  67.                 break
  68.             end
  69.             t = t - v
  70.             table.remove(frames, i)
  71.         end
  72.        
  73.         strokeWidth(1)
  74.         stroke(255, 255, 255, 255)
  75.         font:drawstring(""..fps, WIDTH - 50, HEIGHT - 200)
  76.         font:drawstring(""..longest*1000, WIDTH - 50, HEIGHT - 250)
  77.         font:drawstring(""..diff, WIDTH - 50, HEIGHT - 300)
  78.     end
  79.    
  80.     if state == "intro" then
  81.         if ship.py < 60 then
  82.             ship.py = ship.py + 1
  83.         else
  84.             state = "play"
  85.         end
  86.     end
  87.    
  88.     streaks:draw()
  89.     rocks:draw()
  90.     pickups:draw()
  91.     ship:draw()
  92.    
  93.     --font:drawstring(""..lives, 50, HEIGHT - 50)
  94.    
  95.     if state == "intro" then
  96.         pushStyle()
  97.         strokeWidth(2)
  98.         scale(2)
  99.         font:drawstring("SWOOSH", WIDTH/4 - 60, HEIGHT/4)
  100.         scale(1)
  101.         popStyle()
  102.     end
  103.     if state == "play" then
  104.         pushStyle()
  105.         stroke(82, 69, 31, 255)
  106.         fill(126, 106, 49, 200)
  107.         strokeWidth(2)
  108.         rectMode(CORNER)
  109.         rect(-10, HEIGHT - 90, 25 + 50 * lives, 70)
  110.         rect(WIDTH - 100, HEIGHT - 90, 130, 70)
  111.         fill(182, 157, 105, 120)
  112.         stroke(155, 130, 57, 255)
  113.         rect(WIDTH - 95, HEIGHT - 85, 130, 60)
  114.         pushStyle()
  115.         smooth()
  116.         stroke(91, 65, 29, 255)
  117.         strokeWidth(5)
  118.         font:drawstring(""..points, WIDTH - 80, HEIGHT - 65)
  119.         stroke(0, 0, 0, 255)
  120.         noSmooth()
  121.         strokeWidth(2)
  122.         font:drawstring(""..points, WIDTH - 80, HEIGHT - 65)        
  123.         popStyle()
  124.         for i = 1,lives do
  125.             sprite("Tyrian Remastered:Icon Ship Glow", 50*i - 20, HEIGHT - 55, 38, 44)
  126.         end
  127.         rect(-10, HEIGHT - 85, 20 + 50 * lives, 60)
  128.         popStyle()
  129.         noSmooth()
  130.     end
  131.     if state == "gameover" then
  132.         font:drawstring("YOU GOT "..finalpoints.." POINTS", WIDTH/2 - 190, HEIGHT/2 - 80)
  133.         pushStyle()
  134.         strokeWidth(2)
  135.         scale(2)
  136.         font:drawstring("GAME OVER", WIDTH/4 - 100, HEIGHT/4)
  137.         scale(1)
  138.         popStyle()
  139.     end
  140.  
  141.     for i,v in ipairs(rocks.rocks) do
  142.         if vec2(v.px, v.py):dist(vec2(ship.px, ship.py)) < v.width/2+ship.width/2  and ship.crashed == false and ship.invulnerable < 1 then
  143.             ship.crashed = true
  144.             sound(SOUND_EXPLODE, 25)
  145.             explosion = Explosion(vec2(ship.px, ship.py))
  146.             if diff > 1 then
  147.                 diff = diff - 2
  148.                 nextdiff = 2
  149.             end
  150.         end
  151.     end
  152.     for i,v in ipairs(pickups.pickups) do
  153.         if vec2(v.px, v.py):dist(vec2(ship.px, ship.py)) < v.w/2+ship.width/2  and ship.crashed == false then
  154.             if v.type == "gem" then
  155.                 sound(SOUND_PICKUP, 82)
  156.                 points = points + 9 + diff
  157.             end
  158.             table.remove(pickups.pickups, i)
  159.         end
  160.     end
  161.     if ship.crashed and state == "play" then
  162.         explosion:draw()
  163.         if explosion:isDone() then
  164.             explosion = ""
  165.             if lives > 0 then
  166.                 ship.crashed = false
  167.                 ship.invulnerable = 150
  168.                 lives = lives - 1
  169.             else
  170.                 finalpoints = points
  171.                 state = "gameover"
  172.             end
  173.         end
  174.     end
  175.     if nextdiff > 1 then
  176.         nextdiff = nextdiff - 1
  177.     else
  178.         if diff < table.maxn(diffsettings) then
  179.             diff = diff + 1
  180.         end
  181.         points = points + diff * 5
  182.         rockspeed = diffsettings[diff][1]
  183.         rocks.newrock = diffsettings[diff][2]
  184.         nextdiff = 1200
  185.     end
  186. end
  187.  
  188. pickuptypes = {
  189. gem = {38, 54}
  190. }
  191.  
  192. Pickups = class()
  193.  
  194. function Pickups:init()
  195.     self.pickups = {}
  196.     self.newgem = math.random(250, 400)
  197.     self.nextgem = self.newgem
  198. end
  199.  
  200. function Pickups:draw()
  201.     if self.nextgem < 1 then
  202.         table.insert(self.pickups, Pickup("gem", pickuptypes["gem"][1], pickuptypes["gem"][2]))
  203.         self.nextgem = math.random(150, 400)
  204.     else
  205.         self.nextgem = self.nextgem - 1
  206.     end
  207.     for i,v in ipairs(self.pickups) do
  208.         v:draw()
  209.     end
  210.     for i,v in ipairs(self.pickups) do
  211.         if v.py < 0 - v.h/2 then
  212.             table.remove(self.pickups, i)
  213.         end
  214.     end
  215. end
  216.  
  217. Pickup = class()
  218.  
  219. function Pickup:init(type, w, h)
  220.     self.type = type
  221.     self.w = w
  222.     self.h = h
  223.     self.px = math.random(0 + self.w, WIDTH - self.w)
  224.     self.py = HEIGHT+self.h/2
  225.     self.akey = 1
  226. end
  227.  
  228. function Pickup:draw()
  229.     self.py = self.py - rockspeed*DeltaTime
  230.     if self.type == "gem" then
  231.         if self.akey >= 2 and self.akey <= 12 then
  232.             sprite("Tyrian Remastered:Gem Shine "..math.ceil(self.akey/2), self.px, self.py, self.w, self.h)
  233.         else
  234.             sprite("Tyrian Remastered:Gem Shine "..1, self.px, self.py, self.w, self.h)
  235.         end
  236.     end
  237.     self.akey = self.akey + 1
  238.     if self.akey > 70 then
  239.         self.akey = 1
  240.     end
  241. end
  242.  
  243. Rocks = class()
  244.  
  245. function Rocks:init()
  246.     self.rocks = {}
  247.     self.newrock = 60
  248.     self.nextrock = self.newrock
  249. end
  250.  
  251. function Rocks:draw()
  252.     if self.nextrock < 1 then
  253.         table.insert(self.rocks, Rock())
  254.         self.nextrock = math.ceil(self.newrock)
  255.     else
  256.         self.nextrock = self.nextrock - 1
  257.     end
  258.     for i,v in ipairs(self.rocks) do
  259.         v:draw()
  260.     end
  261.     for i,v in ipairs(self.rocks) do
  262.         if v.py < 0 - v.height/2 then
  263.             table.remove(self.rocks, i)
  264.         end
  265.     end
  266. end
  267.  
  268. rocksprites = {
  269. {1, 50, 48},
  270. {2, 50, 52},
  271. {3, 86, 92},
  272. {4, 82, 104},
  273. {5, 140, 152},
  274. {6, 46, 48},
  275. {7, 44, 40}
  276. }
  277. rockspeed = 400
  278.  
  279. Rock = class()
  280.  
  281. function Rock:init()
  282.     self.sid = rocksprites[math.random(1, table.maxn(rocksprites))][1]
  283.     self.width = rocksprites[self.sid][2]
  284.     self.height = rocksprites[self.sid][3]
  285.     self.px = math.random(0, WIDTH)
  286.     self.py = HEIGHT+self.height/2
  287. end
  288.  
  289. function Rock:draw()
  290.     self.py = self.py - rockspeed*DeltaTime
  291.     sprite("Tyrian Remastered:Rock "..self.sid, self.px, self.py, self.width, self.height)
  292. end
  293.  
  294. Ship = class()
  295.  
  296. function Ship:init()
  297.     self.px = WIDTH/2
  298.     self.py = 50
  299.     self.width = 42
  300.     self.height = 54
  301.     self.crashed = false
  302.     self.invulnerable = 0
  303. end
  304.  
  305. function Ship:draw()
  306.     self.px = self.px + Gravity.x*35
  307.     if self.px < self.width/2 then
  308.         self.px = self.width/2
  309.     elseif self.px > WIDTH - self.width/2 then
  310.         self.px = WIDTH - self.width/2
  311.     end
  312.     sid = ""
  313.     if Gravity.x > 0.14 then
  314.         sid = " R2"
  315.     elseif Gravity.x > 0.06 then
  316.         sid = " R1"
  317.     elseif Gravity.x < -0.14 then
  318.         sid = " L2"
  319.     elseif Gravity.x < -0.06 then
  320.         sid = " L1"
  321.     end
  322.     if self.invulnerable > 0 then
  323.         self.invulnerable = self.invulnerable - 1
  324.     end
  325.     if self.crashed == false and not (self.invulnerable < 140 and self.invulnerable > 130) and not  (self.invulnerable < 120 and self.invulnerable > 110) then
  326.         if self.invulnerable > 0 then
  327.             sprite("Tyrian Remastered:Energy Orb 2", self.px, self.py, 60, 60)
  328.         end
  329.        
  330.         sprite("Tyrian Remastered:Ship A"..sid, self.px, self.py, 40, 54)    
  331.         if self.invulnerable > 0 and self.invulnerable ~= 8 and self.invulnerable ~= 16 then
  332.             pushStyle()
  333.             stroke(255, 255, 255, 255)
  334.             strokeWidth(1)
  335.             fill(203, 217, 228, 123)
  336.             ellipseMode(CENTER)
  337.             ellipse(self.px, self.py, 80, 80)
  338.             popStyle()
  339.         end
  340.     end
  341. end
  342.  
  343. Streaks = class()
  344.  
  345. function Streaks:init()
  346.     self.stars = {}
  347.     self.spawnrate = 1
  348.     for i = 1, 50 do
  349.         table.insert(self.stars, vec3(math.random(0, WIDTH), math.random(0, HEIGHT), math.random(4,15)))
  350.     end
  351. end
  352.  
  353. function Streaks:draw()
  354.     for i = 1, self.spawnrate do
  355.         table.insert(self.stars, vec3(math.random(0, WIDTH), HEIGHT, math.random(4,15)))
  356.     end
  357.     for i,v in ipairs(self.stars) do
  358.         stroke(255, 255, 255, 255)
  359.         strokeWidth(1)
  360.         noSmooth()
  361.         fill(255, 255, 255, 255)
  362.         oy = v.y
  363.         self.stars[i] = vec3(v.x, oy-v.z, v.z)
  364.         line(v.x, oy, v.x, self.stars[i].y)
  365.     end
  366.     for i,v in ipairs(self.stars) do
  367.         if self.stars[i].y < 0 then
  368.             table.remove(self.stars, i)
  369.         end
  370.     end
  371. end
  372.  
  373. Explosion = class()
  374.  
  375. function Explosion:init(pos)
  376.     self.position = pos
  377.     self.life = 255
  378.     self.particles = {}
  379.     for i = 1, 75 do
  380.         vel = vec2(math.random(-10,10), math.random(-10,10))
  381.         table.insert(self.particles, Particle(self.position, vel))
  382.     end
  383. end
  384.  
  385. function Explosion:draw()
  386.     stroke(self.life, self.life, self.life, self.life)
  387.     for i,v in ipairs(self.particles) do
  388.         v:draw()
  389.     end
  390.     self.life = self.life - 217*DeltaTime
  391.     if self.life > 128 then
  392.         sprite("Tyrian Remastered:Explosion Huge", self.position.x, self.position.y, 128-self.life/2)
  393.     elseif self.life > 0 then
  394.         sprite("Tyrian Remastered:Explosion Huge", self.position.x, self.position.y, self.life/2)
  395.     end
  396. end
  397.  
  398. function Explosion:isDone()
  399.     if self.life > 0 then
  400.         return false
  401.     else
  402.         return true
  403.     end
  404. end
  405.  
  406. Particle = class()
  407.  
  408. function Particle:init(pos, vel)
  409.     self.position = pos
  410.     self.velocity = vel
  411. end
  412.  
  413. function Particle:draw()
  414.     line(self.position.x, self.position.y, self.position.x+self.velocity.x, self.position.y+self.velocity.y)
  415.    
  416.     self.position = vec2(self.position.x+self.velocity.x*DeltaTime*50,
  417.      self.position.y+self.velocity.y*DeltaTime*50)
  418. end
  419.  
  420. Font = class()
  421.  
  422. -- - The Hershey Fonts were originally created by Dr.
  423. -- A. V. Hershey while working at the
  424. -- U. S. National Bureau of Standards.
  425.  
  426. -- Useful Links:
  427. -- http://emergent.unpythonic.net/software/hershey
  428. -- http://paulbourke.net/dataformats/hershey/
  429.  
  430. -- Re-encoding of font information and other shenanigans
  431. -- by Tom Bortels bortels@gmail.com November 2011
  432. -- all rights reversed (Hail Eris!)
  433.  
  434. -- "If I have seen a little further it is by standing
  435. --  on the shoulders of Giants."
  436. -- Isaac Newton
  437.  
  438. function Font:init()
  439.    -- font data - 2 decimal character # of points,
  440.    -- followed by 2*points of point data
  441.    -- 9->-9, 8-<-8, ... 1->-1, 0->0, A->1, B->2, ... Z->26
  442.    self.code = "9876543210ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  443.    -- this is the Hershey Roman Simplex font for ascii 32-127
  444.    self.fontdata =
  445.       "00160810EUEG11EBDAE0FAEB0516DUDN11LULN1121KYD711QYJ711DLRL11"
  446.    .. "CFQF2620HYH411LYL411QROTLUHUETCRCPDNEMGLMJOIPHQFQCOAL0H0EACC"
  447.    .. "3124UUC011HUJSJQIOGNENCPCRDTFUHUJTMSPSSTUU11QGOFNDNBP0R0TAUC"
  448.    .. "UESGQG3426WLWMVNUNTMSKQFOCMAK0G0EADBCDCFDHEILMMNNPNRMTKUITHR"
  449.    .. "HPIMKJPCRAT0V0WAWB0710ESDTEUFTFREPDO1014KYIWGTEPDKDGEBG2I5K7"
  450.    .. "1014CYEWGTIPJKJGIBG2E5C70816HUHI11CRML11MRCL0526MRM011DIVI08"
  451.    .. "10FAE0DAEBFAF1E3D40226DIVI0510EBDAE0FAEB0222TYB71720IUFTDQCL"
  452.    .. "CIDDFAI0K0NAPDQIQLPQNTKUIU0420FQHRKUK01420DPDQESFTHULUNTOSPQ"
  453.    .. "POOMMJC0Q01520EUPUJMMMOLPKQHQFPCNAK0H0EADBCD0620MUCGRG11MUM0"
  454.    .. "1720OUEUDLEMHNKNNMPKQHQFPCNAK0H0EADBCD2320PROTLUJUGTEQDLDGEC"
  455.    .. "GAJ0K0NAPCQFQGPJNLKMJMGLEJDG0520QUG011CUQU2920HUETDRDPENGMKL"
  456.    .. "NKPIQGQDPBOAL0H0EADBCDCGDIFKILMMONPPPROTLUHU2320PNOKMIJHIHFI"
  457.    .. "DKCNCODRFTIUJUMTORPNPIODMAJ0H0EADC1110ENDMELFMEN11EBDAE0FAEB"
  458.    .. "1410ENDMELFMEN11FAE0DAEBFAF1E3D40324TRDIT00526DLVL11DFVF0324"
  459.    .. "DRTID02018CPCQDSETGUKUMTNSOQOONMMLIJIG11IBHAI0JAIB5527RMQOOP"
  460.    .. "LPJOINHKHHIFKENEPFQH11LPJNIKIHJFKE11RPQHQFSEUEWGXJXLWOVQTSRT"
  461.    .. "OULUITGSEQDOCLCIDFEDGBIAL0O0RATBUC11SPRHRFSE0818IUA011IUQ011"
  462.    .. "DGNG2321DUD011DUMUPTQSRQROQMPLMK11DKMKPJQIRGRDQBPAM0D01821RP"
  463.    .. "QROTMUIUGTERDPCMCHDEECGAI0M0OAQCRE1521DUD011DUKUNTPRQPRMRHQE"
  464.    .. "PCNAK0D01119DUD011DUQU11DKLK11D0Q00818DUD011DUQU11DKLK2221RP"
  465.    .. "QROTMUIUGTERDPCMCHDEECGAI0M0OAQCRERH11MHRH0822DUD011RUR011DK"
  466.    .. "RK0208DUD01016LULEKBJAH0F0DACBBEBG0821DUD011RUDG11ILR00517DU"
  467.    .. "D011D0P01124DUD011DUL011TUL011TUT00822DUD011DUR011RUR02122IU"
  468.    .. "GTERDPCMCHDEECGAI0M0OAQCRESHSMRPQROTMUIU1321DUD011DUMUPTQSRQ"
  469.    .. "RNQLPKMJDJ2422IUGTERDPCMCHDEECGAI0M0OAQCRESHSMRPQROTMUIU11LD"
  470.    .. "R21621DUD011DUMUPTQSRQROQMPLMKDK11KKR02020QROTLUHUETCRCPDNEM"
  471.    .. "GLMJOIPHQFQCOAL0H0EACC0516HUH011AUOU1022DUDFECGAJ0L0OAQCRFRU"
  472.    .. "0518AUI011QUI01124BUG011LUG011LUQ011VUQ00520CUQ011QUC00618AU"
  473.    .. "IKI011QUIK0820QUC011CUQU11C0Q01114DYD711EYE711DYKY11D7K70214"
  474.    .. "0UN31114IYI711JYJ711CYJY11C7J71016FOHRJO11CLHQML11HQH0021602"
  475.    .. "P20710FUETDRDPEOFPEQ1719ONO011OKMMKNHNFMDKCHCFDCFAH0K0MAOC17"
  476.    .. "19DUD011DKFMHNKNMMOKPHPFOCMAK0H0FADC1418OKMMKNHNFMDKCHCFDCFA"
  477.    .. "H0K0MAOC1719OUO011OKMMKNHNFMDKCHCFDCFAH0K0MAOC1718CHOHOJNLMM"
  478.    .. "KNHNFMDKCHCFDCFAH0K0MAOC0812JUHUFTEQE011BNIN2219ONO2N5M6K7H7"
  479.    .. "F611OKMMKNHNFMDKCHCFDCFAH0K0MAOC1019DUD011DJGMINLNNMOJO00808"
  480.    .. "CUDTEUDVCU11DND01110EUFTGUFVEU11FNF3E6C7A70817DUD011NNDD11HH"
  481.    .. "O00208DUD01830DND011DJGMINLNNMOJO011OJRMTNWNYMZJZ01019DND011"
  482.    .. "DJGMINLNNMOJO01719HNFMDKCHCFDCFAH0K0MAOCPFPHOKMMKNHN1719DND7"
  483.    .. "11DKFMHNKNMMOKPHPFOCMAK0H0FADC1719ONO711OKMMKNHNFMDKCHCFDCFA"
  484.    .. "H0K0MAOC0813DND011DHEKGMINLN1717NKMMJNGNDMCKDIFHKGMFNDNCMAJ0"
  485.    .. "G0DACC0812EUEDFAH0J011BNIN1019DNDDEAG0J0LAOD11ONO00516BNH011"
  486.    .. "NNH01122CNG011KNG011KNO011SNO00517CNN011NNC00916BNH011NNH0F4"
  487.    .. "D6B7A70817NNC011CNNN11C0N03914IYGXFWEUESFQGPHNHLFJ11GXFVFTGR"
  488.    .. "HQIOIMHKDIHGIEICHAG0F2F4G611FHHFHDGBFAE1E3F5G6I70208DYD73914"
  489.    .. "EYGXHWIUISHQGPFNFLHJ11GXHVHTGRFQEOEMFKJIFGEEECFAG0H2H4G611HH"
  490.    .. "FFFDGBHAI1I3H5G6E72324CFCHDKFLHLJKNHPGRGTHUJ11CHDJFKHKJJNGPF"
  491.    .. "RFTGUJUL"
  492.  
  493.    local i=1
  494.    local c=32
  495.    self.font = {}
  496.    while (i < string.len(self.fontdata)) do
  497.       local cs = string.char(c)
  498.       self.font[cs] = {}
  499.       local points = string.sub(self.fontdata, i, i+1)
  500.       self.font[cs].points = points
  501.       self.font[cs].char = cs
  502.       self.font[cs].ascii = c
  503.       self.font[cs].width = string.sub(self.fontdata, i+2, i+3)
  504.       --print(cs,points,self.font[cs].width)
  505.       i = i + 4
  506.       self.font[cs].data = string.sub(self.fontdata, i, i+points*2)
  507.     --print(self.font[cs].data)
  508.       i = i + points*2
  509.       c = c + 1
  510.    end
  511.    i=-9
  512.    self.decode = {}
  513.    for c in self.code:gmatch"." do
  514.       self.decode[c]=i
  515.       i=i+1
  516.    end
  517. end
  518.  
  519. -- returns width in pixels of unscaled, strokeWidth(1) string
  520. function Font:stringwidth(s)
  521.    local x, l, i = 0, string.len(s)
  522.    for i = 1, l do
  523.       x = x + self.font[s:sub(i, i)].width
  524.    end
  525. end
  526.  
  527. -- draw a string at x,y (skipping offscreen draws)
  528. function Font:drawstring(s, x, y)
  529.    local l, i
  530.    l = string.len(s)
  531.    for i = 1, l do
  532.       local c = s:sub(i, i)
  533.       local w = self.font[c].width
  534.       if ((x + w) >= 0) then
  535.          x = x + (self:drawchar(c, x, y))
  536.       else
  537.          x = x + w -- skip offscreen left (but track position)
  538.       end
  539.       if (x > WIDTH) then break end -- skip offscreen right
  540.    end
  541. end
  542.  
  543. -- optimized draw string at x,y (old version for reference)
  544. function Font:olddrawstring(s, x, y)
  545.    local l, i
  546.    l = string.len(s)
  547.    for i = 1, l do
  548.       x = x + (self:drawchar(string.sub(s, i, i), x, y))
  549.    end
  550. end
  551.  
  552. function Font:drawchar(c, x, y)
  553.    local ax, ay, bx, by, minx, maxx = -1, -1, -1, -1, -1, -1
  554.    local p, plot
  555.    local ch = self.font[c]
  556.    for p=1, ch.points do
  557.       ax=bx
  558.       ay=by
  559.       bx=self.decode[ch.data:sub(p*2-1, p*2-1)]
  560.       by=self.decode[ch.data:sub(p*2, p*2)]
  561.       plot=true
  562.       if ((ax==-1) and (ay==-1)) then plot=false end
  563.       if ((bx==-1) and (by==-1)) then plot=false end
  564.       if (plot) then
  565.          line(x+ax, y+ay, x+bx, y+by)
  566.       end
  567.    end
  568.    return ch.width -- for drawstring
  569. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top