Handle per frame custom offsets support in animations #67

Closed
Bertram25 opened this Issue Dec 3, 2012 · 12 comments

Projects

None yet

3 participants

@Bertram25
Member

Currently, all animation frames have the same origin point, and one have to play with the image data to make it look right.

This working quite well so far, except for certain map animations which needs to draw something below their origin point.
Map and battle objects have an origin based on the bottom center of their sprite meaning it's currently impossible to draw something below that point without specific hacks.

What I'll do (post-HEIR*) is to add the capacity to support per frame offsets in animation files, with a default of 0 to not break existing animation files.
Readd the new wolf shadow, and fix the grass clumps being cut at their base due to this limitation.

*HEIR stands for Half-Episode I Release.

@Bertram25 Bertram25 was assigned Dec 3, 2012
@rootslinux
Contributor

Can you provide a simple example that would demonstrate why this feature is needed? I'm not protesting this. I just want to understand why you feel it is necessary.

@Bertram25
Member

Try adding a quick south-projected shadow (below the sprite) to any battle enemy and you'll get what I mean.

You might also notice the need by observing the grass clumps seen around the snakes for instance.
The bottom part of those is cut.

@IkarusDowned
Contributor

@Bertram25 , I'd like to take a crack at this to get some more background on the rendering parts. Do you think you could post a couple screen shots of what you are talking about (a shot of how it is now, and a mock of how you want it to be?), I'd appreciate it :)

@Bertram25
Member

Hi @IkarusDowned, :)

What I'd like to do is adding this in the animation scripts:
Now:

animation = {
       -- ... (omitted to shorten)
    -- The frames duration in milliseconds
    frames = {
        [0] = { id = 0, duration = 75 },
        [1] = { id = 1, duration = 75 },
        [2] = { id = 2, duration = 75 },
        [3] = { id = 3, duration = 200 },
        [4] = { id = 4, duration = 40 },
        [5] = { id = 5, duration = 40 },
        [6] = { id = 6, duration = 75 },
        [7] = { id = 7, duration = 150 }
    }
}

After:

animation = {
       -- ... (omitted to shorten)
    -- The frames duration in milliseconds
    frames = {
        [0] = { id = 0, duration = 75, offset_x = 3, offset_y = 4 },
        [1] = { id = 1, duration = 75 },
        [2] = { id = 2, duration = 75 },
        [3] = { id = 3, duration = 200 },
        [4] = { id = 4, duration = 40, , offset_x = 3, offset_y = 4 },
        [5] = { id = 5, duration = 40 },
        [6] = { id = 6, duration = 75 },
        [7] = { id = 7, duration = 150 }
    }
}

You'll notice the offset x and y optional values for each frames. (if not given, equal to 0, for each separately)

This will permit us to display animation while not begin forced to have:

  1. A fixed frame alignement
  2. A fixed image center point

Example:
sprite_center
This is a normal tree, the sprite is displayed forcefully x-centered, y_top from the sprite point.
And I'd like the sprite to be offset slightly to the tree center, for instance.

Note that the offset would not change the sprite center coordinates, but only the image drawing actual coordinates from that center point. The collision rectangle and the image rectangle would have to also take this offset in account.

This would not change the sprite sorting algorithm also. So don't touch it.

The exact same goes for battle sprites.

This would permit, for instance to have south-projected shadows for enemies in battles for instance, and avoid cutting certain sprites (I'm thinking of the high grass clump, which south part is cut because of that feature gap).

I hope it's helping.

regards,

@IkarusDowned
Contributor

ok, I'll take a look.
btw, how did you get the grid lines to show up? :p

@Bertram25
Member

eh eh ;)
build using the DEBUG_MENU option:
cmake -DDEBUG_MENU=on .

and in game, push Ctrl+A to toggle this. It greatly helps when designing map objects and zones. ;)
Side-note: I should rename this option to something better.

@Bertram25
Member

Raised the priority of this one as I need it to fix the Lord attack point in the riverbank battle, and add several missing shadows.

@IkarusDowned
Contributor

hi Bertram,
I am actually working on this, and have some of the code comited into my
"offset" branch if you wanna check it out. There is still some bugs, but
working on them.

oh, i'm back by the way :)

On Wed, May 1, 2013 at 6:44 AM, Yohann Ferreira notifications@github.comwrote:

Raised the priority of this one as I need it to fix the Lord attack point
in the riverbank battle, and add several missing shadows.


Reply to this email directly or view it on GitHubhttps://github.com/Bertram25/ValyriaTear/issues/67#issuecomment-17256319
.

@Bertram25
Member

Hi @IkarusDowned :)

wb mate!

Ok, I'll let you finish that one and focus on the other ones.

Hope you're going well.

Regards,

@Bertram25 Bertram25 pushed a commit that closed this issue May 13, 2013
Yohann Ferreira Added offset support to still images.
As I was needing to fix several remaining issues and had already started
to work on it anyway, I finished that.
Hope you won't mind, Ikarus. ;)

I adapted the grass clump as a test case. But certain other sprites
also need that change.

Hopefully closes #67.
3a97da8
@Bertram25 Bertram25 closed this in 3a97da8 May 13, 2013
@Bertram25
Member

As told in the commit message, I added it to try and resolve certain little things I'd like to see fixed now before starting the rest. I hope you won't mind @IkarusDowned :)

Regards,

@IkarusDowned
Contributor

no not at all. i meant to mention that the commits i had on my branch were
just to get the stuff working. was going to refactor it when i had the
actual implementation in, but it looks like you already figured that out :)

of course i don't mind!

On Mon, May 13, 2013 at 11:47 PM, Yohann Ferreira
notifications@github.comwrote:

As told in the commit message, I added it to try and resolve certain
little things I'd like to see fixed now before starting the rest. I hope
you won't mind @IkarusDowned https://github.com/IkarusDowned :)

Regards,


Reply to this email directly or view it on GitHubhttps://github.com/Bertram25/ValyriaTear/issues/67#issuecomment-17816381
.

@Bertram25
Member

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment