FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  


FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Location Class and it's functions  (Read 1854 times)


  • Newbie
  • Posts: 2
    • View Profile
Location Class and it's functions
« on: July 30, 2012, 12:58:13 am »

I'm trying to make a couple of skeletons walk in random directions using a timed event. Noe the problem is. How do I tell an Instance to move to a location x,y coordinates with respect to it's present location? I've been fiddling around with getLayerCoordinates(), getExactLayerCoordinates(), getMapCoordinates(), getMapCoordinatesRef(), etc and their set counterparts. I can't seem to get it to work. I created a Point3D class (I used a DoublePoint3D class also) and used it to create a ExactModelCoordinate object (and also ModelCooridnate) and used the __add__() function to add it's coordinates to the another ExactModelCoordinate class or ModelCoordinate class which I had extracted from the Location object I received from the getLocation() function from the instance (one skeletal swordsman, the one I wanted to move). And I created a new Location with the added up ExactModelCoordinate orModelCoordinate and passed it on to the move function of the skeleton. But every time I manage to do this without errors. Nothing happens, all the skeletons are just standing there.

Can someone please let me know what's happening here and whether these are the things I ought to be tinkering with to get done, what I want here as mentioned above?


  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Location Class and it's functions
« Reply #1 on: July 30, 2012, 10:54:26 am »

You should use LayerCoordinates ;)
A few basics to locations:
Every location needs a layer (the layer have the grid and the grid is used for the calculations/conversions).
LayerCoordinates describe the center of a cell on a layer. ExactLayerCoordinates can describe every position on a cell.
The MapCoordinates are useful to convert, for example if you want to compare positions on two different layers or if you want to convert to ScreenCoordinates(which are simple pixel coordinates on the screen).

Since rev. 3992 FIFE has a new pathfinder. Therefore, it may be that your map is not correct. Your layer on which are the agents need the correct size (depends on your ground layer) and in the layer tag of the map file the layer type should be set to walkable. (layer_type="walkable")

You can take a look at the demos e.g. the shrine.xml map in demos/rio_de_hola/maps works with the new pathfinder.