Browse Source

added gamestate, completed Menubutton, added menu

tags/v0.0.6_dev
Niro 3 years ago
parent
commit
0016c01a0f
7 changed files with 167 additions and 40 deletions
  1. +6
    -0
      data/font.lua
  2. +1
    -0
      data/info.lua
  3. +1
    -1
      data/starshipTypes.lua
  4. +2
    -3
      import.lua
  5. +75
    -33
      main.lua
  6. +82
    -2
      src/class/Menubutton.lua
  7. +0
    -1
      src/font.lua

+ 6
- 0
data/font.lua View File

@@ -0,0 +1,6 @@
font = {
default = love.graphics.setNewFont(20),
gametitle = love.graphics.setNewFont(40)
}

return font

+ 1
- 0
data/info.lua View File

@@ -1,6 +1,7 @@
info = {} info = {}


info.name = "Questionable Örbital Mechanics" info.name = "Questionable Örbital Mechanics"
info.title = info.name
info.version = "0.0.2_dev" info.version = "0.0.2_dev"
info.authors = { info.authors = {
"NiroUwU", "NiroUwU",


+ 1
- 1
data/starshipTypes.lua View File

@@ -3,7 +3,7 @@ starshipTypes = {
orbiter = { orbiter = {
name = "Classic Orbiter", name = "Classic Orbiter",
description = "Dolor fugiat irure sit aliqua labore. Culpa voluptate occaecat anim exercitation proident sint ex dolor. Officia in labore sint Lorem ea. Ad minim aliqua aliqua non commodo qui in ea sit excepteur excepteur qui.", description = "Dolor fugiat irure sit aliqua labore. Culpa voluptate occaecat anim exercitation proident sint ex dolor. Officia in labore sint Lorem ea. Ad minim aliqua aliqua non commodo qui in ea sit excepteur excepteur qui.",
impacttolerance = 9999, impacttolerance = 0.75,
mass = 100000, -- idk, feels better but holy fuck thats a thicc ass boi xD mass = 100000, -- idk, feels better but holy fuck thats a thicc ass boi xD
speed = 0.05, speed = 0.05,
specials = {"orbitSync"}, specials = {"orbitSync"},


+ 2
- 3
import.lua View File

@@ -9,14 +9,13 @@ texture = require "textures/textures"
controls = require "data/controls" controls = require "data/controls"
settings = require "data/settings" settings = require "data/settings"
starshipTypes = require "data/starshipTypes" starshipTypes = require "data/starshipTypes"
font = require "data/font"


-- Game Source: -- Game Source:
calc = require "src/calc" calc = require "src/calc"
font = require "src/font"




-- Game Classes: -- Game Classes:
require "src/class/Menubutton"
require "src/class/Player" require "src/class/Player"
require "src/class/Gui" require "src/class/Gui"
require "src/class/Planet" require "src/class/Planet"


+ 75
- 33
main.lua View File

@@ -1,14 +1,33 @@
require "import"
debug = calc.debug
calc.isDebug = true

function love.load() function love.load()
require "import"
-- Debugging / Logging:
debug = calc.debug
calc.isDebug = true

-- Declaration: -- Declaration:
love.window.setTitle(info.name.." - v"..info.version) love.window.setTitle(info.name.." - v"..info.version)
--love.graphics.setDefaultFilter("nearest", "nearest")
width, height = love.graphics.getDimensions() width, height = love.graphics.getDimensions()


-- Gamestate:
gamestate = {
quit = "stateQUIT",
menu = "stateMENU",
game = "stateGAME"
}
GAMESTATE = gamestate.menu

-- Menubuttons:
menubutton = {
menu = {
startGame = Menubutton(20, 100, 200, 50, gamestate.game, nil, "Start Game", {255, 255, 255}, {57, 45, 66}),
quitGame = Menubutton(30, 170, 180, 40, gamestate.quit, nil, "Quit Game", {255, 255, 255}, {57, 45, 66})
},
game = {
-- Pause button or something here in future?
}
}


-- Camera: -- Camera:
cam = Camera() cam = Camera()
zoomlevel = settings.zoom.reset zoomlevel = settings.zoom.reset
@@ -152,37 +171,59 @@ end
-- MAIN -- MAIN


function love.update(dt) function love.update(dt)
-- Game Objects: if GAMESTATE == gamestate.quit then
for i=1, timewarpControls() do debug("Game has been quit, goodbye :)")
-- Physics go in here: love.event.quit(0)
updatePlanets()
player:update(dt)
end
player:throttleControls()

-- Gui:
gui:update(dt)


-- Camera: elseif GAMESTATE == gamestate.menu then
cam:lookAt(player.x, player.y) menubutton.menu.startGame:update(dt)
cameraControls() menubutton.menu.quitGame:update(dt)
--debug(player.x .. " " .. player.y)
end


function love.draw() elseif GAMESTATE == gamestate.game then
cam:attach()
-- Game Objects: -- Game Objects:
drawPlanets() for i=1, timewarpControls() do
drawEffects() -- Physics go in here:
player:draw() updatePlanets()

player:update(dt)
-- Camera Zoom Player Location Indicator: OVERWORK SOON PLS KAY; IT UGLY
if zoomlevel < 0.3 then
love.graphics.setColor(1, 1, 1, 0.2)
love.graphics.circle("fill", player.x, player.y, (1/zoomlevel)*10)
end end
cam:detach() player:throttleControls()

-- Gui:
gui:update(dt)


-- Gui: -- Camera:
gui:draw() cam:lookAt(player.x, player.y)
cameraControls()
--debug(player.x .. " " .. player.y)
end
end

function love.draw()
if GAMESTATE == gamestate.menu then
-- Game Title:
love.graphics.setColor(1, 1, 0.6)
love.graphics.setFont(font.gametitle)
love.graphics.printf(info.title, 20, 20, width, "left")

-- Buttons:
menubutton.menu.startGame:draw()
menubutton.menu.quitGame:draw()

elseif GAMESTATE == gamestate.game then
cam:attach()
-- Game Objects:
drawPlanets()
drawEffects()
player:draw()

-- Camera Zoom Player Location Indicator: OVERWORK SOON PLS KAY; IT UGLY
if zoomlevel < 0.3 then
love.graphics.setColor(1, 1, 1, 0.2)
love.graphics.circle("fill", player.x, player.y, (1/zoomlevel)*10)
end
cam:detach()

-- Gui:
gui:draw()
end
end end

+ 82
- 2
src/class/Menubutton.lua View File

@@ -1,5 +1,85 @@
Menubutton = Class {} Menubutton = Class {}


function Menubutton:init(tempX, tempY, tempW, tempH) function Menubutton:init(tempX, tempY, tempW, tempH, tempState, tempFormat, tempText, tempTC, tempBC)
-- Position and Dimensions:
self.x = tempX
self.y = tempY
self.w = tempW
self.h = tempH

-- State to jump to:
self.toState = tempState

-- Formatting:
self.format = tempFormat
if self.format == "center" or self.format == "centre" then
self.x = self.x - self.w
self.y = self.y - self.h
end

-- Text and Colours:
self.text = tempText
self.colour = {
text = tempTC,
background = tempBC
}
end



-- FUNCTIONS

function Menubutton:hover()
local hover = false
local x,y = love.mouse.getPosition()
if x > self.x and x < self.x + self.w and y > self.y and y < self.y + self.h then
hover = true
end
return hover
end

function Menubutton:click()
local click = false
if self:hover() and love.mouse.isDown(1) then
click = true
end
return click
end



-- MAIN

function Menubutton:update(dt)
if self:click() then
-- Here is room for calling effects or something... looking at you madi qwq xD
GAMESTATE = self.toState
end
end

function Menubutton:draw()
local x, y, w, h = self.x, self.y, self.w, self.h
local bg, tx = self.colour.background, self.colour.text
bg, tx = calc.colour(bg[1], bg[2], bg[3]), calc.colour(tx[1], tx[2], tx[3])

-- Hover Effects
if self:hover() then
-- Slight Colour Lightup
for i = 1, #bg do
bg[i] = bg[i]*1.1
end

-- Slight pop up effect (purly visual)
local pop = 3
x, y, w, h = x-pop, y-pop, w+pop*2, h+pop*2
end

-- Draw Background
love.graphics.setColor(bg[1], bg[2], bg[3])
love.graphics.rectangle("fill", x, y, w, h)

-- Draw Text
love.graphics.setFont(font.default)
love.graphics.setColor(tx[1], tx[2], tx[3])
love.graphics.printf(self.text, x, y, w, "center")
end end

+ 0
- 1
src/font.lua View File

@@ -1 +0,0 @@
default = love.graphics.setNewFont(20)

||||||
x
 
000:0
Loading…
Cancel
Save