SoKoBan

Member
Posts: 102
Joined: 2005.01
Post: #16
Im bringing 2,

Quote:Ok, then blah[a][b] should be right-side up,


but it isnt Sad Sad Sad Sad Sad

its all terrible... and sideways.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #17
HAHA FIGURED IT OUT,

its reading the file starting at the top left

index = 0;

and it starts drawing to the bottom left
a = 0, b = 0;

now how to fix it?

start a and b at 20 and use a-- and b-- ?
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #18
got it

Code:
- (IBAction)open:(id)sender
{
    NSString *lvl1 = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"lvl1" ofType:@"txt"]];
    int a, b;
    int index = 0;
    for (a = 20 ; a > 0 ; a--)    {
        for (b = 0 ; b < 20 ; b++)    {
            switch ([lvl1 characterAtIndex:index])    {
                case '#':
                    enviro[b][a] = WALL;
                    objects[b][a] = WALL;
                    break;
                case '@':
                    objects[b][a] = HERO;
                    xpoh = b;
                    ypoh = a;
                    break;
                case '+':
                    enviro[b][a] = GRASS;
                    objects[b][a] = NONE;
                    break;
                case '$':
                    objects[a][b] = BLOCK;
                    break;
                case '&':
                    enviro[b][a] = GRASS;
                    objects[b][a] = NONE;
                    padPos[b][a] = PAD;
                    break;
            }
            index++;    
        }
        index++;
    }
    [self setNeedsDisplay:YES];
}



WOO!
Quote this message in a reply
Post Reply