Last active
December 31, 2015 15:19
-
-
Save domgetter/8006575 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
{ | |
"animatedParts" : { | |
"stateTypes" : { | |
"boosting" : { | |
"default" : "off", | |
"states" : { | |
"off" : { | |
}, | |
"on" : { | |
"properties" : { | |
"immediateSound" : "/sfx/tech/tech_dashshort.wav" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"particleEmitters" : { | |
"boostParticlesLeft" : { | |
"emissionRate" : 20.0, | |
"particles" : [ | |
{"particle" : "jetboost"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"} | |
] | |
}, | |
"boostParticlesRight" : { | |
"emissionRate" : 20.0, | |
"particles" : [ | |
{"particle" : "jetboost"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"} | |
] | |
}, | |
"boostParticlesDown" : { | |
"emissionRate" : 20.0, | |
"particles" : [ | |
{"particle" : "jetboost"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"} | |
] | |
}, | |
"boostParticlesUp" : { | |
"emissionRate" : 20.0, | |
"particles" : [ | |
{"particle" : "jetboost"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"}, | |
{"particle" : "defaultblue"} | |
] | |
} | |
} | |
} |
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 init() | |
data.lastJump = false | |
data.lastBoost = nil | |
data.ranOut = false | |
data.vert = 0 | |
data.horz = 0 | |
end | |
function input(args) | |
local currentJump = args.moves["jump"] | |
local currentBoost = nil | |
if not tech.onGround() then | |
if not tech.canJump() and currentJump and not data.lastJump then | |
if args.moves["right"] and args.moves["up"] then | |
currentBoost = "boostRightUp" | |
elseif args.moves["right"] and args.moves["down"] then | |
currentBoost = "boostRightDown" | |
elseif args.moves["left"] and args.moves["up"] then | |
currentBoost = "boostLeftUp" | |
elseif args.moves["left"] and args.moves["down"] then | |
currentBoost = "boostLeftDown" | |
elseif args.moves["right"] then | |
currentBoost = "boostRight" | |
elseif args.moves["down"] then | |
currentBoost = "boostDown" | |
elseif args.moves["left"] then | |
currentBoost = "boostLeft" | |
elseif args.moves["up"] then | |
currentBoost = "boostUp" | |
end | |
elseif currentJump and data.lastBoost then | |
currentBoost = data.lastBoost | |
end | |
end | |
data.lastJump = currentJump | |
data.lastBoost = currentBoost | |
return currentBoost | |
end | |
function update(args) | |
local boostControlForce = tech.parameter("boostControlForce") | |
local boostSpeed = tech.parameter("boostSpeed") | |
local energyUsagePerSecond = tech.parameter("energyUsagePerSecond") | |
local energyUsage = energyUsagePerSecond * args.dt | |
if args.availableEnergy < energyUsage then | |
data.ranOut = true | |
elseif tech.onGround() or tech.inLiquid() then | |
data.ranOut = false | |
end | |
local boosting = false | |
local diag = 1 / math.sqrt(2) | |
if not data.ranOut then | |
boosting = true | |
if args.actions["boostRightUp"] then | |
tech.control({boostSpeed * diag, boostSpeed * diag}, boostControlForce, true, true) | |
data.horz = 2 | |
data.vert = 2 | |
elseif args.actions["boostRightDown"] then | |
tech.control({boostSpeed * diag, -boostSpeed * diag}, boostControlForce, true, true) | |
data.horz = 2 | |
data.vert = 1 | |
elseif args.actions["boostLeftUp"] then | |
tech.control({-boostSpeed * diag, boostSpeed * diag}, boostControlForce, true, true) | |
data.horz = 1 | |
data.vert = 2 | |
elseif args.actions["boostLeftDown"] then | |
tech.control({-boostSpeed * diag, -boostSpeed * diag}, boostControlForce, true, true) | |
data.horz = 1 | |
data.vert = 1 | |
elseif args.actions["boostRight"] then | |
tech.control({boostSpeed, 0}, boostControlForce, true, true) | |
data.horz = 2 | |
elseif args.actions["boostDown"] then | |
tech.control({0, -boostSpeed}, boostControlForce, true, true) | |
data.vert = 1 | |
elseif args.actions["boostLeft"] then | |
tech.control({-boostSpeed, 0}, boostControlForce, true, true) | |
data.horz = 1 | |
elseif args.actions["boostUp"] then | |
tech.control({0, boostSpeed}, boostControlForce, true, true) | |
data.vert = 2 | |
else | |
boosting = false | |
end | |
end | |
if boosting then | |
if args.actions["boostRight"] then | |
tech.setParticleEmitterActive("boostParticlesRight", true) | |
elseif args.actions["boostDown"] then | |
tech.setParticleEmitterActive("boostParticlesDown", true) | |
elseif args.actions["boostLeft"] then | |
tech.setParticleEmitterActive("boostParticlesLeft", true) | |
elseif args.actions["boostUp"] then | |
tech.setParticleEmitterActive("boostParticlesUp", true) | |
end | |
tech.setAnimationState("boosting", "on") | |
return energyUsage | |
else | |
tech.setParticleEmitterActive("boostParticles", false) | |
return 0 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment