game state switcher class

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
dusoft
Party member
Posts: 499
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

game state switcher class

Post by dusoft »

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: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: game state switcher class

Post by Davidobot »

You can check out my library: LovelyMoon
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: game state switcher class

Post by davisdude »

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
User avatar
dusoft
Party member
Posts: 499
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: game state switcher class

Post by dusoft »

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 28 guests