SoKoBan
Im bringing 2,
but it isnt
its all terrible... and sideways.
Quote:Ok, then blah[a][b] should be right-side up,
but it isnt
its all terrible... and sideways.
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-- ?
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-- ?
got it
WOO!
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!

