View Single Post
  #22  
Old 06-22-2001, 11:21 AM
Er1c Er1c is offline
Registered User
Er1c's Avatar
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
Er1c is on a distinguished road
I think I know what you're asking for... you want to be able to change all of one kind of tiles to a different kind.

All you need to do is make two arrays, use this.tile1 and this.tile2.

Then in this.tile1 make the array of all the tiles that you want the NPC to look for that should be changed, and in this.tile2 list all of the tiles (corrisponding to the other tiles) that the tiles in this.tile1 should turn into. When you list the tiles, you need to list them like this: tilex+tiley*16.

I'll make the NPC and put some comments in for you, dont just copy it, try to learn it for your self...

NPC Code:

for (cx = 0;cx<64;cx++) for (cy = 0;cy<64;cy++) { //will check every tile in the level
if (board[cx+64*cy] in this.tile1) {//checks if the current tile being checked is supposed to be replaced
for (i = 0;i<arraylen(this.tile1);i++) {//this for statment will find where in this.tile1 the current tile is
if (board[cx+64*cy]==this.tile1[i])
break;//stops the loop keeping i equal to the position of the tile to replace
}
board[cx+64*cy] = this.tile2[i]//replaces the tile with the new one specifyed in this.tile2
updateboard cx,cy,1,1;//updates the board to make the changes noticable
}
}



Well I haven't tryed this out, so tell me if it works or not... hope that answers your question and that you learn from it instead of steal it.
__________________
Eric Kraft
Reply With Quote