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.

Messages - Diarandor

Pages: 1 2 [3] 4 5 ... 68
Development / Re: Is it possible to make the hero face the cursor?
« on: August 18, 2018, 04:51:41 am »
Something like this may work (it is untested, so you should correct it if necessary).
Code: Lua
  1. -- Get the map coordinates of the cursor.
  2. local map_meta = sol.main.get_metatable("map")
  3. function map_meta:get_cursor_coordinates()
  4.   local camera = self:get_camera()
  5.   local mouse_x, mouse_y = sol.input.get_mouse_position()
  6.   local cam_screen_x, cam_screen_y = camera:get_position_on_screen()
  7.   local cam_x, cam_y, _, _ = camera:get_bounding_box()
  8.   local pos_x = mouse_x - cam_screen_x + cam_x
  9.   local pos_y = mouse_y - cam_screen_y + cam_y
  10.   return pos_x, pos_y
  11. end
  13. -- Make the hero face the cursor.
  14. local hero_meta = sol.main.get_metatable("hero")
  15. function hero_meta:face_the_cursor()
  16.   local hero = self
  17.   local pos_x, pos_y = hero:get_map():get_cursor_coordinates()
  18.   local dir = hero:get_direction4_to(pos_x, pos_y)
  19.   hero:set_direction(dir)
  20. end

You still have to import the script that contains these functions, and initialize a timer that will call "hero:face_the_cursor()" when necessary, as mentioned above. If we do all the work for you, you will not learn, so I will be leaving you here. Good luck!

Development / Re: Is it possible to make the hero face the cursor?
« on: August 17, 2018, 02:18:13 am »
Updating the hero's facing direction every 1ms seems like a bad idea.

Unless he is making a shooter where the hero should always be aiming to the cursor, which we don't know.

Development / Re: Is it possible to make the hero face the cursor?
« on: August 17, 2018, 01:17:05 am »
I recommend to add a function to update the direction of the hero. Something as simple as this should work:
Code: Lua
  1. function hero:face_the_cursor()
  2.   local mouse_x, mouse_y = sol.input.get_mouse_position()
  3.   local dir = hero:get_direction4_to(mouse_x, mouse_y)
  4.   hero:set_direction(dir)
  5. end
You can combine it, for instance, with a 1-millisecond-timer that calls the function "face_the_cursor" when necessary, or otherwise, with potatoes, ketchup and chicken wings.

PS1: Since the function "sol.input.get_mouse_position()" seems to calculate the position relative to the quest size, it may not work. I have never used/tested it. In that case, I leave the problem as an exercise for you.

PS2: my cats usally say catsup instead of ketchup.

Development / Re: Problem with thrown enemies after pause
« on: August 09, 2018, 05:16:39 pm »
That (i.e. the hero throwing the item) can be avoided if you add some code to the corresponding event(s) on_key/command_pressed().

Development / Re: Multiple enemies not acting the same
« on: August 06, 2018, 08:23:15 am »
Some of your state variables, like 'attacking', are not local.

Development / Re: Custom entity and associate sprite : strange offset
« on: July 29, 2018, 06:25:41 pm »
That awesome feature will allow to have a hero of bigger or smaller size, which was a feature requested by many devs/artists using custom art of non-standard size. It will also allow to make a game like Minish Cap, where the hero can become smaller/bigger.

Bugs & Feature requests / Re: on_removed() warning issue?
« on: July 28, 2018, 12:52:00 pm »
You should check if the entity still exists. In on_removed:
Code: Lua
  1. if bookcase ~= nil and bookcase:exists() then
  2.   bookcase:set_enabled(false)
  3. end

Development / Re: Required Sound Effects?
« on: July 27, 2018, 03:55:57 pm »
You can always "steal" sounds from our free project.  :P

General discussion / Re: Free Pixel Art Making Programs
« on: July 23, 2018, 11:34:26 pm »
You won't regret it. I can't stop recommending Aseprite. It's very powerful, intuitive and simple at the same time. The layers feature is very important and you should use it a lot.

Development / Re: Pass multiple entities?
« on: July 22, 2018, 11:19:27 am »
The function map.get_entities_by_type(type) and other similar functions return an iterator. You can iterate on it to check all collisions at once! (see the Lua API). You can also define your own function, using those functions, and allowing to do things on iterators or lists, but it's not really necessary.

Development / Re: [Solved]Bomb overlap assistance
« on: July 22, 2018, 12:38:56 am »
An easy way to do this is to allow to define a custom event map.on_bomb_created(bomb_entity). You can call it, if it exists, from the bomb metatable (just define the function bomb_metatable.on_created).

General discussion / Re: Stealth Action Adventure Game Possible?
« on: July 22, 2018, 12:34:20 am »
You need to learn Lua, but also read carefully the Lua API of Solarus (there you have all the tools you need nicely explained). And of course, read others' scripts (as examples) and study their code, and make a lot of tests.

Is it my phone or the movement is not completely smooth? (I do not have internet at home now to check this.)

No one has tried. But it is all perfectly doable. The only problem is to find enough free time to create the art and code it.

Another important tool for this is the "custom properties" of Solarus 1.6. You can add a season property to some entities, and when that property is defined (not nil) and different from the current season, that entity would be destroyed when the map has been created. That together with the custom events are very flexible and powerful tools to work with.

Pages: 1 2 [3] 4 5 ... 68