Author Topic: [Solved]Screen vs entity position?  (Read 99 times)

Zefk

  • Sr. Member
  • ****
  • Posts: 482
  • Just helping Solarus
    • View Profile
    • Zelzec Business
[Solved]Screen vs entity position?
« on: May 15, 2017, 01:51:17 pm »
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?
« Last Edit: May 15, 2017, 05:28:04 pm by Zefk »

zutokaza

  • Full Member
  • ***
  • Posts: 139
  • Active - Making stories can take the most time.
    • View Profile
Re: Screen vs entity position?
« Reply #1 on: May 15, 2017, 04:32:51 pm »
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?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1008
    • View Profile
Re: Screen vs entity position?
« Reply #2 on: May 15, 2017, 05:08:27 pm »
entity:get_position() give coordinates relative to the map. You can find coordinates relative to the screen if you just subtract the camera position.

Zefk

  • Sr. Member
  • ****
  • Posts: 482
  • Just helping Solarus
    • View Profile
    • Zelzec Business
[Solved]Screen vs entity position?
« Reply #3 on: May 15, 2017, 05:27:31 pm »
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.