Does it make sense to create levels dynamically from an array?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'm new to Construct 3 and loving it so far.

    I'm making a Tower Defense style game that will have a lot of different levels.

    I'm simplifying a bit, but basically each level starts as a grid of 16 by 9 squares. Those squares are:

    S = Start (Green): Where the enemies spawn.

    E = End (Red): Where the enemies exit.

    P = Path (White): The trail the enemies follow.

    O = Open (Grey): Spaces where you can place towers.

    B = Blocked (Black): Spaces where you cannot build towers.

    Rather than create sheets for each level, I was wondering if I could create the levels dynamically from a file array (as in, this awesome tutorial from “Game Design by Reilly”).

    Once again, I am simplifying a bit, but the array would basically contain the X and Y coordinates and the value for that square (S, E, P, O, and B.

    Could I then have a single level sheet that would look up the proper grid layout for the current level from the array?

    If the answer is yes, then the follow up question is: how best to actually implement that design and create each level?

    For example, is there a Construct 3 command to draw squares with a solid color and border? Or, do I need to create 5 sprites (Start, End, Path, Open, and Blocked) and then dynamically write them to the layer?

    Thanks in advance for any help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It depends a little on the project and what you plan to do but it can absolutely make sense. But it's not strictly necessary, you can re-use the same eventsheet easily in multiple layouts, so if you prefer creating individual layouts and working entirely visually, that's fine.

    If you plan, for example, adding a level editor, creating levels from an array in the first place is probably much better. I also think it's a bit easier/cleaner to work with overall.

    For example, is there a Construct 3 command to draw squares with a solid color and border? Or, do I need to create 5 sprites (Start, End, Path, Open, and Blocked) and then dynamically write them to the layer?

    Technically you could probably use the canvas but don't bother. Just create the 5 sprites and/or use a tilemap.

    In my case I load an array like in this image, then do Array for each and create a bunch of sprites. It's quite easy since my game is based on a grid, so the coordinates are just array coordinates * gridsize.

  • WackyToaster,

    Thanks so much for the detailed reply.

    I'm glad this idea can work. Like you suggested, this will facilitate level creation by the user and make it easy for us to save completed levels (or even levels in progress).

    I'm excited to give it a try - now I just need to teach myself how to do it. :)

    Should be fun!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)