• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Heez

[Help] Grid Based Dungeon Generator

3 posts in this topic

Hello everyone,

 

I am new to game development and to be honest I am an intermediate - beginner in the language of JAVA. I want to build a dungeon generator, based on rougelike techniques, such as the grid based dungeon generator. I read the instructions on the following site http://www.roguebasin.com/index.php?title=Grid_Based_Dungeon_Generator but I am not sure how I am able to implement all the data structures needed there.

 

I know how the floodfill algorithm works and I also know how to implement it later, but the first things I did do not work.

 

I have to create a grid of cells on an array and store four dimensions for each cell. If I have a cell of the size 5 on my array, the four dimensions would be (0,0) (4,0) (0,4) and (4,4) so the corner points of the cell, and the numbers are the locations on my two dimensional array.

 

The first thing I did was creating a datastructure which can hold a pair (2tupel) of Integers, called IntPair. Now I have to iterate over the array and store for each cell the four dimensions. How am I able to do this? If my description sucks, which it does, since I am confused at the moment, please visit the link and you get a clear idea of what I want to have.

 

All advice is welcome. I know that this is some basic stuff for most of you guys, but if you never have been into game development and such algorithms, its quite hard to write specifications into code right away.

 

Thank you in advance.

0

Share this post


Link to post
Share on other sites

First, these will help you with the Java game framework.

 

http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-active-rendering-r2418

http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-keyboard-and-mouse-r2439

 

As for your question, a simple solution is to create a custom object that contains all the data you need for the algorithm.  Then create a 2D array of your custom objects.


public class MyObject {

   private int data;
   
   public MyObject( int data ) {
      this.data = data;
   }
}

// elsewhere
  MyObject[][] grid = new MyObject[ROW_COUNT][COL_COUNT];
  for( int i = 0; i < grid.length;  ++i ) {
     for( int j = 0; j < grid[i].length;  ++j ) {
         grid[i][j] = new MyObject(i*j);  // just an example
     }
  }
0

Share this post


Link to post
Share on other sites

Humm you may also take some time to study Java core classes.

 

You may use the java.awt.Point as your coordinate class and or a java.awt.Rectangle to represent your '4 coords'.

 

If you want to build your own classes from scratch, at least take a look in Point and Rectangle implementations to 'get inspired':

 

http://developer.classpath.org/doc/java/awt/Point-source.html

http://developer.classpath.org/doc/java/awt/Rectangle-source.html

 

After that you may create a 'java.util.List'  ( ArrayList, or any other lists that fit your algorithm ) and store the objects in it. Something like that:

    List<Rectangle> myCoords = new ArrayList<Rectangle>();	
		
		
    for (Rectangle rectangle : myCoords) {
	// Do what you want with your rectangle
			
	
    }

 It will serve to hold your 'grid' coordinates, you still need to create an array to hold your 'cell' data, so its up to you to decide if you will use an array of integers or build your custom 'Cell' object to hold your Data.

 

If you are a OO programmer and want to use OO to model your problem, so you will build your own Cell class... otherwise, just follow with integer and primitive types.

0

Share this post


Link to post
Share on other sites

 

First, these will help you with the Java game framework.

 

http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-active-rendering-r2418

http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-keyboard-and-mouse-r2439

 

As for your question, a simple solution is to create a custom object that contains all the data you need for the algorithm.  Then create a 2D array of your custom objects.


public class MyObject {

   private int data;
   
   public MyObject( int data ) {
      this.data = data;
   }
}

// elsewhere
  MyObject[][] grid = new MyObject[ROW_COUNT][COL_COUNT];
  for( int i = 0; i < grid.length;  ++i ) {
     for( int j = 0; j < grid[i].length;  ++j ) {
         grid[i][j] = new MyObject(i*j);  // just an example
     }
  }

This is exactly how I created my IntPair class. In the constructor of this class I said that it has to have to parameters. So public void IntPair(int x, int y) {this.x = x; this.y=y} . After this I created an IntPair Array in my Cell Class (also in its constructor) and then I got stuck since I am not sure how to write it that it will save two Integers in an array of Int pair..

 

So IntPair intpair = new IntPair[4] // Since I only need 4 places per cell. Now I dont know how to assign ints to them. If I would create a single IntPair I would type: IntPair intp = new IntPair(3,3) . As I said, this is basic stuff. But I am confused at the moment.

 

//Edit : I got it, nevermind guys. Now I know how to safe a Pair of Ints, I wrote my own class. The next thing is to put a bunch of cells on an array. Thanks for your help.

 

 

Edited by Heez
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0