Author Topic: Questions about programming a Roguelike game  (Read 22469 times)

mike3

  • Rogueliker
  • ***
  • Posts: 125
  • Karma: +0/-0
    • View Profile
    • Email
Questions about programming a Roguelike game
« on: January 29, 2010, 06:54:14 PM »
Hi.

I have a couple questions:

1. Which one of C or C++ is more often used for making Roguelike games? I've heard of other languages being used as well, but for games written with one of these two, which is the more often used one, and why?

2. How can one make a good level generator that generates levels without having tunnels remove the walls from rooms (piercing a room is fine, so long as it doesn't take off stretches of wall, or knock off a corner), or "double up" (i.e. parallel each other so close no wall is in between them)?

purestrain

  • Rogueliker
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
Re: Questions about programming a Roguelike game
« Reply #1 on: January 29, 2010, 08:52:55 PM »
1) c is used more often because of stup... tradition  :P .... and before someone complains: because of portability

2) i don't get the point there; maybe i'm missreading... this could help: http://roguebasin.roguelikedevelopment.org/index.php?title=Articles#Map

Greetings
Michael

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Questions about programming a Roguelike game
« Reply #2 on: January 29, 2010, 10:15:51 PM »
How can one make a good level generator that generates levels without having tunnels remove the walls from rooms

There are many ways to prevent that. Start from placing rooms so that they don't have walls next to each other, or if they have the walls are removed or a special corridor is made between them to connect them.

When you make corridors it's good not to make them travel over another rooms (this may be prevented with pathfinding or connecting rooms that are close).

Pathfinding is probably the tool you need to solve problem situations.

mike3

  • Rogueliker
  • ***
  • Posts: 125
  • Karma: +0/-0
    • View Profile
    • Email
Re: Questions about programming a Roguelike game
« Reply #3 on: January 29, 2010, 10:42:58 PM »
How can one make a good level generator that generates levels without having tunnels remove the walls from rooms

There are many ways to prevent that. Start from placing rooms so that they don't have walls next to each other, or if they have the walls are removed or a special corridor is made between them to connect them.

When you make corridors it's good not to make them travel over another rooms (this may be prevented with pathfinding or connecting rooms that are close).

Pathfinding is probably the tool you need to solve problem situations.

I thought about the use of a pathfinding algorithm, but I've heard stuff about it being really slow. Or would one only use the pathfinding algorithm some times (i.e. if we can't create a viable corridor between two points directly, switch to the pathfinding method?)? Also, what's so bad about crossing through a room, as opposed to bulldozing its walls? All it'd do is make more doorways.
« Last Edit: January 29, 2010, 10:47:57 PM by mike3 »

nhdaniel

  • Newcomer
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Questions about programming a Roguelike game
« Reply #4 on: January 30, 2010, 01:16:26 PM »
First up, choose a language you are comfortable with and familiar with using it. If you plan on learning a language by coding a roguelike, I would suggest starting on a small roguelike attempt first. Trying to achieve a large goal in a new language is difficult at best. As for which is more popular... download a few roguelikes and see...

On map/level generation... there are plenty of articles about this, the pitfalls and solutions. Path finding can be as simple or as complex as you choose to make it. And lets define slow... You are typically working with a small map (lets say 80x20), which even if you have to visit EVERY location four times you are only looking at 6400 visits to each location. Now this may have been a problem pre-1995, but I am fairly sure a dual-quad-core running the latest Radeon ANSI-8192 GPU will have no problems performing this task before you can blink.

My suggestion - go write some simple tests... see how the code works... this will help understand what makes things slow or fast.

mike3

  • Rogueliker
  • ***
  • Posts: 125
  • Karma: +0/-0
    • View Profile
    • Email
Re: Questions about programming a Roguelike game
« Reply #5 on: January 30, 2010, 09:26:38 PM »
First up, choose a language you are comfortable with and familiar with using it. If you plan on learning a language by coding a roguelike, I would suggest starting on a small roguelike attempt first. Trying to achieve a large goal in a new language is difficult at best. As for which is more popular... download a few roguelikes and see...

On map/level generation... there are plenty of articles about this, the pitfalls and solutions. Path finding can be as simple or as complex as you choose to make it. And lets define slow... You are typically working with a small map (lets say 80x20), which even if you have to visit EVERY location four times you are only looking at 6400 visits to each location. Now this may have been a problem pre-1995, but I am fairly sure a dual-quad-core running the latest Radeon ANSI-8192 GPU will have no problems performing this task before you can blink.

My suggestion - go write some simple tests... see how the code works... this will help understand what makes things slow or fast.

Hmm. It seems like C++ is used more often, at least for newer roguelikes.

As for the map generator, I suppose then one doesn't need a really complicated pathfinding method? And I was thinking bigger levels than that, like 80x80 at least.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Questions about programming a Roguelike game
« Reply #6 on: January 30, 2010, 10:21:43 PM »
As for the map generator, I suppose then one doesn't need a really complicated pathfinding method?

If rooms are rectangular and placed apart from each other there is no need for complex pathfinding at all. It becomes harder if you have odd shaped rooms, but even then you can use simple floodfill type pathfinding.

Z

  • Rogueliker
  • ***
  • Posts: 905
  • Karma: +0/-0
    • View Profile
    • Z's Roguelike Stuff
Re: Questions about programming a Roguelike game
« Reply #7 on: January 31, 2010, 12:00:45 AM »
Better to use C++ than C, because you gain many things (even if you don't think in an object oriented way, you still gain e.g. the STL's strings (much better than in C) and containers (very useful)), losing almost nothing (C is almost a subset of C++ and most C programs compile in C++ without change). (And you probably should think in an object oriented way when programming a roguelike.)