Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. function draw_bullets()
  2.  
  3.  bullet_length = 3
  4.  bullet_speed = 2
  5.  
  6.  if (#bullets > 0) then
  7.   for k,v in pairs(bullets) do
  8.    
  9.    --check if out of screen
  10.    if (v[1] > 200) then
  11.     del(bullets,v)
  12.    end
  13.    
  14.    if ( v[3] >= 0) then
  15.     x1 = (v[1])
  16.     x2 = (v[1] + bullet_length)
  17.     y1 = (v[0]) * x1 + v[4]
  18.     y2 = (v[0]) * x2 + v[4]
  19.    
  20.     y1=y1-1
  21.     y2=y2-1
  22.    
  23.     line(x1,y1,x2,y2,11)
  24.     v[2] = v[2] + bullet_speed
  25.    else
  26.     x1 = (v[1])
  27.     x2 = (v[1] - bullet_length)
  28.     y1 = (v[0]) * x1 + v[4]
  29.     y2 = (v[0]) * x2 + v[4]
  30.    
  31.     y1=y1-1
  32.     y2=y2-1
  33.    
  34.     line(x1,y1,x2,y2,11)
  35.     v[2] = v[2] - bullet_speed
  36.    end
  37.   end
  38.  end
  39. end
  40.  
  41. function createbullet(x1,y1,x2,y2)
  42.  bullet = {}
  43.  bullet[0] = (y2-y1) / (x2-x1) 
  44.  bullet[1] = x1        
  45.  bullet[2] = y1    
  46.  bullet[3] = crosshair_x
  47.  bullet[4] = -1*((y2-y1)/(x2-x1))*x1+y1
  48.  add(bullets,bullet)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement