
-- lacht nicht über meinen mist hyper lol

local starScroller=require("starscroller")
local bouncingBall=require("bouncing_ball")
local scrollTextBg=require("scrolltext_bg")
local scrollText=require("scrolltext")
local dragonMageddon=require("dragonmageddon")
local dragons=require("dragons")
local logicrunchLogo=require("logicrunch_logo")
local copperBars=require("copper_bars")
local coloredLines=require("colored_lines")
local tunnel=require("tunnel")
local animedragon=require("animedragon")
local twirledLines=require("twirledlines")
local dragonIcons=require("dragon_icons")
local greetings=require("greetings")
local spaceshiphud=require("spaceship-hud")
local matrix=require("matrix")
local hudText=require("hudtext")
local colordots=require("colordots")
local texturetunnel=require("texturetunnel")
local dragonvortex=require("dragonvortex")
local cubes=require("cubes")
local logicrunchlogo5=require("logicrunchlogo5")
local endscreen=require("endscreen")
local c64loading=require("c64loading")
local dragonchaos=require("dragonchaos")
local Starfield=require("starfield")

local state={
windowWidth=1920,windowHeight=1080,
screenWidth=1920,screenHeight=1080,
renderCanvas=nil,timePassed=0,isReadyToShow=false,delayTime=2,additionalDelay=4,
fade={alpha=0,duration=1,isFading=false,triggered={false,false,false,false,false,false,false,false,false,false,false,false,false,false}},
bgFade={alpha=1,duration=28.5,isFading=false,startFadingTime=77},
scrollTextBgTriggeredUp=false,scrollTextBgTriggeredDown=false,
scrollTextVisible=true,copperBarsVisible=true,coloredLinesVisible=false,
twirledLinesActive=false,greetingsActive=false,spaceshiphudActive=false,
matrixActive=false,hudTextActive=false,colordotsActive=false,
texturetunnelActive=false,dragonvortexActive=false,cubesActive=false,
logicrunchlogo5Active=false,endscreenActive=false,c64loadingActive=false,
starfieldActive=false,starfieldActivationTime=108.99,starScrollerVisible=true,
music=nil,twirledFade={alpha=1,duration=1.772,isFading=false},debugText="",
mainFont=nil,counterFont=nil,dragonchaosActive=false
}
function love.load()
love.window.setMode(state.windowWidth,state.windowHeight,{
fullscreen=false, fullscreentype="exclusive", vsync=true
})
love.window.setTitle("Drakmageddon by Logicrunch 2026")
love.graphics.setBackgroundColor(68/255,21/255,64/255)
love.graphics.setLineStyle("rough")
love.graphics.setDefaultFilter("nearest","nearest")
state.renderCanvas=love.graphics.newCanvas(state.screenWidth,state.screenHeight)
state.renderCanvas:setFilter("nearest","nearest")
state.mainFont=love.graphics.newFont("pixelcraft.ttf",144)
love.graphics.setFont(state.mainFont)
state.counterFont=love.graphics.newFont("pixelcraft.ttf",36)
state.music=love.audio.newSource("music.mp3","stream")
state.music:setLooping(false)

if endscreen.load then endscreen.load() end
if starScroller.load then starScroller.load() end
if bouncingBall.load then bouncingBall.load() end
if scrollTextBg.load then scrollTextBg.load() end
if scrollText.load then scrollText.load() end
if dragonMageddon.load then dragonMageddon.load() end
if dragons.load then dragons.load() end
if logicrunchLogo.load then logicrunchLogo.load() end
if copperBars.load then copperBars.load() end
if coloredLines.load then coloredLines.load() end
if tunnel.load then tunnel.load() end
if animedragon.load then animedragon.load() end
if twirledLines.load then twirledLines.load() end
if dragonIcons.load then dragonIcons.load() end
if greetings.load then greetings.load() end
if spaceshiphud.load then spaceshiphud.load() end
if matrix.load then matrix.load() end
if hudText.load then hudText.load() end
if colordots.load then colordots.load() end
if texturetunnel.load then texturetunnel.load() end
if dragonvortex.load then dragonvortex.load() end
if cubes.load then cubes.load() end
if logicrunchlogo5.load then logicrunchlogo5.load() end
if c64loading.load then c64loading.load() end
if dragonchaos.load then dragonchaos.load() end
Starfield.load(108000,state.screenWidth,state.screenHeight)
end

local function triggerFade()
state.fade.alpha=0.63
state.fade.isFading=true
end

function love.update(dt)
local origGetWidth=love.graphics.getWidth
local origGetHeight=love.graphics.getHeight
love.graphics.getWidth=function() return state.screenWidth end
love.graphics.getHeight=function() return state.screenHeight end

state.timePassed=state.timePassed+dt
if not state.isReadyToShow and state.timePassed>=state.delayTime then state.isReadyToShow=true state.music:play() end
if state.isReadyToShow and dragons.update then dragons.update(dt,state.timePassed) end
if state.isReadyToShow and state.timePassed>=state.delayTime+state.additionalDelay and not state.scrollTextBgTriggeredUp then scrollTextBg.setVisible(true) scrollTextBg.startMovingUp() state.scrollTextBgTriggeredUp=true end
if not state.hudTextActive and state.timePassed>=116.48 then state.hudTextActive=true end
if state.isReadyToShow and not state.fade.triggered[1] and state.timePassed>=9.6 then triggerFade() state.fade.triggered[1]=true end
if state.isReadyToShow and not state.fade.triggered[2] and state.timePassed>=24.6 then triggerFade() state.fade.triggered[2]=true end
if state.isReadyToShow and not state.fade.triggered[3] and state.timePassed>=39.6 then triggerFade() state.fade.triggered[3]=true end
if state.isReadyToShow and not state.fade.triggered[4] and state.timePassed>=54.6 then triggerFade() state.fade.triggered[4]=true state.coloredLinesVisible=true end
if state.isReadyToShow and not state.fade.triggered[5] and state.timePassed>=62.1 then triggerFade() state.fade.triggered[5]=true end
if state.isReadyToShow and not state.fade.triggered[6] and state.timePassed>=62.1 then triggerFade() state.fade.triggered[6]=true copperBars.active=true end
if state.isReadyToShow and not state.fade.triggered[7] and state.timePassed>=69.61 then triggerFade() state.fade.triggered[7]=true state.copperBarsVisible=false state.coloredLinesVisible=false state.twirledLinesActive=true state.greetingsActive=true end
if state.isReadyToShow and not state.scrollTextBgTriggeredDown and state.timePassed>=54.6 then scrollTextBg.startMovingDown() state.scrollTextBgTriggeredDown=true state.scrollTextVisible=false end
if not state.starfieldActive and state.timePassed>=state.starfieldActivationTime then state.starfieldActive=true state.starScrollerVisible=false state.twirledLinesActive=false state.spaceshiphudActive=true end
if state.isReadyToShow and not state.fade.triggered[8] and state.timePassed>=108.99 then triggerFade() state.fade.triggered[8]=true end
if not state.matrixActive and state.timePassed>=123.97 then state.matrixActive=true end
if not state.colordotsActive and state.timePassed>=138.98 then end
if not state.dragonvortexActive and state.timePassed>=138.98 then end
if state.isReadyToShow and state.timePassed>=138.98 then if not state.fade.triggered[9] then triggerFade() state.fade.triggered[9]=true end state.matrixActive=false state.starfieldActive=false state.spaceshiphudActive=false state.hudTextActive=false state.colordotsActive=true state.dragonvortexActive=true end
if not state.logicrunchlogo5Active and state.timePassed>=154 then state.logicrunchlogo5Active=true end
if not state.cubesActive and state.timePassed>=154 then state.cubesActive=true end
if state.timePassed>=168.84 then state.logicrunchlogo5Active=false end
if state.isReadyToShow and state.timePassed>=154 then if not state.fade.triggered[10] then triggerFade() state.fade.triggered[10]=true end state.dragonvortexActive=false end
if state.isReadyToShow and state.timePassed>=168.89 then if not state.fade.triggered[11] then triggerFade() state.fade.triggered[11]=true end end
if not state.texturetunnelActive and state.timePassed>=168.89 then state.texturetunnelActive=true end
if state.isReadyToShow and state.timePassed>=168.89 then if not state.fade.triggered[12] then triggerFade() state.fade.triggered[12]=true end state.colordotsActive=false end
if state.isReadyToShow and state.timePassed>=183.89 then if not state.fade.triggered[13] then triggerFade() state.fade.triggered[13]=true end state.cubesActive=false state.dragonchaosActive=true end
if state.timePassed>=204.56 then state.c64loadingActive=true state.endscreenActive=false end
if state.timePassed>=207.14 then state.c64loadingActive=false end
if state.timePassed>=207.15 then love.event.quit() end
if state.timePassed>=198.88 then if not state.fade.triggered[14] then triggerFade() state.fade.triggered[14]=true end state.dragonvortexActive=false state.dragonchaosActive=false state.texturetunnelActive=false end
if state.timePassed>=199.00 and not state.endscreenActive then state.endscreenActive=true end
if state.timePassed>=199.00 then if not state.fade.triggered[15] then triggerFade() state.fade.triggered[15]=true end end
if state.timePassed>=205.00 and state.endscreenActive then state.endscreenActive=false end
if state.endscreenActive and endscreen.update then endscreen.update(dt) end
if state.isReadyToShow and starScroller.update and state.starScrollerVisible then starScroller.update(dt) end
if state.isReadyToShow and bouncingBall.update then bouncingBall.update(dt,state.timePassed) end
if scrollTextBg.update then scrollTextBg.update(dt) end
if state.isReadyToShow and scrollText.update then scrollText.update(dt) end
if state.isReadyToShow and dragonMageddon.update then dragonMageddon.update(dt,state.timePassed) end
if state.isReadyToShow and logicrunchLogo.update then logicrunchLogo.update(dt,state.timePassed) end
if state.copperBarsVisible and copperBars.update then copperBars.update(dt) end
if state.coloredLinesVisible and coloredLines.update then coloredLines.update(dt) end
if state.isReadyToShow and tunnel.update then tunnel.update(dt,state.timePassed) end
if state.isReadyToShow and animedragon.update then animedragon.update(dt,state.timePassed) end
if state.twirledLinesActive and twirledLines.update then twirledLines.update(dt) end
if state.isReadyToShow and dragonIcons.update then dragonIcons.update(dt,state.timePassed) end
if state.greetingsActive and greetings.update then greetings.update(dt) end
if state.spaceshiphudActive and spaceshiphud.update then spaceshiphud.update(dt) end
if state.matrixActive and matrix.update then matrix.update(dt) end
if state.hudTextActive and hudText.update then hudText.update(dt) end
if state.colordotsActive and colordots.update then colordots.update(dt) end
if state.texturetunnelActive and texturetunnel.update then texturetunnel.update(dt) end
if state.dragonvortexActive and dragonvortex.update then dragonvortex.update(dt) end
if state.cubesActive and cubes.update then cubes.update(dt) end
if state.c64loadingActive and c64loading.update then c64loading.update(dt) end
if state.logicrunchlogo5Active and logicrunchlogo5.update then logicrunchlogo5.update(dt,state.timePassed) end
if state.starfieldActive then Starfield.update(dt) end
if state.dragonchaosActive and dragonchaos.update then dragonchaos.update(dt) end
if state.fade.isFading and state.fade.alpha>0 then state.fade.alpha=state.fade.alpha-(0.9*dt) if state.fade.alpha<=0 then state.fade.alpha=0 state.fade.isFading=false end end
if state.bgFade.isFading and state.bgFade.alpha>0 then state.bgFade.alpha=state.bgFade.alpha-(1/state.bgFade.duration*dt) if state.bgFade.alpha<=0 then state.bgFade.alpha=0 state.bgFade.isFading=false end end

love.graphics.getWidth=origGetWidth
love.graphics.getHeight=origGetHeight
end
function love.draw()
local origGetWidth=love.graphics.getWidth
local origGetHeight=love.graphics.getHeight
love.graphics.getWidth=function() return state.screenWidth end
love.graphics.getHeight=function() return state.screenHeight end
love.graphics.setCanvas(state.renderCanvas)
if state.timePassed>=236 then
love.graphics.clear(0,0,0,state.bgFade.alpha,false,true)
else
love.graphics.clear(68/255,21/255,64/255,state.bgFade.alpha,false,true)
end

if state.texturetunnelActive and texturetunnel.draw then texturetunnel.draw() end
if state.isReadyToShow and state.starScrollerVisible and starScroller.draw then starScroller.draw() end
if state.isReadyToShow and tunnel.draw then tunnel.draw() end
if state.copperBarsVisible and copperBars.draw then copperBars.draw() end
if state.coloredLinesVisible and coloredLines.draw then coloredLines.draw() end
if state.isReadyToShow and dragonIcons.draw then dragonIcons.draw() end
if state.isReadyToShow and dragons.draw then dragons.draw() end
if state.isReadyToShow and dragonMageddon.draw then dragonMageddon.draw() end
if state.isReadyToShow and logicrunchLogo.draw then logicrunchLogo.draw() end
if state.isReadyToShow and bouncingBall.draw then bouncingBall.draw() end
if scrollTextBg.draw then scrollTextBg.draw() end
if state.isReadyToShow and state.scrollTextVisible and scrollText.draw then scrollText.draw() end
if state.isReadyToShow and animedragon.draw then animedragon.draw() end
if state.matrixActive and matrix.draw then matrix.draw() end

if state.fade.alpha>0 then
love.graphics.setColor(1,1,1,state.fade.alpha)
love.graphics.rectangle("fill",0,0,state.screenWidth,state.screenHeight)
love.graphics.setColor(1,1,1,1)
end

if state.twirledLinesActive and twirledLines.draw then love.graphics.setColor(1,1,1,state.twirledFade.alpha) twirledLines.draw() end
if state.endscreenActive and endscreen.draw then endscreen.draw() end
if state.greetingsActive and greetings.draw then greetings.draw() end
if state.starfieldActive then Starfield.draw() end
if state.spaceshiphudActive and spaceshiphud.draw then spaceshiphud.draw() end
if state.hudTextActive and hudText.draw then hudText.draw() end
if state.colordotsActive and colordots.draw then colordots.draw() end
if state.dragonvortexActive and dragonvortex.draw then dragonvortex.draw() end
if state.cubesActive and cubes.draw then cubes.draw() end
if state.dragonchaosActive and dragonchaos.draw then dragonchaos.draw() end
if state.logicrunchlogo5Active and logicrunchlogo5.draw then logicrunchlogo5.draw() end
if state.c64loadingActive and c64loading.draw then c64loading.draw() end

if state.fade.triggered[15] and state.fade.alpha>0 then
love.graphics.setColor(1,1,1,state.fade.alpha)
love.graphics.rectangle("fill",0,0,state.screenWidth,state.screenHeight)
love.graphics.setColor(1,1,1,1)
end

love.graphics.setCanvas()
love.graphics.getWidth=origGetWidth
love.graphics.getHeight=origGetHeight
local s  = state.windowWidth / state.screenWidth
local dx = math.floor((state.windowWidth  - state.screenWidth  * s) / 2)
local dy = math.floor((state.windowHeight - state.screenHeight * s) / 2)
love.graphics.clear(0,0,0,1)
love.graphics.setColor(1,1,1,1)
love.graphics.draw(state.renderCanvas, dx, dy, 0, s, s)
local timeString=string.format("%.2f - %d fps",state.timePassed,love.timer.getFPS())
love.graphics.setFont(state.counterFont)
love.graphics.setColor(1,1,1,1)

-- debug-text top left corner, der sekunden.millisekunden und FPS shit -------------------------
-- love.graphics.print(timeString,10,10) -------------------------------------------------------

love.graphics.setFont(state.mainFont)
end
function love.keypressed(key,scancode,isrepeat)
if key=="escape" then love.event.quit() return end
if key=="left" then state.timePassed=state.timePassed-5 if state.timePassed<0 then state.timePassed=0 end end
if key=="right" then state.timePassed=state.timePassed+5 end
end
function love.run()
if love.load then love.load(love.arg.parseGameArguments(arg),arg) end
if love.timer then love.timer.step() end
local dt=0
local accumulator=0
local frameTime=1/60
local paused=false
while true do
if love.event then love.event.pump() for name,a,b,c,d,e,f in love.event.poll() do if name=="quit" then if not love.quit or not love.quit() then return a end end love.handlers[name](a,b,c,d,e,f) end end
if love.keyboard.isDown({'p'}) then
love.timer.step()
else
if love.timer then love.timer.step() dt=love.timer.getDelta() accumulator=accumulator+dt while accumulator>=frameTime do if love.update then love.update(frameTime) end accumulator=accumulator-frameTime end end
if love.graphics and love.graphics.isActive() then love.graphics.clear() love.draw() love.graphics.present() end
end end end
