[Done] Recreating a "thrown item" movement

Started by MetalZelda, March 21, 2016, 12:11:45 PM

Previous topic - Next topic
Quote from: Diarandor on March 22, 2016, 08:35:28 PM
It is getting really cool.  :)
Do not forget to add a shadow sprite (with transperency if possible), and destroy it after the bait has fallen; that will give more realism to the sequence.

Edit: there was a crash issue in the development version of Solarus 1.5, when removing a sprite of a custom entity. It did not happen in the previous versions. (Christopho has fixed this a few days ago, but the current snapshots may have this problem, so be careful when you remove the shadow sprite).

Yes, removing a sprite crash the game, adding an animation with a clear animation works as well. I can't revert to solarus 1.4.5 because I am using the new camera in this.
The shadow has been added, as well as some other effects, I am working on a trail effect when the bait moves, to compensate a bit the lack of the wire

Other than that, thanks a lot Diarandor for the help  :)

@Metalzelda: I have been using the code to simulate the jump of a slime enemy and I found two small mistakes in the updated first post of this subject (one of them was mine).

1) I forgot to add a minus sign in the shift, in line: "sprite:set_xy(0, f(t))".
It should be "sprite:set_xy(0, -f(t))" instead.

2) Since you are drawing the shift each 10 milliseconds, the increment of the time variable "t" should be 10 too. So we will have:

  local t = 0
  sol.timer.start(self, 10, function() -- timer below 10 is useless, 10 ms is approximately 1 frame in-game
    fishing_rod:get_sprite():set_xy(0, f(t))
    t = t + 10 -- <---- THE PROBLEM WAS HERE.
    if t > duration then return false
      else return true

Just change these two things in the first post, so other people will not get the wrong code. (I know you realized of all of this because your fishing rod works correctly in the videos.)
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Good news: Christopho has released a new snapshot, and now getting the sprite of the hero is working correctly. Hence the sprite of the hero can be shifted with this "thrown movement" to program a custom jump (fully controlled, as in Link's Awakening). I have tested it and it's awesome. I will share the script when I finish improving it (I now use a secondary tunic for the jump, which is not good, but I will fix this someday soon).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."