Created
September 26, 2011 05:26
-
-
Save jspahrsummers/1241667 to your computer and use it in GitHub Desktop.
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
local ship = { entropy.loadtexture("data/ships/fighter/base.png") } | |
local glow = { entropy.loadtexture("data/ships/fighter/glow.png") } | |
local lights = { entropy.loadtexture("data/ships/fighter/lights.png") } | |
function shutdown () | |
entropy.deletetexture(ship[1]) | |
entropy.deletetexture(glow[1]) | |
entropy.deletetexture(lights[1]) | |
end | |
function create () | |
return { | |
glow = 0, | |
velx = 0, | |
vely = 0, | |
lastlights = 0, | |
lights = 0, | |
energy = 1000 | |
} | |
end | |
function energy (data) | |
return data.energy, 1000 | |
end | |
function deplete (data, amount) | |
data.energy = data.energy - amount | |
end | |
function boundingBox (data) | |
return -43, -24, 41, 19 | |
end | |
function act (data, multiplier, x, y, rotation) | |
local regen = false | |
data.lastlights = data.lastlights + multiplier | |
if data.lastlights >= 3 then | |
data.lastlights = 0 | |
data.lights = 0.5 | |
regen = true | |
elseif data.lights > 0 then | |
data.lights = data.lights - multiplier | |
regen = true | |
end | |
data.energy = data.energy + 100 * multiplier | |
if data.energy > 1000 then | |
data.energy = 1000 | |
end | |
return x + data.velx * multiplier, y + data.vely * multiplier, rotation, regen | |
end | |
function accelerate (data, multiplier, rotation) | |
if multiplier > 0 then | |
data.velx = data.velx + math.sin(rotation * (math.pi / 180)) * multiplier * 200 | |
data.vely = data.vely - math.cos(rotation * (math.pi / 180)) * multiplier * 200 | |
data.glow = data.glow + 1 * multiplier | |
if data.glow > 1 then | |
data.glow = 1 | |
end | |
else | |
data.glow = data.glow + 2 * multiplier | |
if data.glow < 0 then | |
data.glow = 0 | |
end | |
end | |
return true | |
end | |
function rotate (data, multiplier, rotation) | |
return rotation + multiplier * 180, false | |
end | |
function render (data) | |
entropy.rendertexture(ship[1], ship[2]) | |
entropy.rendertexture(glow[1], glow[2], data.glow) | |
if data.lights > 0 then | |
entropy.rendertexture(lights[1], lights[2]) | |
end | |
end | |
function velocity (data, rotation) | |
return data.velx, data.vely | |
end | |
offset = 24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment