Home > Uncategorized > super simple level editor

super simple level editor

Phil and I were talking about level editing, and how to load them, and I realized that I already made a very primitive level editor in processing as well as a simple obj-C method to load those files. The file format assumes that you want to populate an array and that the array contains only zeros, each line of the level file looks like this scheme:


so you find in each line where in X and Y space to put the ID.

So here is the processing project:fleeItLevelEditor.pde and the method to load those files looks somewhat like this:

-(void) makeLevel:(int) level{
  int levelMap[100][100];
  int i,j;
  NSString *S=[[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Level_%i",level] ofType:@"txt"] encoding:NSASCIIStringEncoding error:NULL];
  NSArray *T=[S componentsSeparatedByString:@"\n"];
  for(NSString *L in T){
    NSArray *E = [L componentsSeparatedByString:@" "];
    int x,y,w;
    x=[[E objectAtIndex:0] intValue];
    y=[[E objectAtIndex:1] intValue];
    w=[[E objectAtIndex:2] intValue];
    NSLog(@"set element at pos:%i y:%i to:%i",x,y,w);

Cheers Arend


Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.