Mecha Posted August 11, 2014 Share Posted August 11, 2014 Hi guys, I'm new to phaser coding and all game coding in general and just getting my feet wet over the last couple of days.I decided over the weekend to start doing a few tutorials and my first little project was a 2d bomberman style game.I've been dabbling with Tiler and experimenting with layers for the hard objects(blocks - indestructible), Soft objects (Walls - Bombs destroy them) and then the rest (grass etc). At the moment i have my character walking around and can happily destroy blocks, collision is working as expected. My main problem is, due to experience, i'm not 100% what the best way to select the specific tiles. I currently have a raycast function (returns array of tiles) that i've written to create explosions on the affected area, but this is obviously on top of the layers. I've also been experimenting with the layer/tile properties, but have been hitting my head against the wall with trying to retrieve properties via the tile.So, my questions:How would you set up the Outer container (Blocks surrounding user), Walls (hit by bomb and removed) and differentiate between the blocks/select only specific tiles?Should i ditch the tiles view and concentrate on a 2d Array?Writing this may help me try to tackle this, but thought this was worth putting out to you either way. Thanks for reading Link to comment Share on other sites More sharing options...
powerfear Posted August 11, 2014 Share Posted August 11, 2014 I think you should be able to do this kind of game using the Phaser tilemap, something like this:var type = map.getTile(x, y, layer, true).index;if (index === 1) //solid wall cant pass{}else if (index === 2) //breakable wall can destroy it{}If this is not working out for you, you can also do it using a 2D array something like this:http://jsbin.com/gikiwovaveza/1/edit Mecha 1 Link to comment Share on other sites More sharing options...
Mecha Posted August 12, 2014 Author Share Posted August 12, 2014 I think you should be able to do this kind of game using the Phaser tilemap, something like this:var type = map.getTile(x, y, layer, true).index;if (index === 1) //solid wall cant pass{}else if (index === 2) //breakable wall can destroy it{}If this is not working out for you, you can also do it using a 2D array something like this:http://jsbin.com/gikiwovaveza/1/edit Thanks for the pointer powerfear. Yeah, i've rejigged the layers in Tiler again and the index method works just fine. Solution is fine for this exercise. Cheers. Link to comment Share on other sites More sharing options...
lewster32 Posted August 12, 2014 Share Posted August 12, 2014 Got to add my two cents; I wouldn't use Tiled/Tilemaps for this unless I was planning on crafting specific level layouts. Dynablaster/Bomberman style games are usually procedurally generated, with an outer wall, pillars spaced two apart and then destructible blocks randomly filling the remaining tiles except for a few 'safe areas' around the corners. With an algorithm set up to generate these kinds of layouts I could then easily create different sized arenas, change the amount of blocks etc etc. Mecha 1 Link to comment Share on other sites More sharing options...
Mecha Posted August 12, 2014 Author Share Posted August 12, 2014 Got to add my two cents; I wouldn't use Tiled/Tilemaps for this unless I was planning on crafting specific level layouts. Dynablaster/Bomberman style games are usually procedurally generated, with an outer wall, pillars spaced two apart and then destructible blocks randomly filling the remaining tiles except for a few 'safe areas' around the corners. With an algorithm set up to generate these kinds of layouts I could then easily create different sized arenas, change the amount of blocks etc etc. Agree with you Lewster.My first/current experiment doesn't seem like the best way to make this kind of game, but it's definitely helping me understand various parts of Phaser and basic game concepts... I think once i've added Powerups etc, ill go back and start a fresh with the input and things i've been soaking in.Thanks for the input ... i'll be sure to post my progress once in a while. lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts