loading system issues

You must understand the Game Editor concepts, before post here.

loading system issues

Postby savvy » Sun Sep 18, 2011 11:05 am

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
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: loading system issues

Postby skydereign » Sun Sep 18, 2011 11:37 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: loading system issues

Postby savvy » Sun Sep 18, 2011 1:45 pm

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 ^-^
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: loading system issues

Postby skydereign » Sun Sep 18, 2011 10:03 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: loading system issues

Postby savvy » Fri Sep 23, 2011 8:04 am

dont worry sky, i sorted it... thanks for trying anyway :P

savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: loading system issues

Postby skydereign » Fri Sep 23, 2011 11:24 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: loading system issues

Postby savvy » Fri Sep 23, 2011 2:40 pm

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
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron