Page 1 of 1

loading system issues

PostPosted: Sun Sep 18, 2011 11:05 am
by savvy
Code: Select all
for(i=0;i<5;i++)
        {
            Y=i;
            CreateActor("block", "BLOCKS", "(none)", "(none)", px+80, (py-80)+(Y*40), true);
            lpos=(playerpos-30)+(Y*16);
        }

so why, when Y*16 is 0 does playerpos-30 NOT equal playerpos-30? this makes no sense!
i tried if(i>0)Y++;
i tried Y++;
i tried other things, anyone had this issue before?
lpos is the assignment of a block to an array (my nomcraft loading system)

the 0 value is wrong, but when Y is > 0 everything works perfectly... just 1 odd number.

thanks savvy

Re: loading system issues

PostPosted: Sun Sep 18, 2011 11:37 am
by skydereign
You kind of jumped into your explanation, and seems like you skipped some things. I've not come across problems with the indexing of a for loop. Though, why are you using Y, if you just set it equal to i? Might as well replace Y for i (though that wouldn't fix your problem). From this though, I assume Y is a global variable? The only thing I can think of that would change Y when it is zero is if somewhere in the block's create actor event Y is changed (that or playerpos). Anyway, a little more detail might help.

Re: loading system issues

PostPosted: Sun Sep 18, 2011 1:45 pm
by savvy
Y=i was my attempt at finding solutions to the problem, it wasnt originally that. it isnt global because its in a void command, heres the full code...
Code: Select all
int blocks[192][2];
int playerpos;
int px,py,lpos;

void load(char dir)
{
    int i,Y;
    if(dir=='l')
    {
        for(i=0;i<5;i++)
        {
            Y=i;
            CreateActor("block", "BLOCKS", "(none)", "(none)", px-80, (py-80)+(Y*40), true);
            lpos=(playerpos-34)+(Y*16);
        }
    }
    if(dir=='r')
    {
        for(i=0;i<5;i++)
        {
            Y=i;
            CreateActor("block", "BLOCKS", "(none)", "(none)", px+80, (py-80)+(Y*40), true);
            lpos=(playerpos-30)+(Y*16);
        }
    }
    if(dir=='u')
    {
        for(i=0;i<5;i++)
        {
            Y=i;
            CreateActor("block", "BLOCKS", "(none)", "(none)", (px-80)+(Y*40), py-80, true);
            lpos=(playerpos-34)+Y;
        }
    }
    if(dir=='d')
    {
        for(i=0;i<5;i++)
        {
            Y=i;
            CreateActor("block", "BLOCKS", "(none)", "(none)", (px-80)+(Y*40), py+80, true);
            lpos=(playerpos+30)+Y;
        }
    }
}

maybe yes, playerpos changing... ill try limiting it, its under a fraction of a millisecond so.. cant exactly see errors ^-^

Re: loading system issues

PostPosted: Sun Sep 18, 2011 10:03 pm
by skydereign
Well just because it happens extremely quickly doesn't mean you can't see it. You can do a number of things to either store the value, or test the value. For example you can create two variables, and before the Y=i, you set the first one equal to i. And set the second one to display after the lpos line. Then just display those two variables. What I do is use a text file, and print out debug information into that. You can also change actors' color if a variable equal something, even exit the game. I can't really see anything wrong with this, but if it continues to happen, you can upload the ged so I can take a look.

Re: loading system issues

PostPosted: Fri Sep 23, 2011 8:04 am
by savvy
dont worry sky, i sorted it... thanks for trying anyway :P

savvy

Re: loading system issues

PostPosted: Fri Sep 23, 2011 11:24 am
by skydereign
Well, for the sake of the topic, can you post what was going wrong, and how you fixed it? Not sure if there was an relevant/obvious fix or problem, but we should strive to have topics have answers. Otherwise topics like these aren't useful to anyone else reading them, and just make finding solutions harder.

Re: loading system issues

PostPosted: Fri Sep 23, 2011 2:40 pm
by savvy
i just removed what was going wrong, the 1st bit of the array.. when i/Y is 0... i put if(i>0) infront of the create actor, problem solved.
then with the missing corners, make the area NOT a square and it works fine!

savvy