Okay, since the title's fucked up again, lemme picture it...
http://img262.imageshack.us/img262/5021/schemern7.jpg[/img]
I try to make the player character look into the direction of a specific object. Picture [1] shows what I have with the code in the following spoiler: The player changes his view according to the position of the respective object, but in a way that'd work for isometric movement; for example, if the object is in the lower-right part of the screen, the player looks down.
Picture [2] shows what I want to get: If the object is 'more in a specific direction than in another' (worst explanation ever, but the picture should do that job), the player should look there.
Thanks in advance.
http://img262.imageshack.us/img262/5021/schemern7.jpg[/img]
I try to make the player character look into the direction of a specific object. Picture [1] shows what I have with the code in the following spoiler: The player changes his view according to the position of the respective object, but in a way that'd work for isometric movement; for example, if the object is in the lower-right part of the screen, the player looks down.
Code:
def turn_towards_object
if @object.screen_x >= self.screen_x
if @object.screen_y >= self.screen_y
turn_down
else
turn_right
end
else
if @object.screen_y >= self.screen_y
turn_up
else
turn_left
end
end
end
Picture [2] shows what I want to get: If the object is 'more in a specific direction than in another' (worst explanation ever, but the picture should do that job), the player should look there.
Thanks in advance.