Git Product home page Git Product logo

Comments (9)

christopho avatar christopho commented on May 23, 2024

The fact that they didn't fall before 1.5 was actually an engine bug.

from tunics.

mattias-p avatar mattias-p commented on May 23, 2024

The block is created on exactly the same spot as the placeholder tile. Assuming Tunics is doing everything else correctly, shouldn't the block land on top of the placeholder tile in this case?

from tunics.

christopho avatar christopho commented on May 23, 2024

Ok, if you think this is an engine bug please report it and I can fix it for 1.5.1.

from tunics.

mattias-p avatar mattias-p commented on May 23, 2024

I created solarus-games/solarus#995 for this.

from tunics.

mattias-p avatar mattias-p commented on May 23, 2024

So the bug is in Tunics after all. The inject_* functions in zentropy.lua should be using entity:get_ground_position() instead of entity:get_origin().

from tunics.

christopho avatar christopho commented on May 23, 2024

More exactly, use entity:get_ground_position() instead of entity:get_position().
(entity:get_origin() is relative to the entity's upper-left corner, not to the map.)

from tunics.

mattias-p avatar mattias-p commented on May 23, 2024

@christopho Right, I didn't read the docs properly. Thanks for pointing that out. However I don't see how entity:get_ground_position() would solve my problem. Here's my thinking.

This is a fairly precise specification of what I need:

  • Precondition: placeholder:get_size() >= entity_sprite:get_size()
  • Invariant: once entity is created, placeholder overlaps entity:get_ground_position()
  • Postcondition: placeholder:get_bounding_box() contains entity:get_bounding_box()

The initial entity position needs to be calculated before creation. The final position needs to be calculated after creation (unless initial position == final position).

This is the best way of doing this that I can come up with:

  1. initial position = placeholder:get_position() + 2 px south
  2. final position = placeholder:get_position() + entity:get_origin()

For most entity types I'm able to calculate the final position immediately by using entity_sprite:get_origin(), but AFAIK that's not possible for enemies.

Compared to the general quality of the API, I think this calculate-create-move business is a bit awkward. Here's my two cents for making this use case as lean and mean as the rest of Solarus: Add an optional "alignment"-argument to map:create_*() with the possible values of "position" (default) and "center_position". That way you could just map:create_whatever("center_position", placeholder:get_center_position()).

from tunics.

christopho avatar christopho commented on May 23, 2024

Ok, if I understand correctly your suggestion, I think this is a good one. I opened an issue: solarus-games/solarus#997

So for now in the meantime, do you have an acceptable workaround or are you really stuck?

from tunics.

mattias-p avatar mattias-p commented on May 23, 2024

No, I'm just fine with this approach. I already implemented it and It seems to work, so I'm likely to stick with it. The API change was just an idea I thought was kinda neat, and I wanted to share it.

from tunics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.