Page 1 of 1

Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 5:48 pm
by ficolas
Image

Is there any way the player isnt seen when the the entity is under it? so the player would be under the entity instead.

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 5:58 pm
by rk84
picture.priority = "extra-high" mayby?

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 6:15 pm
by ficolas
rk84 wrote:picture.priority = "extra-high" mayby?
No :(

Code: Select all

  {
    type= "container",
    name= "rocket-1",
    flags= {"placeable-neutral", "player-creation"},
    collision_box= {{-1.9, 2.4}, {1.9, 5.4}},
    selection_box= {{-2, -5.5}, {2, 5.5}},
    minable= { hardness= 999, mining_time= 9999, result= "rocket-1" },
    max_health= 50,
    drawing_position= {0.7, 0.12},
	icon="__F-mod__/resources/icons/rocket.png",
	inventory_size=104,
    picture=
    {
      filename= "__F-mod__/resources/entity/rocket/one.png",
      width = 160,
      height = 340,
      priority = "extra-high",
  }
  },

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 6:21 pm
by kovarex
The order of the pictures is determined primarily by layers (container and player have same layer, so it is ok).
Second condition is the y coordinate of the position of the entity, if you want the rocket to be above the player in this situation, you need to move it's location closer to it's base.
You can do it by moving the collision down and drawing position up.
(Look how trees are made)

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 6:33 pm
by ficolas
So how should it look like? the colision box is alredy down, and changing the drawing position does nothing :S

I think it was removed in 0.?

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 6:39 pm
by FreeER
probably replaced with the shift option:

Code: Select all

     pictures =
    {
      {
        filename = "__base__/graphics/entity/big-tree/big-tree-01.png",
        priority = "extra-high",
        width = 155,
        height = 118,
        shift = {1.1, -1}
      },

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 7:02 pm
by kovarex
Yes, shift is used everywhere (it is more general, and self-contained, mainly for entities with more sprites/animations).

Your collision box definition is:

Code: Select all

collision_box= {{-1.9, 2.4}, {1.9, 5.4}},
This means, the center is in the upper part of the object, it is not good.
You should make the collision box more like this:

Code: Select all

collision_box= {{-1.9, 6.8}, {1.9, 1.0}},
So the center of the object is on the place where the object touches the ground.

Re: Entity beeing shown up the player?

Posted: Thu Apr 25, 2013 11:20 pm
by SilverWarior
Factoprio is ment to be use topdown view so having something similar as in isometric view isn't easily done.

I would suggest that you split the entity picture into two parts:
- bottom part is show ans every other entity and is by default rendered behind the player. Colision box has same dimension as botom part
- top part has different Z order so it is always shown on top of other bottom parts or player character.

Re: Entity beeing shown up the player?

Posted: Fri Apr 26, 2013 9:25 am
by MF-
SilverWarior wrote:Factoprio is ment to be use topdown view so having something similar as in isometric view isn't easily done.

I would suggest that you split the entity picture into two parts:
- bottom part is show ans every other entity and is by default rendered behind the player. Colision box has same dimension as botom part
- top part has different Z order so it is always shown on top of other bottom parts or player character.
If the bottom part is shoter than the character, it won't work out well :P
Sounds like a hack that could work, true, but why? the top part should not have a collision box, which should be only at the place where it touches the ground.

Re: Entity beeing shown up the player?

Posted: Fri Apr 26, 2013 10:43 am
by rk84
kovarex wrote:Yes, shift is used everywhere (it is more general, and self-contained, mainly for entities with more sprites/animations).

Your collision box definition is:

Code: Select all

collision_box= {{-1.9, 2.4}, {1.9, 5.4}},
This means, the center is in the upper part of the object, it is not good.
You should make the collision box more like this:

Code: Select all

collision_box= {{-1.9, 6.8}, {1.9, 1.0}},
So the center of the object is on the place where the object touches the ground.
If that uses the same topleft-bottomright logic as findentities then top is lower then bottom? :? (in coords negative y axel goes up)

I though it would be more like this? (box centere around entity position so player does not loose his head in front of it)

Code: Select all

collision_box= {{-1.9, -1.5}, {1.9, 1.5}},
And then Shift the picture up 3.8125 tiles?

Re: Entity beeing shown up the player?

Posted: Fri Apr 26, 2013 8:54 pm
by MF-
negative on Y usually means UP in 2D. Coords are taken from the topleft corner for some historical reasons.
(That is NOT related to factorio. I have no idea how it works there)

Re: Entity beeing shown up the player?

Posted: Sun Apr 28, 2013 7:14 pm
by ficolas
I cant figure out how to do it...
If I move the colision box down, then the colision box will be out, and if I shift it down, then it will be the same...

Re: Entity beeing shown up the player?

Posted: Sun Apr 28, 2013 7:23 pm
by kovarex
ficolas wrote:I cant figure out how to do it...
If I move the colision box down, then the colision box will be out, and if I shift it down, then it will be the same...
This is the tree:

Code: Select all

collision_box = {{-0.4, -0.4}, {0.4, 0.4}}, -- small around the actual position of the entity
...
pictures:
{
 ...
  {
        filename = "__base__/graphics/entity/tree/tree-a01.png",
        priority = "extra-high",
        width = 84,
        height = 64,
        shift = {0.5, -0.8} -- Picture shifted up (left shift is because of the shadow)
      },

Re: Entity beeing shown up the player?

Posted: Wed May 29, 2013 3:23 pm
by ficolas
I have this problem again, do the priority have something to do with it?
This time I want it to be shown the lowest, below everything, but I cant even changing the hitbox (the hitbox should be 0 so...)

Re: Entity beeing shown up the player?

Posted: Thu May 30, 2013 1:09 am
by kovarex
The priority has nothing to do with that.
The priority just specifies internal order of sprites in the atlas, the goal is to have the most used sprites in the first atlas always, as switching from atlas to atlas slows down the render method.
So big sprites or sprites not used so often should never have the highest priority.

Could you provide example code?