blank LOVE / splash / Splash.lua

--[[----------------------------------------------------------------------------
Copyright (c) 2011, Danny Fritz <dannyfritz@gmail.com>
http://creativecommons.org/licenses/by/3.0/
Licensed under the Creative Commons Attribution 3.0 Unported License.
--]]----------------------------------------------------------------------------

local Splash = Gamestate:addState('Splash')

local Tween = require 'lib.tween.tween'
local Object = require 'splash.Object'

local NEXTSTATE = 'Menu'

local leaf
local face
local text
local pixel_effect

--------------------------------------------------------------------------------
function Splash:enteredState()
	love.graphics.setBackgroundColor(254, 153, 0)

	local leaf_image = love.graphics.newImage('splash/leaf.png')
	leaf = Object:new(leaf_image, {x=520, y=20, angle=-math.pi/64,
			scale_x=0, scale_y=0, offset_x=3, offset_y=4})
	Tween(0.2, leaf, {}, 'linear',
	Tween, 0.1, leaf, {angle=math.pi/64}, 'outSine',
	Tween, 0.1, leaf, {angle=-math.pi/64}, 'inOutSine',
	Tween, 0.2, leaf, {}, 'linear',
	Tween, 0.1, leaf, {angle=math.pi/64}, 'outSine',
	Tween, 0.1, leaf, {angle=0}, 'inOutSine',
	Tween, 0.3, leaf, {}, 'linear')

	Tween(0.3, leaf, {scale_x=0.3, scale_y=0.3}, 'outBack',
	Tween, 0.1, leaf, {}, 'linear',
	Tween, 0.3, leaf, {scale_x=0.6, scale_y=0.6}, 'outBack',
	Tween, 0.3, leaf, {}, 'linear',
	Tween, 0.4, leaf, {scale_x=1, scale_y=1}, 'outBack')

	local face_image = love.graphics.newImage('splash/face.png')
	face = Object:new(face_image,
			{x=390, y=300, scale_x=0.75, scale_y=0.75, alpha=0, offset_x=159, offset_y=175})
	Tween(1, face, {}, 'linear',
			Tween, 0.4, face, {scale_x=1, scale_y=1}, 'outBack')
	Tween(1, face, {}, 'linear',
			Tween, 0.4, face, {alpha=255}, 'linear')

	local text_image = love.graphics.newImage('splash/TechnoCat.png')
	text = Object:new(text_image, {x=90, y=490, alpha=0})
	Tween(1, text, {}, 'linear',
			Tween, 0.4, text, {alpha=255}, 'linear')
	
	--SWITCH ON PIXELSHADER
	Tween(2, leaf, {}, 'linear',
			Tween, 0.3, leaf, {alpha=0}, 'linear',
			gamestate.gotoState, gamestate, NEXTSTATE)
	
	Tween(2, face, {}, 'linear',
			Tween, 0.3, face, {alpha=0}, 'linear')
	
	Tween(2, text, {}, 'linear',
			Tween, 0.3, text, {alpha=0}, 'linear')
	
end

--------------------------------------------------------------------------------
function Splash:exitedState()
end

--------------------------------------------------------------------------------
function Splash:update(dt)
	Tween.update(dt)
end

--------------------------------------------------------------------------------
function Splash:draw()
	leaf:draw()
	face:draw()
	text:draw()
end

--------------------------------------------------------------------------------
function Splash:keypressed(key, unicode)
	if key == ' ' or key == 'return' or key == 'kpenter' or key == 'escape' then
		gamestate:gotoState(NEXTSTATE)
	end
end

--------------------------------------------------------------------------------
function Splash:mousepressed(x, y, button)
	gamestate:gotoState(NEXTSTATE)
	--Let the player press things for animations!
end

--------------------------------------------------------------------------------
function Splash:joystickpressed(joystick, button)
	gamestate:gotoState(NEXTSTATE)
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.