Hello everyone! I have been developing a maze game for a while now. It is a gridded game, and the grid is based on strings. I did this because the individual strings would be easy to manipulate.
Now that I have the game engine complete, and have written 14ish levels, I would like to make a level editor (I am the only person in my family who understands script). unfortunately, I have know idea how to overwrite a single character in a string...
Code:
"L" is lava, that will kill you.
"E" is the location of the exit to the maze
"P" is the location of the player when the level starts
"1" is a wall
"+" is the location to a portal (there CAN be more than 1)
"=" is the location that a portal will send you to (there can NOT be more than 1)
this is what a level looks like in the strings...
Code:
row1 = new String("111111111111111111111111111111111");
row2 = new String("100000000000000000000000000000001");
row3 = new String("100000000000000000000000000000001");
row4 = new String("100000000000000000000000000000001");
row5 = new String("100000000000000000000000000000001");
row6 = new String("100000000000000000000000000000001");
row7 = new String("100000000000000000000000000000001");
row8 = new String("100000000000000000000000000000001");
row9 = new String("100000000000000000000000000000001");
row10 = new String("100000000000000000000000000000001");
row11 = new String("100000000000000000000000000000001");
row12 = new String("10000000000000000P000000000000001");
row13 = new String("100000000000000000000000000000001");
row14 = new String("100000000000000000000000000000001");
row15 = new String("100000000000000000000000000000001");
row16 = new String("100000000000000000000000000000001");
row17 = new String("100000000000000000000000000000001");
row18 = new String("100000000000000000000000000000E01");
row19 = new String("100000000000000000000000000000001");
row20 = new String("100000000000000000000000000000001");
row21 = new String("100000000000000000000000000000001");
row22 = new String("100000000000000000000000000000001");
row23 = new String("100000000000000000000000000000001");
row24 = new String("100000000000000000000000000000001");
row25 = new String("111111111111111111111111111111111");
Ok, How can I take a string, and overwrite a single character?
I can't use replace because I want to replace only 1 character, no matter what it is, with any of the above characters...
sorry for the massive amount of info in this post, but everyone always complains about not having enough info...
map[0]= new Array(6,8,6,6,8,5,9,8,6,4,4,8,8,5,8,9)
map[1]= new Array(6,8,9,5,8,9,4,5,5,7,9,5,9,8,8,9)
map[2]= new Array(6,4,9,5,4,7,7,6,8,9,5,7,8,5,5,5)
map[2]= new Array(5,2,0,2,1,0,0,0,0,0,1,0,0,1,0,9)
map[3]= new Array(9,3,5,5,7,6,7,9,9,5,5,1,5,5,0,7)
map[4]= new Array(5,0,5,6,5,5,7,7,9,9,5,0,5,1,1,9)
map[5]= new Array(8,0,5,7,4,0,1,2,0,0,5,2,5,5,0,5)
map[6]= new Array(6,0,3,8,6,0,1,0,0,0,5,0,5,5,1,6)
map[7]= new Array(5,0,0,9,6,0,2,0,0,3,5,1,0,0,1,4)
map[8]= new Array(4,5,1,5,4,0,3,2,0,0,5,6,7,9,2,5) // X = start pos
map[9]= new Array(5,5,2,6,6,0,1,0,0,0,6,7,8,8,2,6)
map[10]=new Array(5,1,2,5,4,6,4,4,0,3,0,0,0,0,1,7)
map[11]=new Array(7,5,2,8,5,6,5,8,6,6,8,5,8,6,5,8)
map[12]=new Array(5,1,5,5,5,8,9,5,4,7,4,5,7,7,5,9)
map[12]=new Array(7,2,3,2,0,1,0,1,1,0,1,0,1,1,1,9)
map[13]=new Array(7,8,5,5,5,5,7,7,7,6,5,1,7,5,2,8)
map[14]=new Array(5,0,0,0,3,2,5,7,8,6,8,1,7,1,1,7)
map[15]=new Array(4,0,5,7,4,3,1,2,2,2,7,2,7,7,1,6)
map[16]=new Array(5,2,0,8,4,3,0,0,0,1,5,3,7,5,1,5)
map[17]=new Array(7,0,0,2,3,8,2,2,0,0,X,1,2,1,1,4)
map[18]=new Array(5,5,1,5,2,7,7,2,5,3,5,1,5,2,2,4)
map[19]=new Array(5,5,A,8,B,7,5,C,6,7,8,D,8,7,6,5)
so you can change every field with:
map[x][y] = *terrain*
but you could also use slice to change 1 character.
like: row9 = row9.slice(0, 10)+P+row9.slice(11, 20)
Hello everyone, I have managed to put together the level editor for my maze game. I am attaching the file, and I hope that some of you will open it, design a level with it, and send it to me via PM.
Design the level, and then click "view code" when your done. Copy and paste the code in your PM.
I included a "Copy" button that will copy the the text to clipboard for you, but it doesn't usually work...
the problem I'm having is that when I use this to copy multi-line statements, It will copy fine, It just doesn't copy as multi line... Everywhere a new line is started, it puts a square (when pasted into notepad). everywhere else, It runs as a continuous line