Page 1 of 1

Just an idea I had

Posted: Tue Aug 25, 2015 11:50 pm
by eqnox
Today in school I was thinking about stuff that I can do for my game and I thought of a animation of sorts that I could use.
The idea would be that when you click start the animation would begin and under it would lie the game.
This is just an example of the idea and is not very fancy.

Re: Just an idea I had

Posted: Wed Aug 26, 2015 11:44 am
by NickRock
Pretty cool idea!

An other way you could do the same this is to draw a rectangle from top to bottom and change the game state when it reaches the height of your screen, like this

Code: Select all

function love.load()
	img = love.graphics.newImage('screen.png')
	w = love.graphics.getWidth()
	h = 0
	go = true
end

function love.update(dt)
	if go == true then
		h = h + (500 * dt)
	end
	
	if h >= love.graphics.getHeight() then
		go = false
		--change game state
	end
end

function love.draw()
	love.graphics.draw(img,0,0)
	love.graphics.setColor(255,255,255) -- or whatever color you want
	love.graphics.rectangle('fill',0,0,w,h)
end

Re: Just an idea I had

Posted: Wed Aug 26, 2015 12:31 pm
by Ulydev
For some of my games, I'm using a modified version of stateswitcher.lua that allows for scene transitions.

You simply use it like

Code: Select all

state.switch("game", "fromLeft", function() print("I'm done !") end)
--state.switch(scene, transition, oncomplete)
Transitions include fromLeft, fromRight, fromTop, fromBottom

Also, you need to use love.updateScene(dt) and love.drawScene() instead of love.update(dt) and love.draw().

Code: Select all

--[[
State switcher class: stateswitcher.lua
Author: Daniel Duris, (CC-BY) 2014
dusoft[at]staznosti.sk
http://www.ambience.sk

License: CC-BY 4.0
This work is licensed under the Creative Commons Attribution 4.0
International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by/4.0/ or send a letter to
Creative Commons, 444 Castro Street, Suite 900, Mountain View,
California, 94041, USA.

modified by some guy
]]--

passvar={}
state={}
s_g = {updateCurrent = nil, updateOld = nil, drawCurrent = nil, drawOld = nil, unload = nil, delta = nil, translate = nil}

function state.switch(state, transition, oncompletetransition)
  if love.unload then love.unload() end
  passvar={}
  local matches={}
  for match in string.gmatch(state,"[^;]+") do
    matches[#matches+1]=match
  end
  state=matches[1]
  matches[1]=nil
  if (matches[2]~=nil) then
    for i,match in pairs(matches) do
       passvar[#passvar+1]=match
    end
  end
  -- remove info from metatable about state loaded to allow for new require of the state
  package.loaded[state]=false
  s_g.updateOld = love.updateScene
  s_g.drawOld = love.drawScene
  s_g.unload = love.unload
  require(state)
  s_g.updateCurrent = love.updateScene
  s_g.drawCurrent = love.drawScene
  if transition == nil then
    s_g.updateOld = nil
    s_g.drawOld = nil
  else
    s_g.delta = 1
    if transition == "fromLeft" then
      
      s_g.translate = {x = -WWIDTH, y = 0}
      
    elseif transition == "fromRight" then
      
      s_g.translate = {x = WWIDTH, y = 0}
      
    elseif transition == "fromTop" then
      
      s_g.translate = {x = 0, y = -WHEIGHT}
      
    elseif transition == "fromBottom" then
      
      s_g.translate = {x = 0, y = WHEIGHT}
      
    end
    flux.to(s_g, 0.75, {delta = 0}):ease("quadout"):oncomplete(function()
      s_g.updateOld = nil
      s_g.drawOld = nil
      if s_g.unload then s_g.unload() end
      oncompletetransition()
    end)
  end
  love.load()
end

function state.clear()
  passvar=nil
end

function love.update(dt)
  s_g.updateCurrent(dt)
  if s_g.updateOld then s_g.updateOld(dt) end
end

function love.draw()
  --Manager:drawF(1)
  love.graphics.push()
  if s_g.drawOld then
    if s_g.delta and s_g.delta > 0 then
      love.graphics.translate(s_g.delta*s_g.translate.x-s_g.translate.x, s_g.delta*s_g.translate.y-s_g.translate.y)
    end
    s_g.drawOld()
  end
  if s_g.delta and s_g.delta > 0 then
    love.graphics.translate(s_g.translate.x, s_g.translate.y)
  end
  s_g.drawCurrent()
  love.graphics.pop()
  --Manager:drawF(2)
end

return state