Comments (9)
The fact that they didn't fall before 1.5 was actually an engine bug.
from tunics.
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.
Ok, if you think this is an engine bug please report it and I can fix it for 1.5.1.
from tunics.
I created solarus-games/solarus#995 for this.
from tunics.
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.
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.
@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:
- initial position = placeholder:get_position() + 2 px south
- 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.
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.
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)
- Implement composite placeholder tiles
- Add component names to debug info
- Missing graphics in cave tileset
- Update ChangeLog for 0.3
- Finalise tileset assets
- Homepage is down HOT 6
- Wrong genre HOT 3
- Link's 360 sweep attack doesn't hit instantly
- [Manjaro] DualShock 4 d-pad doesn't work
- [Manjaro] DualShock 4 doesn't seem to have any button bound to hook shot
- Softlock
- Link's slashes are laggy.
- Add new puzzle: Lost woods HOT 1
- New obstacle: Flying tiles
- New boss: Lanmolas
- Avoid resource depletion HOT 1
- Update tileset.dat and tileset pngs to no new floor model
- Update documentation to match 0.3 release
- Update tileset assets to handle random palettes
- 0.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tunics.