"Questions that don't deserve their own thread" thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
User avatar
meffcio
Prole
Posts: 7
Joined: Thu May 07, 2015 7:30 pm

Re: "Questions that don't deserve their own thread" thread

Post by meffcio »

Which GUI library is on the top now? I need to make an interface for a fantasty turn-based game. Think of HoMM.
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by rmcode »

I want to decouple input handling from my game logic, so I wrote a small messenger system which publishes stuff and others receive it. Naturally the input handler needs to do stuff like "if rightclick door do openDoor but if rightclick enemy do harlem shake", but I am not sure where to handle the decision making.

Should the InputManager have a reference to the map, check if the clicked tile is a door and then publish something like "DOODE_CLICKED_A_DOOR" or should I just publish a "CLICKED_TILE" event and let the game object handle the logic?

Example:

Code: Select all

        -- In input manager. Has reference to map and tiles.
        if button == 1 then
            if tile:getWorldObject():instanceOf( 'Door' ) then
                if not tile:getWorldObject():isPassable() then
                    Messenger.publish( 'CLICKED_CLOSED_DOOR', tile );
                else
                    Messenger.publish( 'CLICKED_OPEN_DOOR', tile );
                end
            else
                Messenger.publish( 'CLICKED_TILE', tile );
            end
        elseif button == 2 then
            if tile:isOccupied() then
            Messenger.publish( 'RIGHT_CLICKED_CHARACTER', tile );
        end
In game class:

Code: Select all

    Messenger.observe( 'CLICKED_CLOSED_DOOR', function( tile )
        setTarget( tile, false );
        character:enqueueAction( OpenDoor.new( character, tile ));
    end)

    Messenger.observe( 'CLICKED_OPEN_DOOR', function( tile )
        setTarget( tile, false );
        character:enqueueAction( CloseDoor.new( character, tile ));
    end)
    
    -- ...
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by s-ol »

rmcode wrote:I want to decouple input handling from my game logic, so I wrote a small messenger system which publishes stuff and others receive it. Naturally the input handler needs to do stuff like "if rightclick door do openDoor but if rightclick enemy do harlem shake", but I am not sure where to handle the decision making.

Should the InputManager have a reference to the map, check if the clicked tile is a door and then publish something like "DOODE_CLICKED_A_DOOR" or should I just publish a "CLICKED_TILE" event and let the game object handle the logic?
I would defineteley not have the input manager determine what action to take.

This being lua, I personally would use "polymorphism" / duck-typing and just do something like "if tile.onClick then tile.onClick(x, y, button) end" but a "CLICKED_TILE" event would do I guess? Are you sure you need a pub-sub / observer pattern thing for this? It seems a bit overcomplicated, but I don't know the full project.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: "Questions that don't deserve their own thread" thread

Post by scissors61 »

I'm trying to make a very basic hello world with bump by following kikito's guide, but the values actualX and actualY, that I would use for drawing a rectangle, as I understand, are nil and therefore I cannot draw with them, the error says "bad argument #2 to 'rectangle' (number expected got nil)". it must be something very simple because here many people use bump, but can't find the solution :cry:
Attachments
hellobump.love
(5.54 KiB) Downloaded 135 times
User avatar
farzher
Prole
Posts: 41
Joined: Fri Jul 31, 2015 5:38 pm

Re: "Questions that don't deserve their own thread" thread

Post by farzher »

scissors61 wrote:I'm trying to make a very basic hello world with bump by following kikito's guide, but the values actualX and actualY, that I would use for drawing a rectangle, as I understand, are nil and therefore I cannot draw with them, the error says "bad argument #2 to 'rectangle' (number expected got nil)". it must be something very simple because here many people use bump, but can't find the solution :cry:
You included v2 of bump instead of v3, just replace it with the current version and it should work
butts
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: "Questions that don't deserve their own thread" thread

Post by scissors61 »

farzher Hey, it works! I was suffering psychologically with this, because it is so simple what I was trying to do. I took the bump file from an example that works fine, so I thought that it didn't have any problem, thanks!
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

Re: "Questions that don't deserve their own thread" thread

Post by murks »

meffcio wrote:Which GUI library is on the top now? I need to make an interface for a fantasty turn-based game. Think of HoMM.
I guess it depends on what you need and how you want to work.
At the moment, with löve 0.10, I prefer SUIT.
The immediate mode thing needs some getting used to if you are used to other GUI libs, but it works rather well. At the moment it is rather resource intensive for me, but it does not matter and may be due to a weird workaround (needs further testing).
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

Re: "Questions that don't deserve their own thread" thread

Post by murks »

I designed a simple ECS which works with component tables. Those are tables used as arrays and I use the index directly as entity ID. I'm not quite sure that this is a good idea because of the problems with sparse arrays in Lua.

I still wonder a bit about removing entities and components.
For the most part I guess it is OK, as long as I can keep using pairs.

For the actual removal however I guess I will need to simply set values to nil instead of using table.remove(), correct? Otherwise the entries will be shifted down and thus components mixed up. Is there any drawback to this?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: "Questions that don't deserve their own thread" thread

Post by bobbyjones »

You could set them to a dummy value. Like "nil". That way you could continue to use ipairs. In another table store the indexes that are "nil". When ever you create a new entity throw it in the first "nil" spot. The benefit of nil vs "nil" is you could still use ipairs. (In luajit ipairs is usually faster)
Last edited by bobbyjones on Tue Feb 23, 2016 2:40 am, edited 1 time in total.
User avatar
DavidOliveiraSilva
Prole
Posts: 19
Joined: Fri May 29, 2015 10:19 pm
Location: Quixadá, Brazil
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by DavidOliveiraSilva »

I am trying build a sign android APK of my game using ant (as in here), but with the release command instead of debug. I have created my keys and etc, and i got this BUILD FAILED exactly on signing part... I am searching for solution since friday, i can't find anything. help
Locked

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 195 guests