Skip to main content
1 of 3

How would i go about implementing portals into my game?

I don't mean to ask a broad question, so let me explain. I'm creating a 2D top-down design game and I'd like to implement "portals" to be able to switch between worlds. Each world is a level class, and at the moment portals are rendered as tiles, and changing world is handled in the player collision code. However, I have no way of determining which portal is dedicated to which level. I would perhaps also like to have the ability to lock portals until a player becomes a certain rank. I've tried to set up a portal class, and implemented it as entities that were spawned during level creation at the location of the portal tiles, and then all collision handling was passed to that class. It took in params of currLevel, targetLevel, x and y. When the player collided, it would change to the set targetLevel. However, when I ran the code and collided with the portal, the game just froze. There was no error output, ups was at 60 as standard and the fps was at about 3000 as standard. The terminal was also outputting as normal, but the game was doing nothing.

To conclude, I'd like to know if there is a better way to go about completing this? I may have just missed something.

Thanks