Hi All, How do you guys put together your state system.
The way Love is at the moment, it's as if it expects your entire program in once script. I've tried stateswitcher, which doesn't work the way I expected it to, and I'm now looking at HUMP, which looks extremely complicated to just switch over to another state. Maybe i'm missing something.
Also, what is the point of love.load when all my variables can be loaded outside of love.load as well?
State System
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: State System
Another thing, why does Love work the way it does? Why put all the update and draw methods in there own functions? Why not just have a loop with both of them in?
Re: State System
Actually it's pretty simple:TheMeq wrote: ...and I'm now looking at HUMP, which looks extremely complicated to just switch over to another state. Maybe i'm missing something.
Code: Select all
-- main.lua
Gamestate = require("hump.Gamestate")
Game = require("Game")
function love.load()
Gamestate.switch(Game)
Gamestate.registerEvents()
end
The code in your State should look like this:
Code: Select all
local Game = {}
function Game:init() -- gets called the first time you load this state
end
function Game:enter() -- gets called everytime you switch to this state
end
function Game:leave() -- gets called when you switch to another state
end
function Game:update(dt)
end
function Game:draw()
end
return Game
It's possible to pass command line arguements from outside of the application to love.load. That might be a reason.TheMeq wrote: Also, what is the point of love.load when all my variables can be loaded outside of love.load as well?
Re: State System
How should the files be laid out in relation to my main.lua?
Would I create a game.lua and put those function in that file?
Thanks
Would I create a game.lua and put those function in that file?
Thanks
Re: State System
Ok, I think I got it, but it's throwing up an error.
hump/gamestate.lua:40: attempt to index local 'to' (a boolean value)
hump/gamestate.lua:40: attempt to index local 'to' (a boolean value)
- Attachments
-
- BitRhythm.zip
- (75.77 KiB) Downloaded 150 times
Re: State System
Because you can't always draw on the screen whenever you want.TheMeq wrote:Another thing, why does Love work the way it does? Why put all the update and draw methods in there own functions? Why not just have a loop with both of them in?
Like for example, if vsync is involved.
Also, no reason to draw on the screen more frequently than 1/60 of a second as your eyes won't even notice it.
Re: State System
Thanks for clarifying ivan ^_^ivan wrote:Because you can't always draw on the screen whenever you want.TheMeq wrote:Another thing, why does Love work the way it does? Why put all the update and draw methods in there own functions? Why not just have a loop with both of them in?
Like for example, if vsync is involved.
Also, no reason to draw on the screen more frequently than 1/60 of a second as your eyes won't even notice it.
Re: State System
Figured it out, forgot to return at the end.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: State System
Man be careful with double posting. The admins are old(jk) and not used to the newer forms of communication where double posting is acceptable.
Re: State System
Sorry >_<
Who is online
Users browsing this forum: Bing [Bot] and 65 guests