FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

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

Pages: 1 [2] 3

Author Topic: Basics of instance and object manipulation  (Read 8740 times)

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Basics of instance and object manipulation
« Reply #15 on: December 17, 2012, 09:41:00 am »

The repository is right. But seems you mixed the last official release (0.3.3r3) and trunk.
Here is the win compile guide: http://wiki.fifengine.net/Building:Win32:SCons
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #16 on: December 17, 2012, 10:44:18 am »

Tried fresh install, same error.
engine_build_log.txt: http://pastebin.com/Y05au54E
engine_install_log.txt: http://pastebin.com/abuwgvUt
_fife.pyd hashes:
Code: [Select]
CRC-32: ae340d34
   MD4: 74b7a7b51e7a59f37f9f827a396c0bbd
   MD5: f754d26e48c1745400a855fe854be46f
 SHA-1: 65ee7551dbe06a688a1a85a7c1afd828ffae3cac
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #17 on: December 17, 2012, 11:04:08 am »

Oh, sorry, my mistake.
Error is different this time:
Code: [Select]
TypeError: in method 'CellGrid_getVertices', argument 3 of type 'FIFE::ModelCoordinate const &'
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Basics of instance and object manipulation
« Reply #18 on: December 17, 2012, 11:41:26 am »

Sorry no idea. Here it works, I tested it with rio and here is my code snippet:
Code: [Select]
loc = self.hero.agent.getLocationRef()
grid = loc.getLayer().getCellGrid()
vertices = grid.getVertices(loc.getLayerCoordinates())
for i in vertices:
print i
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #19 on: December 17, 2012, 11:46:14 am »

Changed getExactLayerCoordinates to
Code: [Select]
getLayerCoordinates()
Doesn't break anymore.
Will try and see if it does what i want.
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #20 on: December 17, 2012, 12:08:55 pm »

getVertices returns absolute coordinates (like 1036:441), and if i want to attach lines/points/whatever to a tile, not to a camera, i need them to be relative to instance's center. How can i get an instance's coordinates relative to camera's coordinate system?
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #21 on: December 17, 2012, 05:41:04 pm »

Code: [Select]
        clickpoint = fife.ScreenPoint(event.getX(), event.getY())
        if event.getButton() == fife.MouseEvent.LEFT:
            instances = self.get_instances_at(clickpoint, self._layers['ground_layer'])
            instance = instances[0]
            loc = instance.getLocationRef()
            grid = loc.getLayer().getCellGrid()

            vertices = grid.getVertices(loc.getLayerCoordinates())
            anchor = self._cameras['main'].toScreenCoordinates(grid.toMapCoordinates(instance.getLocation().getLayerCoordinates()))
            points = []
            for i in vertices:
                firstpt = self._cameras['main'].toScreenCoordinates(grid.toMapCoordinates(i))
                p = fife.Point(firstpt.x - anchor.x, firstpt.y - anchor.y)
                points.append(p)
            for i in range(0, 6):
                i1 = fife.RendererNode(instance, points[i])
                i2 = fife.RendererNode(instance, points[i - 1])
                self._generic_renderer.addLine('123', i1, i2, 0, 0, 0)
This works. Not perfect, though. And will have to finetune manually anyway.
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #22 on: December 18, 2012, 12:17:48 am »

I have an idea how to make perfect borders. I just have to create 2^6 sprites with borders prerendered on them with a single color. And when a map is loading, app will generate sprites with whatever colors i may need from the original ones. May take a while to process 64*[number of players] images though, but it don't have to redraw everything every time a new game is started. Just once a new color is involved and then store them for later usage.
Pluses: if border tiles and ground tiles are of the same size, zoom should work like a clock; probably a bit better performance, as engine won't have to make all this coordinates calculations.
Minus: speed hit when sprites are drawn for the first time.
Logged

Niektory

  • Newbie
  • Posts: 29
    • View Profile
Re: Basics of instance and object manipulation
« Reply #23 on: December 18, 2012, 03:36:30 am »

I don't think you'd need to generate separate sprites for different colors, the renderer can color them for you (InstanceRenderer::addColored()).
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #24 on: December 20, 2012, 04:14:04 am »

InstanceRenderer::addColored()
Thanks, i'll look into it.

Can i get a full list of available pychan styling attributes somewhere?
Also, is it possible to change SDL_app caption of the main application window and relocate it, before it has been properly initialized and loaded?
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Basics of instance and object manipulation
« Reply #25 on: December 21, 2012, 08:18:32 am »

We have settings to set the window title and icon. Rio de hola stores it in the settings.xml file.
Code: [Select]
    <Setting name="WindowTitle" type="str"> FIFE - Rio de hola </Setting>
    <Setting name="WindowIcon" type="str"> gui/icons/boy.png </Setting>
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #26 on: December 21, 2012, 09:31:57 pm »

Code: [Select]
<Setting name="WindowTitle" type="str"> FIFE - Rio de hola </Setting>
"SDL_app" title is visible for a second or two, then changes according to the setting.
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Basics of instance and object manipulation
« Reply #27 on: December 22, 2012, 09:25:52 am »

I had not realized but it's fixed now.
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #28 on: December 23, 2012, 09:31:01 am »

Pychan buttons keep focus after being clicked, and thus stop fife.IKeyListener from intercepting keystrokes. Is it possible to make a button unfocusable, to unfocus a button programmatically or to make FIFE use global keyboard hooks?
Logged

Kresp

  • Newbie
  • Posts: 22
    • View Profile
Re: Basics of instance and object manipulation
« Reply #29 on: December 23, 2012, 08:34:18 pm »

When i use addColored method, resulting objects are either too dark, or too bright (depenging on what base color was used for template image). How do i instruct engine not to recolour existing colour, but replace it, saving only alpha-channel from original pixels?
Logged
Pages: 1 [2] 3