Jump to content

Unlimited tile world


xompl
 Share

Recommended Posts

Hi, this is a quite open question because I am not sure what's the best way to implement this using

Phaser.

 

I implemented a simple vertical shooter and I'd like to add a tiled background with trees, water, etc.

As far as I know, using for this a tilemap requires an actual matrix with the map content. The game will use

an extremelly narrow but potentially unlimited tile map so I though on creating one on the fly.

 

What's the best way to implement this?

 

In my current implementation create() populates the screen with 32x32 tiles and during the update() I

move all of them down to simulate the movement. When one row of tiles exits the window I move all

these tiles to the top.

This might be reinventing the wheel but all the tilemap examples use a fixed map. I'm open to new ideas.

 

My approach works but only if the speed of the movement is slow.

If I use this.tiles[y][x].body.y += 1 all the tiles are nicely aligned but if I use a speed like 5 the rows of tiles are not aligned anymore. Not sure if its a bug in my code or sync problems between update and draw.

post-7542-0-73242600-1394811293.png

post-7542-0-96987100-1394811310.png

Link to comment
Share on other sites

Sorry, not sure what you mean.

 

You mean a single tilemap where the charater is moving vertically (say 1000 rows and 30 colums)

and when the char is arriving to the end I copy the current tiles on screen to the first rows and move

the char to this position?

I thought about this solution but I was not sure how smooth I could make this "teleportation".

 

In my current implementation  I use 30 lines of sprites/tiles. On screen there are at most 21 lines 

at the same time.

 

Thanks for your help rich. I love Phaser!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...