Random Generation

Is there a way to randomly generate a 2d dungeon? also how do i use tiles/tilesets

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    There are algorithms online for creating 2d dungeons (mazes), though not specifically for GameSalad. Tile sheets are not supported at this time.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • how would i use this in a game?

  • ArmellineArmelline Member, PRO Posts: 5,364

    That's like asking someone how to make the car you're building accelerate. By the time someone's done answering the question they'll have taught you how to build almost the whole car. Nobody is going to be able to teach you how to do what you want. You need to look up some GameSalad tutorials and watch some videos, and make a lot of little practice projects. @The_Gamesalad_Guru has a video series on logic that might be a good place to start, and @jamie_c has a great introductory GameSalad course with example projects to build.

    Once you've got a good grasp on the basics and what you can and can't do with GameSalad, you'll be able to come back and ask a more specific question that someone will actually be able to answer :D

  • ookami007ookami007 Member Posts: 581

    Honestly... there's no good way that I've found to create a TRULY random dungeon in GameSalad. The idea I came up with was to break the final dungeon size into sections and then create multiple random areas for each section. Each section would have to be made so that it joins the other sections, but once designed, you could generate a fairly random dungeon each time.

    Another idea is to use a digger. First, say your "tile" size will be 64x64. Fill your screen with 64x64 actors of walls. Next, create a "digger" actor and have him move in random directions, occasionally creating a new digger to a maximum of x diggers.

    Each digger would move 64 pixels (one tile) in any direction and when it collided with a wall actor, it would destroy the wall actor. What's left would be a random dungeon with more natural features. You could also have it spawn rooms by spawning a new actor that destroys walls and itself. So square, rectangular, etc. actors with sizes in multiples of 64.

    The problem with this method is it doesn't give pretty dungeons and you're limited to making dungeons with one type of wall.

  • gamestudentgamestudent Member Posts: 504

    @ookami007 said:
    Honestly... there's no good way that I've found to create a TRULY random dungeon in GameSalad. The idea I came up with was to break the final dungeon size into sections and then create multiple random areas for each section. Each section would have to be made so that it joins the other sections, but once designed, you could generate a fairly random dungeon each time.

    Another idea is to use a digger. First, say your "tile" size will be 64x64. Fill your screen with 64x64 actors of walls. Next, create a "digger" actor and have him move in random directions, occasionally creating a new digger to a maximum of x diggers.

    Each digger would move 64 pixels (one tile) in any direction and when it collided with a wall actor, it would destroy the wall actor. What's left would be a random dungeon with more natural features. You could also have it spawn rooms by spawning a new actor that destroys walls and itself. So square, rectangular, etc. actors with sizes in multiples of 64.

    The problem with this method is it doesn't give pretty dungeons and you're limited to making dungeons with one type of wall.

    That is kind of cool...

  • ookami007ookami007 Member Posts: 581

    Do you use Mac or PC version? I can show you a quick and dirty sample of the digger method.

  • ookami007ookami007 Member Posts: 581

    Here's both versions...

    It will first fill the scene with wall actors

    Then, it spawns a digger and the digger moves around killing walls by moving into them

    After a random amount of time, it destroys itself and spawns a view to allow you to use the ARROW keys to move around the scene... head right and up since the digger spawns in the middle of the scene.

    Obviously, to be usable, you'd need to tweak it and add checks for the edges of the scene, etc.

  • ookami007ookami007 Member Posts: 581

    If you want more corridors, change the random number in digger to 1-4

  • its good, but its rly slow

  • ookami007ookami007 Member Posts: 581

    yup... I haven't found a faster method using GameSalad, but then again, I really haven't devoted alot of time to it.

  • ok, do u know a way to make the same actor clone next to each other infinitely?

  • ookami007ookami007 Member Posts: 581

    Technically, you could put a spawn actor routine to spawn the same actor with an offset of self.width to the X or Y. Then one spawns one, which spawns another, that spawns another, etc.

    Of course, you will crash and burn unless you put some type of limiter on it.

  • is there a way i could make it only spawn if you are near where it would spawn

  • ookami007ookami007 Member Posts: 581

    You'd need to have a conditional in the spawner that looks at the distance between it and the player actor.

    That means using constrains in the player actor to set a game attribute - like playerX and playerY to the player actor's self.position.x and self.position.y respectively.

    Then, in the spawner actor, you need to figure the distance - and have the spawn activate when it's less than or equal to whatever the minimum distance is.

  • ok, so now I'm making a mining game... how would i quickly fill a big space with a tile and randomly generate some ores in it, with better ores lower down?

  • ookami007ookami007 Member Posts: 581

    Honestly... you're probably better off starting off with the screen pre-populated and then just generating the ores.

    Is the scene the same size as the screen? Or will you be able to scroll around?

  • able to scroll around, how do i make it prepopulated?

  • ookami007ookami007 Member Posts: 581

    Just create your scene and fill it with the base tile. Then you can just randomly spawn the ores.

  • but i want it to be infinite

  • ookami007ookami007 Member Posts: 581

    What do you mean... infinite?

  • ArmellineArmelline Member, PRO Posts: 5,364

    You're still trying to get us to build your car for you. Take some time to learn the basics of GameSalad and then ask questions a bit narrower in scope than "How do I create this entire game system?"

  • by infinite i mean i want it to be whenever your near somewhere it will fill with blocks

Sign In or Register to comment.