Created
April 26, 2013 06:29
-
-
Save dermotbalson/5465368 to your computer and use it in GitHub Desktop.
bullets1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() | |
physics.gravity(0,0) | |
bullets={} | |
end | |
function touched(touch) | |
x = touch.x | |
y = touch.y | |
if touch.state == BEGAN then --create bullet | |
local bullet = physics.body(CIRCLE,10) -- <<NEW | |
bullet.x,bullet.y = x,y | |
bullet.linearVelocity = vec2(1000,0) | |
bullet.restitution = 0 | |
bullet.type = DYNAMIC | |
table.insert(bullets,bullet) | |
end | |
end | |
function draw() | |
background(0, 0, 0, 255) | |
--draw bullets | |
pushStyle() | |
fill(255, 255, 255, 255) | |
--ellipse(bullet.x,bullet.y,10) | |
for i,b in pairs(bullets) do | |
ellipse(b.x,b.y,10) | |
end | |
popStyle() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment