game state switcher class

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

game state switcher class

Post by dusoft » Mon Apr 21, 2014 4:05 am

Hello,

would anyone be interested in a state switcher library/class based on the files (one .lua file=one state) as opposed to most of the state switchers linked from LOVE2D Wiki?

I created such a class for my game and now I can release it, if there you have need for it.

Basic concept simplified is as follows:
main.lua - loads everything and switches to any other state, e.g. mainmenu.lua
mainmenu.lua - main game menu - state switch e.g. based on the menu option...
newgame.lua - new game launch
credits.lua - credits etc.
etc.

Any state can switch to any other state. Best thing is you can overload (redeclare) any function, so you can have separate keyboard handling love.keypressed, love.draw functions for every state etc... without any further subclasses or enforcing any a state switcher class over you (it's just a function).

User avatar
Davidobot
Party member
Posts: 1155
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: game state switcher class

Post by Davidobot » Mon Apr 21, 2014 5:08 am

You can check out my library: LovelyMoon
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: game state switcher class

Post by davisdude » Mon Apr 21, 2014 8:55 pm

You should definitely share it anyway! If it's bad we'll only make fun of you a little (NOTE: sarcasm, not serious). :)
Having too many options is almost never a bad thing.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

Re: game state switcher class

Post by dusoft » Sat May 03, 2014 11:39 pm

OK, I put it together and you can find the state switcher here:
http://www.ambience.sk/love2d-a-state-s ... class-lua/

or a direct download:
http://www.ambience.sk/wp-content/uploa ... itcher.zip

Licensed under CC-BY, tested with the latest Love2D 0.9.1. Just run main.lua and it guides you through. Any feedback welcome.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests