Hesitate to come back on Love2D

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Koeba
Prole
Posts: 5
Joined: Thu Jun 23, 2022 10:07 am
Location: France

Hesitate to come back on Love2D

Post by Koeba »

Long story short, every year I change framework and language because I can't find the "perfect framework". I've come to realize that whatever the framework, it's not the tool that makes the game, but the developer. But I still hesitate between two frameworks, and I kinda need you guys to help me make my choice. So I hesitate between Love2d, SDL2 (with C).

I really like Love2D because how the community are friendly, the wiki and the documentation are freaking awesome. I have one issues with this framework rn, it's that I struggle to do OOP with lua.

I don't really like SDL2 because the community meh, the wiki is a mess and using the tools in general are quite "suffer". So I am using SDL well the only reason it's that in September I'm gonna start a school specialized on video games creation, and we gonna learn C with SDL. It's why I hesitate so much to use Love2D.

I already use SDL for like the past month but damn it's not I don't like it, it's just that compared to love2d it's bad. :?


I don't know if learning lua and C at the same time is a good idea? Will using two frameworks at the same time disturb me? I have a lot of questions like that and I really wanted to get your point of view. You are the only programming/gamedev community where I feel so at home on the Internet.
User avatar
keharriso
Party member
Posts: 104
Joined: Fri Nov 16, 2012 9:34 pm

Re: Hesitate to come back on Love2D

Post by keharriso »

If OOP is the only sticking point for LOVE, there's plenty of class libraries out there. I like this one, but there are many more:

https://github.com/rxi/classic
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
User avatar
Koeba
Prole
Posts: 5
Joined: Thu Jun 23, 2022 10:07 am
Location: France

Re: Hesitate to come back on Love2D

Post by Koeba »

keharriso wrote: Wed Jun 26, 2024 1:24 pm If OOP is the only sticking point for LOVE, there's plenty of class libraries out there. I like this one, but there are many more:

https://github.com/rxi/classic
Damn didn't know that kind of stuff exists, thanks you !
User avatar
pgimeno
Party member
Posts: 3601
Joined: Sun Oct 18, 2015 2:58 pm

Re: Hesitate to come back on Love2D

Post by pgimeno »

Well, Löve is a wrapper around SDL, OpenGL and a few more libraries. Learning SDL will help you know how Löve is implemented internally, what to expect, etc. In fact, the person that is currently maintaining the majority of Löve is also an SDL important contributor. But yeah, Löve hides the complexity of SDL behind a deliciously simple interface.

Learning both at the same time does not sound like a bad idea to me, as long as you're able to keep them separate in your mind. When I get back to Lua after coding in C++ for a while, I tend to add semicolons to Lua code by mistake, and vice versa; but these just take a little bit getting used to.

As for OOP, you can use an OOP library until you're more comfortable with the language and understand metatables better. rxi's "classic" is a class library with a very straightforward implementation; I recommend that one for now. In fact keharriso posted it before I pressed 'submit' :)
User avatar
dusoft
Party member
Posts: 547
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Hesitate to come back on Love2D

Post by dusoft »

keharriso wrote: Wed Jun 26, 2024 1:24 pm If OOP is the only sticking point for LOVE, there's plenty of class libraries out there. I like this one, but there are many more:

https://github.com/rxi/classic
Also see other options:
https://github.com/love2d-community/awe ... ov-file#oo

Flexibility of Lua means you can just create any objects (tables) you like and use OOP approach.
User avatar
Koeba
Prole
Posts: 5
Joined: Thu Jun 23, 2022 10:07 am
Location: France

Re: Hesitate to come back on Love2D

Post by Koeba »

dusoft wrote: Wed Jun 26, 2024 3:13 pm
keharriso wrote: Wed Jun 26, 2024 1:24 pm If OOP is the only sticking point for LOVE, there's plenty of class libraries out there. I like this one, but there are many more:

https://github.com/rxi/classic
Also see other options:
https://github.com/love2d-community/awe ... ov-file#oo

Flexibility of Lua means you can just create any objects (tables) you like and use OOP approach.
Oh I already use this github for anim8 but thanks you for your answer and sharing it
User avatar
Koeba
Prole
Posts: 5
Joined: Thu Jun 23, 2022 10:07 am
Location: France

Re: Hesitate to come back on Love2D

Post by Koeba »

pgimeno wrote: Wed Jun 26, 2024 1:32 pm Well, Löve is a wrapper around SDL, OpenGL and a few more libraries. Learning SDL will help you know how Löve is implemented internally, what to expect, etc. In fact, the person that is currently maintaining the majority of Löve is also an SDL important contributor. But yeah, Löve hides the complexity of SDL behind a deliciously simple interface.

Learning both at the same time does not sound like a bad idea to me, as long as you're able to keep them separate in your mind. When I get back to Lua after coding in C++ for a while, I tend to add semicolons to Lua code by mistake, and vice versa; but these just take a little bit getting used to.

As for OOP, you can use an OOP library until you're more comfortable with the language and understand metatables better. rxi's "classic" is a class library with a very straightforward implementation; I recommend that one for now. In fact keharriso posted it before I pressed 'submit' :)
Okay well i'm gonna do that, there are only benefits to doing this thank you for your answer
RNavega
Party member
Posts: 294
Joined: Sun Aug 16, 2020 1:28 pm

Re: Hesitate to come back on Love2D

Post by RNavega »

I wouldn't try comparing them, though. While you could call Lua + LÖVE and C + SDL as pairs with "language + framework", the API from SDL is way more low-level than the API from LÖVE. The same is true for the languages, with you taking less lines to write something in Lua than you would if you wrote the same program using C.

Therefore, your productivity with Lua + LÖVE is going to be higher, and as long as it has the features you need and can deploy to the platforms you're targeting, you should pick that.
Just use the best tool for the job, yeah?
gcmartijn
Party member
Posts: 139
Joined: Sat Dec 28, 2019 6:35 pm

Re: Hesitate to come back on Love2D

Post by gcmartijn »

I use https://github.com/rxi/classic for my game in progress (3 years now)
OOP works very good.

I made a simple engine and a game using that engine.

engine camera code example

Code: Select all

local Geometry = require "lib.engine3.src.framework.helper.math.geometry"
local Callback = require "lib.engine3.src.framework.core.callback"

-- Camera
local Camera = Object:extend("Camera")
Camera:implement(Callback)

function Camera:new(data)
    if data == nil then
        data = {}
    end
    self.config = entityManager:findOne(nil, "Config")
    self.gameCanvas = entityManager:findOne({name = "gameCanvas"}, "Canvas")
    self.x = data.x or 0
    self.y = data.y or 0

    self.width = data.width or self.gameCanvas:getWidth()
    self.height = data.height or self.gameCanvas:getHeight()
    self.followSpeed = data.followSpeed or 1
    self.targetX = nil
    self.targetY = nil
    self.bound = true
    self.bounds_min_x = nil
    self.bounds_min_y = nil
    self.bounds_max_x = nil
    self.bounds_max_y = nil

    self.callbackAfterStop = {}

    entityManager:add(self)
end

function Camera:getHeight()
    return self.height
end

function Camera:update(dt)
    -- bla bla engine
end

function Camera:release()
end

return Camera
That game is using the engine and for custom code overwrite or extend classes like this.

Code: Select all

local Camera = require("lib.engine3.src.framework.core.camera"):extend()

function Camera:sceneReadyEvent(args)
    -- There are multiple actor movable
    for _, actor in ipairs(entityManager:find(nil, "Player")) do
        actor.callbackChangeMovableByUserInput["changeMovableActorCamera"] = function(s, active)
            if active then
                self:setFollowEntity(s)
            end
        end

        if actor.movableByUserInput then
            self:setFollowEntity(actor)
        end
    end
end

function Camera:update(dt)
    if self.followEntity then
        -- @warning not every followEntity contains a activeFrameset
        local newTargetX = self.targetX
        if self.followEntity.activeFrameset then
            newTargetX = self.followEntity.activeFrameset:getX()
        else
            newTargetX = self.followEntity:getX() or self.followEntity:getFrameX()
        end

        -- don't jitter, we only move left <> right
        local newTargetY = self.targetY
        if self.targetY == nil then
            if self.followEntity.activeFrameset then
                newTargetY = self.followEntity.activeFrameset:getY()
            else
                newTargetY = self.followEntity:getY() or self.followEntity:getFrameY()
            end
        end

        if newTargetX ~= self.targetX or newTargetY ~= self.targetY then
            self:setTarget(newTargetX, newTargetY)
        end
    end

    -- Call the original camera update
    Camera.super.update(self, dt)
end

return Camera
As you can see, you can extend the engine and call the super like I did above (Camera.super.update(self, dt)).
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests