Commits

Danny Fritz committed 04a6abe

Added LOVE2d to the splash.

Comments (0)

Files changed (9)

+
+Programming Libraries
+*KIKITO MiddleClass https://github.com/kikito/middleclass
+*KIKITO Stateful https://github.com/kikito/middleclass-extras
+*KIKITO Tween.lua https://github.com/kikito/tween.lua/
+
+Art Assets
+
+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.
 
 function love.conf(t)
-  t.title = 'Splash'
+  t.title = 'TechnoCat Splash'
   t.author = 'Danny \'TechnoCat\' Fritz dannyfritz@gmail.com'
   t.identity = nil
   t.release = false
 Stateful = require 'lib.middleclass.stateful.stateful'
 
 require 'lua.Gamestate'
+require 'splash.LoveSplash'
 require 'splash.Splash'
 require 'lua.Menu'
 
+function love.run()
+  if love.load then love.load(arg) end
+  local dt = 0
+  while true do
+    if love.timer then
+      love.timer.step()
+      dt = love.timer.getDelta()
+      if dt>1/60 then
+      	dt = 1/60
+      end
+    end
+    if love.update then love.update(dt) end
+    if love.graphics then
+      love.graphics.clear()
+      if love.draw then love.draw() end
+    end
+    if love.event then
+      for e,a,b,c in love.event.poll() do
+        if e == "q" then
+          if not love.quit or not love.quit() then
+            if love.audio then
+               love.audio.stop()
+            end
+            return
+          end
+        end
+        love.handlers[e](a,b,c)
+      end
+    end
+    if love.timer then love.timer.sleep(0.001) end
+    if love.graphics then love.graphics.present() end
+  end
+end
+
 
 --------------------------------------------------------------------------------
 function love.load()
 	gamestate = Gamestate:new()
-	gamestate:gotoState('Splash')
+	gamestate:gotoState('LoveSplash')
 end
 
 --------------------------------------------------------------------------------

ref/splash.psd

Added
New image

splash/LoveSplash.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 LoveSplash = Gamestate:addState('LoveSplash')
+
+local Tween = require 'lib.tween.tween'
+local Object = require 'splash.Object'
+
+local NEXTSTATE = 'Splash'
+
+local splash
+local orange
+local stars
+local number_stars = 20
+
+--------------------------------------------------------------------------------
+function LoveSplash:enteredState()
+	love.graphics.setBackgroundColor(131, 192, 240)
+
+	stars = {}
+	local star_image = love.graphics.newImage('splash/star.png')
+	for i=0, number_stars do
+		local p = love.graphics.newParticleSystem( star_image, 128 )
+		p:setDirection(-math.pi/2)
+		p:setSpread(math.pi)
+		p:setColors(31,120,183,100, 31,120,183,0)
+		p:setEmissionRate(2)
+		p:setSpeed(100, 150)
+		p:setGravity(0, 0)
+		p:setSizes(0.2, 0.1)
+		p:setSizeVariation(1)
+		p:setLifetime(-1)
+		p:setParticleLife(2)
+		p:setRadialAcceleration(-120)
+		p:setTangentialAcceleration(0)
+		p:setSpin(-1,1, 1)
+		p:start()
+		table.insert(stars, p)
+	end
+
+	orange={alpha=0}
+
+	local splash_image = love.graphics.newImage('splash/love-splash-no-stars.png')
+	splash = Object:new(splash_image, {alpha=0})
+	Tween(1, splash, {alpha=255}, 'linear',
+	Tween, 1, splash, {}, 'linear',
+	Tween, 0.5, orange, {alpha=255}, 'linear',
+	gamestate.gotoState, gamestate, NEXTSTATE)
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:exitedState()
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:update(dt)
+	Tween.update(dt)
+	for _,p in pairs(stars) do
+		p:update(dt)
+	end
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:draw()
+	love.graphics.setColor(255, 255, 255, 255)
+	splash:draw()
+	for i=1, #stars do
+		love.graphics.draw(stars[i], 800*i/#stars, 640)
+	end
+	love.graphics.setColor(254, 153, 0, orange.alpha)
+	love.graphics.rectangle('fill', 0,0, 800, 600)
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:keypressed(key, unicode)
+	if key == ' ' or key == 'return' or key == 'kpenter' or key == 'escape' then
+		gamestate:gotoState(NEXTSTATE)
+	end
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:mousepressed(x, y, button)
+	gamestate:gotoState(NEXTSTATE)
+end
+
+--------------------------------------------------------------------------------
+function LoveSplash:joystickpressed(joystick, button)
+	gamestate:gotoState(NEXTSTATE)
+end

splash/Splash.lua

 local Object = require 'splash.Object'
 
 local NEXTSTATE = 'Menu'
-local WIDTH = 800
-local HEIGHT = 600
 
 local leaf
 local face
 local text
 local pixel_effect
-local old_background_color
-local music
 
 --------------------------------------------------------------------------------
 function Splash:enteredState()
-	old_background_color = {love.graphics.getBackgroundColor()}
 	love.graphics.setBackgroundColor(254, 153, 0)
 
-	music = love.audio.newSource('splash/music.ogg')
-	music:play()
+	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')
 
-	local leaf_image = love.graphics.newImage('splash/leaf.png')
-	leaf = Object:new(leaf_image, {x=800, y=-120})
-	Tween(5, leaf, {x=100}, 'inOutSine',
-			Tween, 4, leaf, {x=520}, 'inOutSine')
-	Tween(5, leaf, {y=-40}, 'outInSine',
-			Tween, 4, leaf, {y=10}, 'outInSine')
-	Tween(5, leaf, {angle=-0.5}, 'inOutSine',
-			Tween, 4, leaf, {angle=0}, 'inOutSine')
+	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(7.5, face, {}, 'linear',
-			Tween, 1.5, face, {scale_x=1, scale_y=1}, 'linear')
-	Tween(8, face, {}, 'linear',
-			Tween, 1.5, face, {alpha=255}, 'linear')
+	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(8, text, {}, 'linear',
-			Tween, 1, text, {alpha=255}, 'linear')
+	Tween(1, text, {}, 'linear',
+			Tween, 0.4, text, {alpha=255}, 'linear')
 	
-	Tween(12, leaf, {}, 'linear',
-			Tween, 2, leaf, {alpha=0}, 'linear',
+	--SWITCH ON PIXELSHADER
+	Tween(2, leaf, {}, 'linear',
+			Tween, 0.3, leaf, {alpha=0}, 'linear',
 			gamestate.gotoState, gamestate, NEXTSTATE)
 	
-	Tween(12, face, {}, 'linear',
-			Tween, 2, face, {alpha=0}, 'linear')
+	Tween(2, face, {}, 'linear',
+			Tween, 0.3, face, {alpha=0}, 'linear')
 	
-	Tween(12, text, {}, 'linear',
-			Tween, 2, text, {alpha=0}, 'linear')
+	Tween(2, text, {}, 'linear',
+			Tween, 0.3, text, {alpha=0}, 'linear')
 	
 end
 
 --------------------------------------------------------------------------------
 function Splash:exitedState()
-	love.graphics.setBackgroundColor(unpack(old_background_color))
 end
 
 --------------------------------------------------------------------------------

splash/love-splash-no-stars.png

Added
New image

splash/star.png

Added
New image