2019-01-28 13:46:57 +01:00
|
|
|
-- scenes/test :: a basic test scene
|
|
|
|
|
|
|
|
--[[
|
|
|
|
Copyright © 2019 Kazhnuz
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
]]
|
|
|
|
|
2021-05-05 08:30:32 +02:00
|
|
|
local Scene = require "birb.modules.scenes"
|
2019-01-28 13:46:57 +01:00
|
|
|
local TitleScreen = Scene:extend()
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
2019-08-17 15:59:53 +02:00
|
|
|
local TweenManager = require "game.modules.tweenmanager"
|
2020-08-16 11:17:13 +02:00
|
|
|
local Background = require "game.modules.drawing.parallaxBackground"
|
2021-04-05 12:06:02 +02:00
|
|
|
local Menu = require "scenes.menus.titlescreen.menu"
|
2020-08-16 11:17:13 +02:00
|
|
|
|
|
|
|
local zoneList = require("datas.gamedata.maps.shoot.zones")
|
2019-08-17 15:59:53 +02:00
|
|
|
|
2021-04-05 12:29:45 +02:00
|
|
|
function TitleScreen:new(fromMenu)
|
2019-01-28 13:46:57 +01:00
|
|
|
TitleScreen.super.new(self)
|
|
|
|
|
2021-04-05 12:29:45 +02:00
|
|
|
local fromMenu = (fromMenu == true)
|
|
|
|
|
2019-01-28 13:46:57 +01:00
|
|
|
self.borders = gui.newBorder(424, 30, 8)
|
2021-04-11 10:32:49 +02:00
|
|
|
self.assets:batchImport("scenes.menus.assets")
|
2019-01-28 13:46:57 +01:00
|
|
|
self.assets:addImage("logo", "assets/artworks/logo.png")
|
2021-04-05 12:06:02 +02:00
|
|
|
self.assets:addTileset("charicons", "assets/sprites/characters/charicons")
|
|
|
|
self.assets.fonts["small"]:setLineHeight(16/18)
|
|
|
|
self.assets.fonts["small"]:setFilter("shadow")
|
2019-08-17 15:59:53 +02:00
|
|
|
|
|
|
|
self.tweens = TweenManager(self)
|
2020-08-16 11:17:13 +02:00
|
|
|
self:initBackground()
|
2019-08-17 15:59:53 +02:00
|
|
|
|
2021-04-05 12:29:45 +02:00
|
|
|
self.haveMenu = false
|
2019-08-17 15:59:53 +02:00
|
|
|
self.flashOpacity = 0
|
|
|
|
self.showPressStart = true
|
|
|
|
self.showPressStartTimer = 0.5
|
|
|
|
|
2021-04-05 12:29:45 +02:00
|
|
|
if (fromMenu) then
|
|
|
|
self.darkenOpacity = 0
|
|
|
|
self.canShowPressStart = true
|
|
|
|
self.borderY = 30
|
|
|
|
self.logoX = 0
|
|
|
|
else
|
|
|
|
self.darkenOpacity = 1
|
|
|
|
self.canShowPressStart = false
|
|
|
|
self.borderY = 0
|
|
|
|
self.logoX = 270
|
|
|
|
|
|
|
|
self.tweens:newTween(0.2, 0.5, {borderY = 30}, "inOutQuart")
|
|
|
|
self.tweens:newTween(0.5, 0.4, {darkenOpacity = 0}, "outExpo")
|
|
|
|
self.tweens:newTween(0.7, 0.6, {logoX = 0}, "inOutQuart")
|
|
|
|
self.tweens:newTween(1.3, 0.03, {flashOpacity = 1}, "inQuart")
|
|
|
|
self.tweens:newTween(1.45, 0.2, {flashOpacity = 0}, "outExpo")
|
|
|
|
self.tweens:newSwitch(1.4, { "canShowPressStart" })
|
|
|
|
end
|
2019-01-28 13:46:57 +01:00
|
|
|
end
|
|
|
|
|
2020-08-16 11:17:13 +02:00
|
|
|
function TitleScreen:initBackground()
|
2021-04-05 12:06:02 +02:00
|
|
|
self.background = love.graphics.newImage("datas/gamedata/maps/sti/stuff/tilescreen.png")
|
2020-08-16 11:17:13 +02:00
|
|
|
end
|
|
|
|
|
2019-01-28 13:46:57 +01:00
|
|
|
function TitleScreen:update(dt)
|
2019-08-17 15:59:53 +02:00
|
|
|
self.tweens:update(dt)
|
|
|
|
if (self.canShowPressStart) then
|
|
|
|
self.showPressStartTimer = self.showPressStartTimer - dt
|
|
|
|
if self.showPressStartTimer < 0 then
|
|
|
|
self.showPressStart = (self.showPressStart == false)
|
|
|
|
self.showPressStartTimer = 0.5
|
|
|
|
end
|
2020-08-16 11:18:51 +02:00
|
|
|
|
|
|
|
local keys = self:getKeys(1)
|
2021-04-11 10:32:49 +02:00
|
|
|
if (keys["start"].isPressed and (self.haveMenu == false)) then
|
|
|
|
self.assets:playSFX("mSelect")
|
2021-04-05 12:06:02 +02:00
|
|
|
Menu(self)
|
|
|
|
self.haveMenu = true
|
2021-04-11 10:32:49 +02:00
|
|
|
self.menusystem:setSoundFromSceneAssets("mBeep")
|
2020-08-16 11:18:51 +02:00
|
|
|
end
|
|
|
|
|
2019-08-17 15:59:53 +02:00
|
|
|
end
|
2019-01-28 13:46:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function TitleScreen:draw()
|
|
|
|
utils.graphics.resetColor()
|
2021-04-05 12:06:02 +02:00
|
|
|
local w, h = self.background:getDimensions()
|
|
|
|
love.graphics.draw(self.background,424/2,240/2,0,1,1,w/2,h/2)
|
2020-08-16 11:17:13 +02:00
|
|
|
|
|
|
|
love.graphics.setColor(0, 0, 0, self.darkenOpacity)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
|
|
|
utils.graphics.resetColor( )
|
2019-01-28 13:46:57 +01:00
|
|
|
|
2021-04-05 12:06:02 +02:00
|
|
|
local w, h = self.assets.images["logo"]:getDimensions()
|
|
|
|
self.assets:drawImage("logo", 240 - 32, 80 - self.logoX, 0, 1, 1, w/2, h/2)
|
2019-01-28 13:46:57 +01:00
|
|
|
|
2019-08-17 15:59:53 +02:00
|
|
|
if (self.canShowPressStart) and (self.showPressStart) then
|
2021-04-11 10:32:49 +02:00
|
|
|
local w = self.assets.fonts["title"]:getWidth("PRESS START")
|
|
|
|
self.assets.fonts["title"]:print("PRESS START", 424/2, 240/1.33, "center", 0, 1, 1)
|
2019-08-17 15:59:53 +02:00
|
|
|
end
|
2019-01-28 13:46:57 +01:00
|
|
|
|
2019-08-17 15:59:53 +02:00
|
|
|
love.graphics.setColor(1, 1, 1, self.flashOpacity)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
|
|
|
utils.graphics.resetColor( )
|
2021-04-05 14:20:25 +02:00
|
|
|
end
|
2021-04-05 12:06:02 +02:00
|
|
|
|
2021-04-05 14:20:25 +02:00
|
|
|
function TitleScreen:drawOverTransition()
|
2021-04-05 12:06:02 +02:00
|
|
|
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
|
|
|
|
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
|
2021-04-05 14:20:25 +02:00
|
|
|
self.assets.fonts["small"]:draw("v" .. game.version, 424 - 44, 240 + 10 - self.borderY)
|
2019-01-28 13:46:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return TitleScreen
|