Page 49 of 91
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Feb 15, 2016 9:21 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Feb 15, 2016 10:36 pm
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)
-- ...
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Feb 15, 2016 10:53 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Sat Feb 20, 2016 7:09 pm
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
Re: "Questions that don't deserve their own thread" thread
Posted: Sun Feb 21, 2016 4:04 am
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
You included v2 of bump instead of v3, just replace it with the current version and it should work
Re: "Questions that don't deserve their own thread" thread
Posted: Sun Feb 21, 2016 4:50 am
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!
Re: "Questions that don't deserve their own thread" thread
Posted: Sun Feb 21, 2016 7:56 pm
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).
Re: "Questions that don't deserve their own thread" thread
Posted: Sun Feb 21, 2016 8:03 pm
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?
Re: "Questions that don't deserve their own thread" thread
Posted: Sun Feb 21, 2016 9:18 pm
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)
Re: "Questions that don't deserve their own thread" thread
Posted: Tue Feb 23, 2016 12:29 am
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