cs6505 wrote:I realize that GE has built in tile mapping and scrolling
The use of tiles is just an option that you can use. You can make your game without tiles by using a single image in your actor.
cs6505 wrote:I wanted to make a small scrolling game with a level editor included to add replay value. I am thinking I could store the levels in a simple text file and then load them into an array and then render them to the screen.
You can't change tiles in game mode, but you can simulate by using normal actors:
1) Create an actor "parentTile"
2) Create an actor "tile"
3) Make the parentTile parent of actor tile. This will help you to move the tiles
4) Add your tile animation in the tile actor
5) In the "Create Actor" event stop the animation with the "Change Animation Direction" action
6) Make a clone array with tile actor (like 20x16)
Now, make a txt file with the map info like this:
0 0 0 0 0 .... 0
1 0 0 0 0 .... 0
Make an array to hold the map info (in the Global Code editor):
int map[16][20];
Create a function to read the map (in the Global Code editor):
- Code: Select all
void readLevel(char *file)
{
int value, i, j;
if(!levelRead)
{
FILE *fp = fopen(file, "r");
if(fp)
{
levelRead = 1; //Don repeat reads
for(i = 0; i < 16; i++)
{
for(j = 0; j < 20; j++)
{
fscanf(fp, "%d", &value);
map[i*20 + j] = value;
}
}
fclose(fp);
}
}
}
And read the map in the view "Create Actor" event:
readLevel("level1.txt");
Download the complete sample here:
http://game-editor.com/examples/tile_map.zip