particles
This commit is contained in:
parent
e355e5d3fe
commit
5d6c97d086
3 changed files with 49 additions and 13 deletions
|
@ -7,7 +7,8 @@ multilily = lily.loadMulti({
|
||||||
{lily.newImage, "assets/captains/john-danger.png"},
|
{lily.newImage, "assets/captains/john-danger.png"},
|
||||||
{lily.newImage, "assets/ships/blackstar-5.png"},
|
{lily.newImage, "assets/ships/blackstar-5.png"},
|
||||||
{lily.newImage, "assets/ships/excalibur-iv.png"},
|
{lily.newImage, "assets/ships/excalibur-iv.png"},
|
||||||
{lily.newImage, "assets/ships/decorator.png"}
|
{lily.newImage, "assets/ships/decorator.png"},
|
||||||
|
{lily.newImage, "assets/ships/particle.png"}
|
||||||
})
|
})
|
||||||
multilily:onComplete(function(_, lilies)
|
multilily:onComplete(function(_, lilies)
|
||||||
gameLogo = lilies[1][1]
|
gameLogo = lilies[1][1]
|
||||||
|
@ -19,6 +20,7 @@ multilily:onComplete(function(_, lilies)
|
||||||
CaptainSteve.ship.image = lilies[7][1]
|
CaptainSteve.ship.image = lilies[7][1]
|
||||||
CaptainRobert.ship.image = lilies[8][1]
|
CaptainRobert.ship.image = lilies[8][1]
|
||||||
CaptainJohn.ship.image = lilies[9][1]
|
CaptainJohn.ship.image = lilies[9][1]
|
||||||
|
boosterParticle = lilies[10][1]
|
||||||
|
|
||||||
windowWidth = love.graphics.getWidth()
|
windowWidth = love.graphics.getWidth()
|
||||||
windowHeight = love.graphics.getHeight()
|
windowHeight = love.graphics.getHeight()
|
||||||
|
|
BIN
assets/ships/particle.png
Normal file
BIN
assets/ships/particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 316 B |
|
@ -6,15 +6,39 @@ end
|
||||||
function GameScene:init()
|
function GameScene:init()
|
||||||
GameScene:playerChanged(currentPlayer)
|
GameScene:playerChanged(currentPlayer)
|
||||||
movementDelta = 0
|
movementDelta = 0
|
||||||
|
|
||||||
|
pSystem = love.graphics.newParticleSystem(boosterParticle,128)
|
||||||
|
pSystem:setParticleLifetime(0,0.6)
|
||||||
|
pSystem:setLinearAcceleration(0,20,0,25)
|
||||||
|
pSystem:setSpeed(40,50)
|
||||||
|
pSystem:setRotation(10,20)
|
||||||
|
pSystem:setSpin(10,20)
|
||||||
|
pSystem:setRadialAcceleration(10,20)
|
||||||
|
pSystem:setTangentialAcceleration(10,20)
|
||||||
|
pSystem:setSizeVariation(0.3)
|
||||||
|
pSystem:setSizes(1,0.9,0.8,0.7,0.5,0.3,0.1,0.05)
|
||||||
|
pSystem:setColors(
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,0.8,
|
||||||
|
1,1,1,0.6,
|
||||||
|
1,1,1,0.5,
|
||||||
|
1,1,1,0.4,
|
||||||
|
1,1,1,0.3
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:update(dt)
|
function GameScene:update(dt)
|
||||||
|
pSystem:update(dt)
|
||||||
GameScene:updateInput(dt)
|
GameScene:updateInput(dt)
|
||||||
GameScene:updateBounds(dt)
|
GameScene:updateBounds(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:draw()
|
function GameScene:draw()
|
||||||
love.graphics.setColor(255,255,255, 1)
|
love.graphics.setColor(255,255,255, 1)
|
||||||
|
love.graphics.draw(pSystem, currentPlayer.px-2, currentPlayer.py)
|
||||||
|
love.graphics.draw(pSystem, currentPlayer.px+2, currentPlayer.py)
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
currentPlayer.ship.image,
|
currentPlayer.ship.image,
|
||||||
currentPlayer.px,
|
currentPlayer.px,
|
||||||
|
@ -58,7 +82,7 @@ function GameScene:playerChanged(to)
|
||||||
currentPlayer.py = windowHeight/2
|
currentPlayer.py = windowHeight/2
|
||||||
currentPlayer.rot = 0
|
currentPlayer.rot = 0
|
||||||
currentPlayer.acc = 0
|
currentPlayer.acc = 0
|
||||||
currentPlayer.bounds = { x1= 20, y1= 20, x2= windowWidth-30, y2= windowHeight - 86}
|
currentPlayer.bounds = { x1= 20, y1= 20, x2= windowWidth-20, y2= windowHeight - 86}
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:updateInput(dt)
|
function GameScene:updateInput(dt)
|
||||||
|
@ -70,7 +94,6 @@ function GameScene:updateInput(dt)
|
||||||
local isLeft = false
|
local isLeft = false
|
||||||
local isDown = false
|
local isDown = false
|
||||||
local isRight = false
|
local isRight = false
|
||||||
local rotation = 0
|
|
||||||
|
|
||||||
--local hAxis, vAxis, hAxis2, vAxis2 = love.joystick.getAxes(1)
|
--local hAxis, vAxis, hAxis2, vAxis2 = love.joystick.getAxes(1)
|
||||||
--local axisMargin = 0.5
|
--local axisMargin = 0.5
|
||||||
|
@ -81,25 +104,31 @@ function GameScene:updateInput(dt)
|
||||||
isRight = love.keyboard.isDown( "d" )-- or (not (hAxis == nil) and hAxis > (1-axisMargin)) or (not (hAxis2 == nil) and hAxis2 > (1-axisMargin)) or love.joystick.isDown(1, 4)
|
isRight = love.keyboard.isDown( "d" )-- or (not (hAxis == nil) and hAxis > (1-axisMargin)) or (not (hAxis2 == nil) and hAxis2 > (1-axisMargin)) or love.joystick.isDown(1, 4)
|
||||||
|
|
||||||
if isUp and isLeft then
|
if isUp and isLeft then
|
||||||
rotation = 315
|
currentPlayer.rot = 315
|
||||||
|
particleRot = 45
|
||||||
elseif isUp and isRight then
|
elseif isUp and isRight then
|
||||||
rotation = 45
|
currentPlayer.rot = 45
|
||||||
|
particleRot = 135
|
||||||
elseif isUp then
|
elseif isUp then
|
||||||
rotation = 0
|
currentPlayer.rot = 0
|
||||||
|
particleRot = 90
|
||||||
elseif isDown and isLeft then
|
elseif isDown and isLeft then
|
||||||
rotation = 225
|
currentPlayer.rot = 225
|
||||||
|
particleRot = 315
|
||||||
elseif isDown and isRight then
|
elseif isDown and isRight then
|
||||||
rotation = 135
|
currentPlayer.rot = 135
|
||||||
|
particleRot = 225
|
||||||
elseif isDown then
|
elseif isDown then
|
||||||
rotation = 180
|
currentPlayer.rot = 180
|
||||||
|
particleRot = 270
|
||||||
elseif isLeft then
|
elseif isLeft then
|
||||||
rotation = 270
|
currentPlayer.rot = 270
|
||||||
|
particleRot = 0
|
||||||
elseif isRight then
|
elseif isRight then
|
||||||
rotation = 90
|
currentPlayer.rot = 90
|
||||||
|
particleRot = 180
|
||||||
end
|
end
|
||||||
|
|
||||||
currentPlayer.rot = rotation
|
|
||||||
|
|
||||||
if isUp or isDown or isLeft or isRight then
|
if isUp or isDown or isLeft or isRight then
|
||||||
currentPlayer.acc = currentPlayer.acc + currentPlayer.accIncr
|
currentPlayer.acc = currentPlayer.acc + currentPlayer.accIncr
|
||||||
elseif currentPlayer.acc > 0 then
|
elseif currentPlayer.acc > 0 then
|
||||||
|
@ -108,6 +137,11 @@ function GameScene:updateInput(dt)
|
||||||
|
|
||||||
currentPlayer.acc = math.clamp(0, currentPlayer.acc, 1)
|
currentPlayer.acc = math.clamp(0, currentPlayer.acc, 1)
|
||||||
|
|
||||||
|
if currentPlayer.acc > 0 then
|
||||||
|
pSystem:setDirection(particleRot*(math.pi/180))
|
||||||
|
pSystem:emit( 64 * currentPlayer.acc )
|
||||||
|
end
|
||||||
|
|
||||||
if isUp then
|
if isUp then
|
||||||
currentPlayer.py = currentPlayer.py - (currentPlayer.speed*currentPlayer.acc)
|
currentPlayer.py = currentPlayer.py - (currentPlayer.speed*currentPlayer.acc)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue