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

0 Members and 1 Guest are viewing this topic.

Zefk

  • Hero Member
  • *****
  • Posts: 535
  • Just helping Solarus
    • View Profile
    • Zefk Design
[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?

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • 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: 1194
    • 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

  • Hero Member
  • *****
  • Posts: 535
  • Just helping Solarus
    • View Profile
    • Zefk Design
[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.