Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function draw_bullets()
- bullet_length = 3
- bullet_speed = 2
- if (#bullets > 0) then
- for k,v in pairs(bullets) do
- --check if out of screen
- if (v[1] > 200) then
- del(bullets,v)
- end
- if ( v[3] >= 0) then
- x1 = (v[1])
- x2 = (v[1] + bullet_length)
- y1 = (v[0]) * x1 + v[4]
- y2 = (v[0]) * x2 + v[4]
- y1=y1-1
- y2=y2-1
- line(x1,y1,x2,y2,11)
- v[2] = v[2] + bullet_speed
- else
- x1 = (v[1])
- x2 = (v[1] - bullet_length)
- y1 = (v[0]) * x1 + v[4]
- y2 = (v[0]) * x2 + v[4]
- y1=y1-1
- y2=y2-1
- line(x1,y1,x2,y2,11)
- v[2] = v[2] - bullet_speed
- end
- end
- end
- end
- function createbullet(x1,y1,x2,y2)
- bullet = {}
- bullet[0] = (y2-y1) / (x2-x1)
- bullet[1] = x1
- bullet[2] = y1
- bullet[3] = crosshair_x
- bullet[4] = -1*((y2-y1)/(x2-x1))*x1+y1
- add(bullets,bullet)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement