[Solved]Screen vs entity position?

Started by Zefk, May 15, 2017, 01:51:17 PM

Previous topic - Next topic
May 15, 2017, 01:51:17 PM Last Edit: May 15, 2017, 05:28:04 PM by Zefk
Is there a formula I could use to calculate screen image x,y coordinates to the entity position? For example, drawing an image at the hero. I am not sure that entity:get_position() is related to this because is not that position different than image x,y coordinates?

I think getting the position of the entities with entity:get_position() only works for drawing if your map is 320 x 240. It has to be the same as the quest size.

I am not really sure how to solve this. There might need to be drawing checks as the map scrolls. Some calculations would work until the hero starts in a location where the map scrolls.

Maybe @Diarandor or Christopho knows?
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

entity:get_position() give coordinates relative to the map. You can find coordinates relative to the screen if you just subtract the camera position.

That was the first thing I tried because I saw it in the Children of Solarus game_over.lua script. It seems I forgot to repeat my timer when checking my script, so a mistake on my part. Thank you Christopho and Zutokaza for the assistance. My script works perfectly now.