aboutsummaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
authorIndrajith K L2022-02-27 01:15:31 +0530
committerIndrajith K L2022-02-27 01:15:31 +0530
commit62ff5245c26c305e35a2903cc64a60cb20718e96 (patch)
tree9042f9917e77b584b0ceb421166221ef7777a5d1 /scenes
downloadYEAD-62ff5245c26c305e35a2903cc64a60cb20718e96.tar.gz
YEAD-62ff5245c26c305e35a2903cc64a60cb20718e96.tar.bz2
YEAD-62ff5245c26c305e35a2903cc64a60cb20718e96.zip
Initial Commit
* ECS - In-Progress * GameStates - Skeleton Implemented * Library Integrations - Completed * Levels - In-Progress
Diffstat (limited to 'scenes')
-rw-r--r--scenes/level1_scene.lua35
-rw-r--r--scenes/menu_scene.lua79
2 files changed, 114 insertions, 0 deletions
diff --git a/scenes/level1_scene.lua b/scenes/level1_scene.lua
new file mode 100644
index 0000000..83d676e
--- /dev/null
+++ b/scenes/level1_scene.lua
@@ -0,0 +1,35 @@
+level1 = {} -- Level1 State
+
+Map = require("utils.map")
+-- imports
+require("utils.constants")
+
+local map = nil
+
+function level1:init()
+ constants.resetColors()
+ map = Map("level1")
+end
+
+function level1:enter(previous)
+
+end
+
+function level1:update(dt)
+ map.update(dt)
+end
+
+function level1:draw()
+ map.draw()
+ --love.graphics.print("Level 1", 100, 200)
+end
+
+function level1:keypressed(key, scancode)
+
+end
+
+function level1:leave()
+ map = nil
+end
+
+return level1 \ No newline at end of file
diff --git a/scenes/menu_scene.lua b/scenes/menu_scene.lua
new file mode 100644
index 0000000..a513d6d
--- /dev/null
+++ b/scenes/menu_scene.lua
@@ -0,0 +1,79 @@
+menu = {} -- Menu Game State
+
+local Timer = require "libs.hump.timer"
+local Gamestate = require("libs.hump.gamestate")
+
+-- scenes
+require("scenes.level1_scene");
+
+local titleFontSize = 25
+local msgFontSize = 15
+local defaultFontFactor = 8
+local windowWidth = love.graphics.getWidth()
+local windowHeight = love.graphics.getHeight()
+
+function menu:init()
+ print("Entering Menu")
+ titleFont = love.graphics.newFont('assets/fonts/minecraftia.ttf', titleFontSize)
+ startMsgFont = love.graphics.newFont('assets/fonts/minecraftia.ttf', msgFontSize)
+ music = love.audio.newSource("assets/music/Stevia Sphere - Drum machine dreams.ogg", "stream")
+ music:setLooping(true)
+ msgFontColor = {0, 0, 0}
+ titleFontColor = {1, 1, 1}
+ starfield = generateStarfield()
+
+ fadeIn = function()
+ Timer.tween(0.5, msgFontColor, {1, 1, 1}, 'linear', fadeOut)
+ end
+
+ fadeOut = function()
+ Timer.tween(0.5, msgFontColor, {0, 0, 0}, 'linear', fadeIn)
+ end
+
+ fadeIn()
+ music:play()
+end
+
+function menu:enter(previous)
+
+end
+
+function menu:leave()
+ music:stop()
+end
+
+function menu:update(dt)
+ psystem:update(dt)
+ Timer.update(dt)
+end
+
+function menu:draw()
+ love.graphics.setFont(titleFont)
+ love.graphics.setColor(titleFontColor)
+ love.graphics.draw(starfield, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5)
+ love.graphics.print("Enemy is in Another Dungeon",(windowWidth * 0.5) - (titleFontSize * defaultFontFactor), (windowHeight * 0.5) - 50)
+
+ love.graphics.setFont(startMsgFont)
+ love.graphics.setColor(msgFontColor)
+ love.graphics.print("Press X to START", (windowWidth * 0.5) - (msgFontSize * (defaultFontFactor/1.5)), windowHeight - 50)
+
+end
+
+function menu:keyreleased(key, scancode)
+ if scancode == 'x' then
+ Gamestate.switch(level1)
+ end
+end
+
+function generateStarfield()
+ image = love.graphics.newImage("assets/images/particle.png")
+ psystem = love.graphics.newParticleSystem(image, 500)
+ psystem:setParticleLifetime(2, 15) -- Particles live at least 2s and at most 5s.
+ psystem:setEmissionRate(500)
+ psystem:setSizeVariation(1)
+ psystem:setLinearAcceleration(-20, -20, 20, 20) -- Random movement in all directions.
+ psystem:setColors(1, 1, 1, 1, 1, 1, 1, 0) -- Fade to transparency.
+ return psystem
+end
+
+return menu \ No newline at end of file