Is Love2d Suitable For My Project?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ryanzec
Prole
Posts: 11
Joined: Sat May 05, 2018 3:37 pm

Is Love2d Suitable For My Project?

Post by ryanzec »

So I have spent that last several months using my free time to prototype a game in Unity. I have built a lot of systems at a very basic level and that has been good for me to get a general idea what what I am going to want in my game. While things have been going ok with Unity, before I start to really dig in and polish and fully flesh out my game, I want to give a different engine a try (and this time I have a blueprint for the systems and how I want them to work). Love2D looks interesting to me as it invovle a very different language (Lua vs C#) and wanted to get some idea on whether people think my game would be suitable with Love2D.

Before I get to the game feature list, there are 2 things I want to be able to doing with when working with Love2D (or any other game engine I decide to trying other than Unity):
  • I want everything to be able to be done with just the scripting language (in this case Lua), If I have to dive into C++ code and deal with pointers, memory management, etc., then this is probably not the engine for me.
  • I want to be able to use the Entity Component System pattern as I find that interesting and want to see how well it works in practice
The game I am making is a top down 2d turn based roguelike / survival game (along the lines of something like CDDA). The features I am looking to support are:
  • Large "infinite" procedurally generated open world: I want to be able to have an "infinite" open world for the player to explore (and literally infinite would be impossible but I would like to be able to basically chunk up the world into like 128x128, 256x256, etc and then just load / unload chunks as the player move around or something similar to that)
  • Render / Simulate Large Chunk Of World At A Time: I want to be able to display and simulate a large chunk of the world at any given time, ideally I would want to shoot for what CDDA does with i think is 132 x 132 (17424 tiles) which could be 100s / 1000s of enemies and other entities that would need to be simulated.
  • Z-Levels: I want to be able to have multiple z-levels in the world so that user can move up and down in the world (like multi-floored building, sewers, etc).
  • Turn Based System: The game will have a turn based system that is based on "action points" (ie. the player movement cost 3 action points and then all the other entities in the game that can do stuff will simulate 3 action points worth of stuff).
  • Crafting System: Crafting is going to be a big part game with the player being able to craft 100s (maybe 1000+) of different of items.
  • Building System: Building is another piece of the game the is important to me as I want the player to be able to build there own places to live, crafting "station", etc.)
  • Reading / Writing Data Files: Almost all of the game is going to be loading through data files (enemies, items, crafting recipes, tile meta data, etc.) so I want it to be easy to read / write data files (ideally I would like to be able to use YAML however JSON would work if needed).
  • AStar Path Finding: I am going to need to have AStar path finding for at least to be able to allow enemies to be able to track down the player and other NPCs (though there are other ideas that I might be able to use this for).
  • NPC System: The game will feature a robust NPC system that will allow the player to trade, interact (build up reputation with factions, specific NPCs, etc.), fight, NPCs can interact with other NPCs / enemies, etc.
  • Inventory System: The game will feature a fairly standard inventory system that would be in any standard survival style game
  • Quest System
  • Development and deployment on Mac / Windows
I am sure I am probably missing stuff but these are the features that I have at least prototype versions of in my Unity project currently.

I don't feel that I am going to miss Unity when it comes to building out the game itself as I am mostly in a code editor for that and not Unity's IDE since most things are generated from data files however UI is a different story. The UI I have for the game does not need to be super complex but on the UI side of things, these are the things I would like to be able to do:
  • Be able to list items of data (for stuff like inventory items, skills, stats, etc.)
  • Be able to have text areas that are variable in size in order to fit the content
  • Be able to have content areas that are scrollable
  • Be able to have icons / image with the UI easily
My biggest concern (as with any game engine) is performance. I am not too worried about the graphical performance since the graphical need are going to be limited compared to most games however there is a lot of simulation that needs to happen for a relatively large given area and I want to make sure that it not going to be a huge problem (obviously my code needs to be optimized but I want to make sure the Love2D / Lua itself is not going to be a the bottle neck as I can't control it).

Any insight people can provide me about the suitability of Love2D with a game of this kinda using just the scripting language and the ECS pattern would be great (also if you think ECS would not be suitable for this kind of game even outside of the context of Love2D, I would be interested in hearing why).
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Is Love2d Suitable For My Project?

Post by ivan »

ryanzec wrote: Sat May 05, 2018 5:09 pm I want everything to be able to be done with just the scripting language (in this case Lua), If I have to dive into C++ code and deal with pointers, memory management, etc., then this is probably not the engine for me.
Sure, Love2D can do that.
ryanzec wrote: Sat May 05, 2018 5:09 pm I want to be able to use the Entity Component System pattern as I find that interesting and want to see how well it works in practice
Yep, the rest of your questions are really a matter of how experienced you are in making games.
Generally speaking it sounds like a very ambitious game so keep that in mind.
ryanzec wrote: Sat May 05, 2018 5:09 pmLarge "infinite" procedurally generated open world: I want to be able to have an "infinite" open world for the player to explore (and literally infinite would be impossible but I would like to be able to basically chunk up the world into like 128x128, 256x256, etc and then just load / unload chunks as the player move around or something similar to that)
As far as I know this is done using techniques like Perlin noise.
ryanzec wrote: Sat May 05, 2018 5:09 pm Render / Simulate Large Chunk Of World At A Time: I want to be able to display and simulate a large chunk of the world at any given time, ideally I would want to shoot for what CDDA does with i think is 132 x 132 (17424 tiles) which could be 100s / 1000s of enemies and other entities that would need to be simulated.
For a turned-based game you could handle a lot of enemies/NPCs but I don't think it would be feasible to draw over 10k tiles in realtime.
Unless you pre-render those to canvas but it would be hard to make that work seamlessly.
Development and deployment on Mac / Windows
Yep, that is supported too.
Be able to have icons / image with the UI easily
You have to roll out your own UI system. Native UI elements are not supported.
ryanzec wrote: Sat May 05, 2018 5:09 pm My biggest concern (as with any game engine) is performance. I am not too worried about the graphical performance since the graphical need are going to be limited compared to most games however there is a lot of simulation that needs to happen for a relatively large given area and I want to make sure that it not going to be a huge problem (obviously my code needs to be optimized but I want to make sure the Love2D / Lua itself is not going to be a the bottle neck as I can't control it).
Love2D can handle pretty much any traditional 2D game you come up with. There are techniques for optimizing your code, but I think your primary concern should be the scope of the game. The game you have described could take several years of full-time work for a single person.

In my opinion, ECS is just a technique for keeping your code organized. There's other ways to do that of course - so whatever works for you. I don't think it's that important.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Is Love2d Suitable For My Project?

Post by grump »

ryanzec wrote: Sat May 05, 2018 5:09 pm
  • Reading / Writing Data Files: Almost all of the game is going to be loading through data files (enemies, items, crafting recipes, tile meta data, etc.) so I want it to be easy to read / write data files (ideally I would like to be able to use YAML however JSON would work if needed).
You might want to consider using Lua instead. It has everything JSON and YAML have, the syntax is equally concise and it integrates naturally into a game made with - well, Lua. Especially if asset security is not a concern for your project, it will be hard to load anything else as fast as plain Lua files.
ryanzec
Prole
Posts: 11
Joined: Sat May 05, 2018 3:37 pm

Re: Is Love2d Suitable For My Project?

Post by ryanzec »

ivan wrote: Sat May 05, 2018 6:21 pm
ryanzec wrote: Sat May 05, 2018 5:09 pm Render / Simulate Large Chunk Of World At A Time: I want to be able to display and simulate a large chunk of the world at any given time, ideally I would want to shoot for what CDDA does with i think is 132 x 132 (17424 tiles) which could be 100s / 1000s of enemies and other entities that would need to be simulated.
For a turned-based game you could handle a lot of enemies/NPCs but I don't think it would be feasible to draw over 10k tiles in realtime.
Unless you pre-render those to canvas but it would be hard to make that work seamlessly.
This is definitely a big one for me and while I am flexible on the size of the area where tiles are drawn (it would just effect how far out the player can "zoom"), I do want the "simulated" area that is effected by the action points to be relatively big.

The current tile map manager that I am using in Unity (not one I built though I think going forward even if I stick with Unity, I am going to have to build one myself anyways so I am up for doing that with Love2D) I am pretty sure that is does not re-draw every tile every update / render so I would like to think that it would be possible to draw the initial tiles on the first render that are in "view" and then only draw / remove tiles when the player moves and only update the tiles that are coming into / going out of view (in which case for a 132 x 132 "viewable" area, that would mean only updating 524 tiles when the player move diagonally and half that if they move north / south / east / west). My understand might be wrong as I will 100% admit my understanding of how it works is naive (I only know for sure that a chunk of the tile map manager code does not run after initial render since loading 3 tile maps of 128 x 128 take a little but after it loads, performance is fine).

Does this sounds like something reasonable for Love2D to be able to handle or am I not understanding how rendering works?
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is Love2d Suitable For My Project?

Post by pgimeno »

ryanzec wrote: Sat May 05, 2018 8:18 pm Does this sounds like something reasonable for Love2D to be able to handle or am I not understanding how rendering works?
It sounds reasonable to me, maybe with a canvas or with a spritebatch - it shouldn't be difficult to do a preliminary test to find the best approach.

However...
ryanzec wrote: Sat May 05, 2018 5:09 pm Render / Simulate Large Chunk Of World At A Time: I want to be able to display and simulate a large chunk of the world at any given time, ideally I would want to shoot for what CDDA does with i think is 132 x 132 (17424 tiles) which could be 100s / 1000s of enemies and other entities that would need to be simulated.
... that part sounds more delicate.
ryanzec
Prole
Posts: 11
Joined: Sat May 05, 2018 3:37 pm

Re: Is Love2d Suitable For My Project?

Post by ryanzec »

pgimeno wrote: Sat May 05, 2018 8:52 pm However...
ryanzec wrote: Sat May 05, 2018 5:09 pm Render / Simulate Large Chunk Of World At A Time: I want to be able to display and simulate a large chunk of the world at any given time, ideally I would want to shoot for what CDDA does with i think is 132 x 132 (17424 tiles) which could be 100s / 1000s of enemies and other entities that would need to be simulated.
... that part sounds more delicate.
Yea, I figured as much however I was assumed that would be tricky whether in Unity or any other language, do you think this would be trickier in Love2D vs something like Unity?
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is Love2d Suitable For My Project?

Post by pgimeno »

Probably not. LuaJIT's speed has often been compared to that of C/C++. It's not quite there, but reasonably close for a JIT compiler.
Nelvin
Party member
Posts: 124
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: Is Love2d Suitable For My Project?

Post by Nelvin »

I write a different game (city builder) but kind of similar requirements with regards to the mapsize, number of active characters doing pathfinding etc. and I'd say Love is easily able to handle everything you need.

My game, at the moment is in many areas highly unoptimized. F.i. the rendering is done using a single quad and spritebatch instance and during the rendering, for every tile, sprite etc. I first set the viewport of that quad, add the quad to the batch and when I added big amounts of quads, render the batch. I.e. I create the full batch ever frame (of course I reuse the instance, but I fill it from scratch each time).
I still use only a single thread, and I even have switched off the JIT compiler at the moment.

Given this setup I can use 128x128 maps and still get 60fps on my probably average PC. It's a E3-1231v3, similar to the 4770k, GPU is a R9 280 similar to a 7950 so it's hardware that's >= 5 years old.
snowcat
Prole
Posts: 5
Joined: Thu Apr 19, 2018 2:56 pm

Re: Is Love2d Suitable For My Project?

Post by snowcat »

ryanzec wrote: Sat May 05, 2018 10:03 pm Yea, I figured as much however I was assumed that would be tricky whether in Unity or any other language, do you think this would be trickier in Love2D vs something like Unity?
Maybe trickier in the sense that Unity offers more tools and has an asset store that probably already has some code that does what you need. On the flipside, Unity is a huge beast and it can take quite some time to figure out how to do things efficiently.

Unity has a reputation among gamers for bad performance, which is entirely undeserved but still relevant here because it's 100% on the game developers either taking shortcuts or not understanding the tools they use well enough. I've written code for Unity projects as part of modding games that were made in Unity, but for my own projects I do in my spare time, it still intimidates me. (I also code at work, but we don't make games, so it's completely different.)

As far as performance of the language is concerned, luajit (used by Love2D) and mono (used by Unity) do similar things (compile to byte code, JIT compilation to native code) and get comparable performance. Of course there are differences, for example, being able to tell the compiler what type everything is in C# will sometimes enable it to generate better native code. But they're in the same class, and luajit has often been called a shining example of what's possible with a JIT compiler for a dynamically typed language.

In general I'd say performance is up to you. Of course you can make drawing your tile map slow by drawing each tile independently, but you could also use a sprite batch. And of course you can make the code for your 1000s of enemies really slow, but it's not automatically going to be slow just because you chose to write it in lua.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Is Love2d Suitable For My Project?

Post by zorg »

For another reference point, let me just state that in 1999, RollerCoaster Tycoon was released, made by a pre-John Blow enigma called Chris Sawyer; the game was mostly written in assembler, and could simulate thousands of peeps on computers from that era. (300-500 MHz CPUs)

Now, people have been working on an open-source re-implementation of the second game, OpenRCT2, written in C/C++, and it's none the slower. LuaJIT being able to reach speeds near those two languages means simulating a large amount of entities may not be as big of a problem as one might think, granted they benchmark their code and check to see it doesn't under-perform. And CPUs have gotten faster as well, of course; 10 times the clock speed, more elaborate pipelines, etc.

That said, entity simulation can mean anything from having 0 parameters per-entity to wanting to simulate trees or generic graphs for A.I. and stuff... it really depends on the use-case whether it'll work out or not.



Just for the sake of humour, and this is by no means any rigorous metric, but here's an unrealistic example of how i'd fake-calculate how many bomberman sprites i could move on a simple, non-pipelined, 3 GHz CPU:

3 000 000 000 cycles / second
let's use 1 cycles for add/subtract; 5 for load and 4 for store; the code would be like this: x = x + dx; y = y + dy.
that's 2 * ( 2 load, 1 store, 1 add) => 2 * ( (2*5) + 4 + 1 ) => 2 * 15 = 30 cycles.
3 000 000 000 / 30 = 100 000 000

So, naively, i might say that the maximum # of units i could simulate if i only needed to do the above two statements would be a hundred million. Cool. It's totally bogus, but that's at least something to start going off on.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests