Jump to content

Tower Rougelike Character Movement


zigazak
 Share

Recommended Posts

Hey guys, I've come up with a simple idea for a tower based 'rougelike' where each tower has randomly generated floors.

I'm having trouble coming up with an elegant way to build the towers and floors within Phaser such that a character can 'climb' the floors.

The characters will be controlled AI that simply climb the tower from right to left - left to right. 

An example -

Do you guys have any tips as to how I might be able to achieve this?

I've thought of just a standard tile map - with objects on each side of each floor, that when collided with will move the character to the floor above. 

example.png

Link to comment
Share on other sites

Yeah this one is literally a game design issue rather than specific to any library/framework. However you want it to happen, Phaser can help you make it happen.

Most games I've played like this have discrete floors, and the tower is climbed (or dungeon descended) sequentially, so, each floor has a 'win' condition which is indeed an object that, when collided with/interacted with, progresses the user to a new level, usually via a nice congratulatory screen that might additionally bestow some coins/XP/kudos for completing the level.

If you want to allow your user to revisit old levels then simply use something like a stairway/lift/teleporter that moves between levels. Each level is its own 2D tilemap (if thats how you're doing it) and when you hit the stairs (or whatever) you load the next tilemap and render it. Simple, but traditional.

Link to comment
Share on other sites

Thanks for the reply mattstyles :)

I've made a basic prototype of the 'tower building', which can be seen here http://codepen.io/JUNKLAB/pen/grOEOV

( you can use the up and down arrow keys to move the camera up and down the building )

My question now is, does Phaser have some sort of trigger functionality? Say my character moves all the way to the left of on of the rooms - I want him to automatically get teleported to the room above. 

I put together a crude implementation of this using the arcade body physics and collisions, was just wondering if there was something more suitable I could be using? ( the codepen uses x positioning to check wether the 'player' should be teleported to the next level).

 

Link to comment
Share on other sites

I dont think Phaser has any specific triggering mechanism, for general events I often use an event emitter (I use browserify to give me access to commonJS modules so the node eventemitter module, or something similar) and a pub/sub pattern i.e. on your collision with the 'exit object' for that level, I'd emit an event saying your user has hit the exit, something listening then triggers which puts the current level to sleep, moves the user to the next level and wakes up the next level (or whatever). I actually end up using a slightly different pattern that attaches callbacks rather than pinging events all over but the theory is largely the same.

You should be able to attach actions to specific collisions or overlaps i.e. a collision between your player and a specific object should trigger an 'exit level' action (I'm not sure how the Phaser arcade physics simulation works but most physics simulations require use of handlers for collisions between different groups or types of objects). This teleport action could then be generalised to other objects so you can reuse code to implement other stairs, ladders, teleporters etc etc, the Exit action would simply be a specialist teleport action that additionally updates other stuff in your game (such as making levels active/inactive, granting bonuses for level completion etc etc).

 

Link to comment
Share on other sites

That's the exact way I do portals in my game. They are a set of rectangles that I check collision for every frame, just like platforms and enemies. When the player overlaps them I call their callbacks to see if the level should transition or what.

Minor quibble: I use "overlap" instead of "collide" since I don't want the player bouncing away from the rectangles.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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