How to Create Multi-Room Layouts For a 2D Game Using Arrays

4

Index

Stats

1,219 visits, 3,694 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY-NC 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

This is the final step--the game has all the required information, it just needs to know which room to move the player to when they leave the layout. To do this, you need to do four things.

- If the player is outside the layout, then (trigger once):

- If the player's X is greater than (a number near the right edge), then

- add 1 to roomX, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's X to (a number near the layout's left edge)

- If the player's X is less than (a number near the left edge), then

- subtract 1 from roomX, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's X to (a number near the layout's right edge)

- If the player's Y is less than (a number near the top edge), then

- subtract 1 from roomY, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's Y to (a number near the layout's bottom edge)

- If the player's Y is greater than (a number near the bottom edge), then

- add 1 to roomY, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's Y to (a number near the layout's top edge)

What this does is makes it so that when the player leaves the layout, the edge they left from determines where they will end up. Leaving from the top edge will cause roomY to decrease, leaving from the right edge will cause roomX to increase, etc.

Remember that in Construct 3, all coordinates are in the fourth graph quadrant, meaning that X increases from left to right but Y increases from top to bottom instead of bottom to top.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!