#An issue with my transition sprites!

107 messages · Page 1 of 1 (latest)

royal meadow
#

If I'm understanding this correctly you want the sprite to evenly spread vertically and horizontally?

teal venture
#

That's right! The issue is that, if I step through the sequence, the screen is fully covered with the transition sprites at different times

#

let me take some screenshots:

royal meadow
#

okay

teal venture
#

These are when hMod/vMod are 1/1 and -1/-1 respectively

#

And these latter two are when one is -1 and the other is 1

#

You can tell they're from the same point in the transition from the indicator at the center

#

Ideally, each should have the same amount of the screen covered at this point

royal meadow
#

so every time you run it with the values the same it's random?

teal venture
#

No, not random at all

#

it depends on the direction of the wipe

#

1/1 has it start from the bottom right, while -1/-1 has it start from the top left

#

1/1 is the fastest to cover the screen, -1/-1 is the slowest

#

the negative numbers were only supposed to change the direction of the transition, not the speed of it

#

The trouble is in this line, I think:

#

var _trueSubImg = currentSubImg+(i*hMod) + (k*vMod);

#

at 1/1, the lowest this number can go is currentSubImg+0

#

at -1/-1, the lowest it can go is currentSubImg-(_gamewidth div _spritewidth)-(_gameheight div _spriteheight+1)

royal meadow
#

yea

#

it could be that the sprite width/height needs to be added on negatives

#

does the animation fully complete?

#

or does it get stuck

teal venture
#

if it goes on for long enough, it completes no matter what

#

the only difference is the time it takes

royal meadow
#

what is currentSubImage set to

teal venture
#

in the example screenshots, it's at 30.10

royal meadow
#

var _trueSubImg = currentSubImg+(i*hMod) + (k*vMod); like the code in this?

#

the currentSubImg varbiable

teal venture
#

right, that changes over the course of the animation

#

that's how time is measured

royal meadow
#

If currentSubImg increases over the duration of the animation wouldn't that add 30.10 to the _trueSubImg

#

wait but that wouldn't do anything

#

Where does currentSubImg change

teal venture
#

it changes every frame, but right now I can change it manually to test things

royal meadow
#

will the animation run without currentSubImg

teal venture
#

I... don't know how it would

royal meadow
#

wait sorry that was a dumb question

teal venture
#

If I removed it, all that would determine the sub-image of each sprite would be its position

royal meadow
#

well it wont do exactly what you need it to do but if you run it based on the position will it still be inconsistent

teal venture
#

Doing some measurements, here are the frames of currentSubImg where the screen is covered for each value of hMod/vMod:

#

1/1: 32
1/-1: 40 (8 off)
-1/1: 46 (14 off)
-1/-1: 54 (22 off)

royal meadow
#

is the ratio of your screen 8/6?

teal venture
#

the problem here isn't the ratio of the screen, it's more that like...

#

I should be able to mirror the animation and have it run at the same speed

royal meadow
#

but um

#

I'm trying to wrap my head around this but I can't figure out why this won't work

royal meadow
#

the hMod and vMod things seem to work fine

#

actually I might know why

#

it looks like its just the negatives making it take longer than it should

#

uh that was a bad explanation

#

var _trueSubImg = currentSubImg+(i*hMod) + (k*vMod);

#

In this code

#

if you're using -1/-1

#

which would be: currentSubImg-(_gamewidth div _spritewidth)-(_gameheight div _spriteheight+1)

#

subimg has to add the extra amount that you subtract with -(_gamewidth div _spritewidth)-(_gameheight div _spriteheight+1) to the end

#

What you could do is make seperate variables for k and i

#

and use min() and set their minimmum value to 0

#

which I think should fix it

#

var _gamewidth = display_get_gui_width();
var _gameheight = display_get_gui_height();
    
var _spritewidth = sprite_get_width(transitionSprite)
var _spriteheight = sprite_get_height(transitionSprite);

for (var i = 0; i < _gamewidth div _spritewidth;i++)
{
    for (var k = 0; k < _gameheight div _spriteheight+1;k++)
    {    
        var k1 = (k*vMod); k1 = min(k1, 0);
        var i1 = (i*hMod); i1 = min(i1, 0);
        var _trueSubImg = currentSubImg+k1 + i1;
        
        if _trueSubImg < 0
        {
            _trueSubImg = 0;
        }
        else if _trueSubImg > _endSprite-1
        {
            _trueSubImg = _endSprite-1;
        }
        draw_sprite(transitionSprite,_trueSubImg,i*_spritewidth,k*_spriteheight);
    }
}```
#

something like this maybe

teal venture
#

min ruins the directionality

royal meadow
#

ah

royal meadow
#

sorry I had to do something

#

So it is delayed when it is negative I assume

#

before the animation starts

#

for -1/-1 it should start at 22

teal venture
#

I've noticed actually that, when starting from 0

#

-1/-1 actually starts out at the proper point, with nothing drawn to the screen

#

1/1 has a bunch of squares appear without animation

royal meadow
#

yep

#

I have a mock version of your animation made right now and it does the same thing

#

var _gamewidth = display_get_gui_width();
var _gameheight = display_get_gui_height();
    
var _spritewidth = sprite_get_width(transitionSprite)
var _spriteheight = sprite_get_height(transitionSprite);

for (var i = 0; i < _gamewidth div _spritewidth;i++)
{
    for (var k = 0; k < _gameheight div _spriteheight+1;k++)
    {    
        var k1 = (k*vMod);
        var i1 = (i*hMod);
        var currentSubImg1 = currentSubImg;
        if(k1+i1 == -2) {
        currentSubImg1 = currentSubImg+22;
        }
        else if (k1 == -1){
          currentSubImg1 = currentSubImg+8;
        }
        else if (i1 == -1){
          currentSubImg1 = currentSubImg+14;
        }

        var _trueSubImg = currentSubImg1+k1 + i1;
        
        if _trueSubImg < 0
        {
            _trueSubImg = 0;
        }
        else if _trueSubImg > _endSprite-1
        {
            _trueSubImg = _endSprite-1;
        }
        draw_sprite(transitionSprite,_trueSubImg,i*_spritewidth,k*_spriteheight);
    }
}```
#

whoops gimme a second to edit that

royal meadow
#

that should fix it

#

oh I left in the min sry

#

now it should be good

teal venture
#

so the solution is basically manually putting in magic numbers to fix it

#

it didn't actually work, but

royal meadow
#

oh I mightve mixed the number around

#

but yea you have to change that base currentSubImg number

teal venture
#

I think I'm just gonna give up on this issue for now

#

maybe scrap the sprites altogether and find some other transition to do

royal meadow
#

uh I fixed it for me I mmessed up the code I sent

#

var _gamewidth = display_get_gui_width();
var _gameheight = display_get_gui_height();
    
var _spritewidth = sprite_get_width(transitionSprite)
var _spriteheight = sprite_get_height(transitionSprite);

for (var i = 0; i < _gamewidth div _spritewidth;i++)
{
    for (var k = 0; k < _gameheight div _spriteheight+1;k++)
    {    
        var k1 = (k*vMod);
        var i1 = (i*hMod);
        var currentSubImg1 = currentSubImg;
        if(vMod+hMod == -2) {
        currentSubImg1 = currentSubImg+22;
        }
        else if (vMod == -1 && hMod == 1){
          currentSubImg1 = currentSubImg+8;
        }
        else if (hMod == -1 && vMod == 1){
          currentSubImg1 = currentSubImg+14;
        }

        var _trueSubImg = currentSubImg1+k1 + i1;
        
        if _trueSubImg < 0
        {
            _trueSubImg = 0;
        }
        else if _trueSubImg > _endSprite-1
        {
            _trueSubImg = _endSprite-1;
        }
        draw_sprite(transitionSprite,_trueSubImg,i*_spritewidth,k*_spriteheight);
    }
}```
#

I did this

#

and it worked completely fine

#

I just mixed up my variables when writing it

teal venture
#

okay, yeah, that seems to work

#

still, it doesn't sit right that I'd have to resort to magic numbers for this

royal meadow
#

Yea I hate to do it but I couldn't think of any other way

#

there most definitely is a way though

#

ok I came up with a solution

#

var _gamewidth = display_get_gui_width();
var _gameheight = display_get_gui_height();
    
var _spritewidth = sprite_get_width(transitionSprite)
var _spriteheight = sprite_get_height(transitionSprite);

for (var i = 0; i < _gamewidth div _spritewidth;i++)
{
    for (var k = 0; k < _gameheight div _spriteheight+1;k++)
    {    
        var _trueSubImg = ((4+(-4*vMod))+(7+(-7*hMod))+currentSubImg) + (i*hMod) + (k*vMod)
        
        if _trueSubImg < 0
        {
            _trueSubImg = 0;
        }
        else if _trueSubImg > _endSprite-1
        {
            _trueSubImg = _endSprite-1;
        }
        draw_sprite(transitionSprite,_trueSubImg,i*_spritewidth,k*_spriteheight);
    }
}```
#

Just had to wrap my head around it lol

teal venture
#

Still as magic numbers, just in a different place :y but it is more compact, I suppose

royal meadow
#

yea

#

but compact == better

teal venture
#

maybe once you understand what's happening in a given bit of code, but I feel like this'll just confuse me more when I try to go back and actually fix it

royal meadow
#

actually yea thats true

#

might wanna keep it on the previous one if you're gonna fix it later

teal venture
#

yeah

royal meadow
#

Anyways that's as far as my knowledge goes

#

Good luck on fixing that