Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Diarandor

#901
Development / Re: Carrying custom entities
September 23, 2015, 03:31:52 AM
Oops. Just after the line "game.save_between_maps = require("scripts/save_between_maps")" add this one:

game.independent_entities = {}


I use that list to store entities that save their position when left in some map (it can be used with the "metal ball", although that can be used for other types of entities too).
#902
Development / Re: Carrying custom entities
September 23, 2015, 03:18:51 AM
It seems that I forgot this piece of code. Put it in the game manager to solve that error:

game.save_between_maps = require("scripts/save_between_maps")
#903
Development / Re: Carrying custom entities
September 23, 2015, 02:58:06 AM
This code is not exactly what I have. It is simpler but untested.

If a custom_entity is close to the border of the map, the custom_command_action (used for "custom_lift") may be not reseted to nil when the hero changes map. To avoid this, I use the line "game:set_custom_command_effect("action", nil)" in this code.

Also, we notify the save_between_maps.lua script to create a custom entity being carried if there is some. (So here we are loading the already saved information in the previous map.)


  -- Function called when the player goes to another map.
  function game:on_map_changed(map) 
    -- Notify the HUD and hero manager(some HUD elements need to know that).
    hud:on_map_changed(map)
    game:set_custom_command_effect("action", nil) -- Reset. To avoid problems with custom_interactions.lua.
    game.save_between_maps:load_map(map) -- Create saved and carried entities.
  end


On the other hand, in some part of the game manager (maybe in game:on_started()) you must use this code, to save the carried custom entities and reload them in the new map.  (So here we are saving some information to reload it in the next map.)


  local map_metatable = sol.main.get_metatable("map")
  function map_metatable:on_finished()
    game.save_between_maps:save_map(self)
  end


Tell me which errors you get with this.
#904
Development / Re: Carrying custom entities
September 23, 2015, 02:05:05 AM
I think I know why you get a crash, which could be due to that another piece of code is needed to create again the carried entity in the new map and allow to use the save_between_maps.lua script. (We will need to use the events map:on_created() and map:on_finished() for that purpose.) When you have time I will explain how.

I know you have your things to do and you are working very hard in your game, so take your time and you will tell me when we can continue debugging this. There is no haste.
#905
Ok, I would like to help with this, so I will try to code it someday soon.

EDIT: we would need to concrete what the script will allow to do. I mean, we need to know which customizable properties we will allow to the particles emitter, like: number of particles, speed and color (which could change with time), max distance, possible directions for emitted particles, and also which altorithms we will use, etc.
#906
Development / Re: Shaders?
September 22, 2015, 06:20:31 PM
I was so curious that I tried the brute force idea. Only creating the surfaces makes the game impossible to play (terribly slow, no game is possible, as we thought), and drawing the pixel-surfaces just makes it even worse...  :'(

No hope until Christopho allows pixel modification in the engine.
#907
Development / Re: Shaders?
September 22, 2015, 04:51:43 PM
I have another idea to use multiple light points, only using Lua. But it could slow down a bit the game (and it will be much worse than using a shader). We could script this in one Lua file, doing as follows:

First, we create a main transparent surface, with the size of the screen/window. Then, for each pixel of the screen, we can create a surface of 1x1 pixels size and draw it in the main surface. We can use a list as a matrix to store all the "pixel surfaces". The rest of the code would be some functions to modify the transparence on each pixel surface (to make it more or less transparent, also modify the color, etc). This would allow to have torches iluminating some parts of dark rooms, and also to have several lights which are moving. This is just the overall idea.

Anyway, as I say, maybe this would be a bit of brute force that could slow down the game (too many surfaces?), although I'm not sure of this.
#908
@zutokaza:
About that video, I wouldn't say that's exactly a particle engine. It seems more like some scripts with collision tests on some sprites. It should not be too hard to make a script to do all of that if you have enough free time.

Well... I don't really know if there is a universal concept of "particle engine", but I had a different idea of it, something more like what wrightmat described in https://github.com/christopho/solarus/issues/415 and the videos he linked there.

@wrightmat:
I'm interested in your scripts for particles, did you finish it or are you still working on it? (If that's the case maybe I could help a bit with the scripts, to quicken the work.)

I suppose that could be done using surfaces of 1 pixel, or maybe with sprites. The problem of drawable surfaces is that they cannot use collision tests (that could be needed for some purposes), and the problem of the sprites is that you cannot change the color or transparency dynamically, so maybe it's not so easy to do something very general...
#909
Development / Re: Carrying custom entities
September 22, 2015, 04:16:07 AM
If you want the entity to fall away when walking and on hero's foot when stopped, you have two solutions:
-The first one is to do what I do: use the second tunic, and that's all.
-The second solution: modify the entity:throw() function and write:

local dx, dy = 0, 0; if animation == "carrying_walking" then dx, dy = math.cos(direction*math.pi/2), -math.sin(direction*math.pi/2) end

instead of

local dx, dy = 0, 0; if animation == "walking" then dx, dy = math.cos(direction*math.pi/2), -math.sin(direction*math.pi/2) end

But with the second solution you will still have the problem that the carrying_stopped animation is not used!!!
#910
Development / Re: Carrying custom entities
September 22, 2015, 04:05:14 AM
Quote from: wrightmat on September 22, 2015, 03:55:25 AM
Sounds great - thanks!

I had tried to move to another map carrying the object, and it did crash. It appears that throwing onto holes and such does work.

One question - is there a way to have the entity actually be thrown? Right now the hero essentially drops the object at his feet, but it'd like to get some distance.

-Ok, we will have to solve the crash you have, do you get some error?
-Yes. When I throw the entity while walking, the entity does not fall on the hero's foot, it is thrown away instead in the direction of the hero. But you need the hero to be walking. In that case, the entity is thrown in the direction of the hero. Isn't that working correctly? Or you mean that you want it to be always thrown away? In that case, you would need to make a very small change in the entity:throw() function of generic_portable.lua. You would need to change the line:

local dx, dy = 0, 0; if animation == "walking" then dx, dy = math.cos(direction*math.pi/2), -math.sin(direction*math.pi/2) end

with the following instead:

local dx, dy = math.cos(direction*math.pi/2), -math.sin(direction*math.pi/2)


EDIT: Ok, I just figured out what's happening. The point is that you are changing the animation when walking in the hero_metatable:on_position_changed(), and I am not doing that, because I use the second tunic and the animation I have is the walking one. That's why you cannot throw it away.
#911
Development / Re: Carrying custom entities
September 22, 2015, 03:58:14 AM
To use the carrying stopped animation, I think that the only solution is to use the second tunic (the carrying one). For each different tunic you will need to create another one for the carrying animations. You would only need to modify a bit the function "hero_metatable:set_carrying(boolean)" to make it compatible with the three tunics of Link, which is really easy.
#912
Development / Re: Carrying custom entities
September 22, 2015, 03:39:43 AM
I realized that, since you have already added the save_between_maps.lua script to your game_manager script, maybe it's already working the feature that allows carrying the custom entity to another map.  ;D
#913
Development / Re: Carrying custom entities
September 22, 2015, 03:18:27 AM
That's good news. I will explain to you other day how to customize generic_portable entities without modifying the generic_portable.lua script. So that you can have a different bouncing sound for different portable entities, etc. I use the script generic_portable.lua as a base script for all very different portable entities, so it is important not to modify it (maybe not so important if you use only one type of those entities in your game). I will also explain how to use the save_between_maps.lua script (not so hard as what we have done) to save position of some of these entities when left in some map (this could be used to simulate the metal ball of Link's awakening). But that's all for today.

Anyway, have you thrown the entity to a hole, water or lava? Just test it and tell me if it works.

EDIT: do not carry the entity to other map or you will get a crash. I will explain how to make that work too, don't worry (that's also part of the save_between_maps.lua script). We have finished for today.
#914
Development / Re: Carrying custom entities
September 22, 2015, 03:09:42 AM
The grabbing animation has frame delay 0 and only one frame, so maybe it has no ending, but I am not sure at all. Try to use an animation with nonzero frame delay, several frames (and without loop, obviously). That could work.
#915
Development / Re: Carrying custom entities
September 22, 2015, 03:01:39 AM
I have added some sounds to my repository: item_fall.ogg, falling_on_hole.ogg and splash.ogg.
You can use them (I created them so they are free to use).