Re: bgt help, sidescroller and classes

I would recommend a dictionary for your map system, as that is what is primarily used. And if you want to use an array, use reserve.
but here, have a nice little thing I'm coding as i type this post.
This is mainly useful for 2dp games, but it'll work, and the less map data you need the less memory it eats.

dictionary map;
void set_tiles(int minx, int maxx, int miny, int maxy, string type)
{
for(int x=minx; x<=maxx; x++)
{
for(int y=miny; y<=maxy; y++)
{
map.set(x+":"+y,type);
}
}
}
//now, say I wanted to get the tile. Let's have a nice little string function for that. If it's air, return blank so it's air, unless you have a tile for air... Laggy!
string get_tile_at(int x, int y)
{
if(map.exists(x+":"+y)==false) return '";
string temptile;
map.get(x+":"+y,temptile);
return temptile;
}
//and now, if you wanted to get the players tile, assuming playerx and playery are your vars, you could write a function like this.
string get_player_tile()
{
return get_tile_at(playerx,playery);
}

I would highly recommend a dictionary over an array for map tiles and such.



_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : coltonhill01 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : coltonhill01 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : audiogames . net fan via Audiogames-reflector

Reply via email to