"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: "Questions that don't deserve their own thread" thread
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
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:
In game class:
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
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
I would defineteley not have the input manager determine what action to take.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?
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.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: "Questions that don't deserve their own thread" thread
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
- Attachments
-
- hellobump.love
- (5.54 KiB) Downloaded 149 times
Re: "Questions that don't deserve their own thread" thread
You included v2 of bump instead of v3, just replace it with the current version and it should workscissors61 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
butts
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: "Questions that don't deserve their own thread" thread
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
I guess it depends on what you need and how you want to work.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.
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
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?
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?
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
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.
- DavidOliveiraSilva
- Prole
- Posts: 19
- Joined: Fri May 29, 2015 10:19 pm
- Location: Quixadá, Brazil
- Contact:
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot] and 2 guests