PDA

View Full Version : Develop a roguelike from scratch



foxfire29
05-31-2009, 06:35 PM
Hi, I am intending to develop a roguelike from scratch in MS VS C++ , unsure of whether to go with a win32 app or console poject but considering I love adom well I would appreciate any advice you can give on getting started, I have read lots of theory but I really need to see an example of say a rougelike gameloop in main, I have ideas and could put something together but I really want to complete something this time hence dont want to just code thrash and end up 3/4 the way through having to do massive re-writes.

My main hurdle would be how to do AI, and exactly in code how to draw the dungeon on screen?

All I am interested in at the momment is building a single 4 * 4 dungeon with 1 player and 1 monster, the player and monster have a viewing distance fixed viewing distance, when the moster sees the player the monster attacks.

So then I have to consider timing of attacks, how is this done?

I figure also have a player and monster class , player has attributes which I can code later but I just want to set fixed values to start with an see if I can code simplistic combat and ai, basically start small, simple and build incrementally after testing.

I just compiled and succesfully ran the angband source and after looking at its numerous API hooks etc its made me not so keen to go with a windows32 app

N.B I have been to roguebasin but I need a barebones piece of code that is well written, clean , small as hell and well commented if possible, plus any advice any of you can give :)

I dont want to use LUA or Ncurses so no libraries or scripting languages as I am determined to nail various areas I lacked in coding and I figure a text game is a good way to go, I did write some direct X newbie code away back and bought a directx book which I read lots of, so I understand the complexities involved, I mention this because I in essence crash coursed direct3d :) however I realise that I need to get so many fundemental concepts nailed that I need to start small and with text only(I also concur that this is no easy option )

Thanks all!

Heres a link to another forum post I created, I am just going around the differant communities forr thoughts and ideas as well as trying to pull resources as I want to ty some stuff out tommorow but I need as good a start as I can get to stand a hope in hells chance which is why I am asking :)

http://groups.google.co.uk/group/rec.games.roguelike.development/browse_thread/thread/5c76784f18f7b8a2#

Just as an "aside" Is there a beta test program for jade or something similiar? Just curious but not wanting to derail the thread

MRB 255
05-31-2009, 09:39 PM
Hi. It just so happens that I've been doing the same thing. I haven't gotten very far yet, but I more or less have the basic framework done. So far it can draw the map, the pc can move, and there it a vary basic item system. It does use ncurses, but nothing outside of ui.h and ui.cpp uses that (I think), so that should be fixable. Anyway, I attached the source, so feel free to look at it.

Also, first post from a long time lurker!

magellan
06-01-2009, 11:19 PM
So then I have to consider timing of attacks, how is this done?

I figure also have a player and monster class , player has attributes which I can code later but I just want to set fixed values to start with an see if I can code simplistic combat and ai, basically start small, simple and build incrementally after testing.


just some quick and dirty comments on these 2

a) for starters it might be the simplest to just go "your turn - my turn" just loop through all critters on the map

wich leads us directly to 2:
seperating monsters from players is very rarely done these days. The player is a monster, that just happens to listen to keyboard input instead of AI.
If you don't do that you need to do several things twice.
For exampe You would have a routine player_attack_monster and one monster_attack_player
If both are the same you just have one routine attack(att,def)

Good luck with your project!

gut
06-05-2009, 10:10 AM
http://www.adom.de/misc/qhack.php3

Ter13
07-29-2009, 03:44 PM
To be perfectly honest, QuickHack is not a good example to look at. More than likely, you are going to want to look into more "mainstream" and recent games. Remember that any 2D game tutorials can be translated into writing a roguelike. If anything, often the more modern tutorials will do you better than the same ten year old roguelike tutorials, as event-based architecture and OOP is much more developed and available this day.

Roguelikes that use the Curses/NCurses/PDCurses libraries are a huge waste of time due to certain limitations. For instance, curses can't "Shift" the display like you can using a backbuffered graphical drawing method.

Modern roguelikes are more often being written in C++ using an OpenGL rendering system. They run faster on modern computers due to certain rendering tricks like partial printing, and only-on-need updates.

This is why Biskup's roguelikes suffer/benefit from nostalgia or "old design". One-screen dungeons aren't a bad thing, but frankly, it's a little outdated. JADE, however, seems to not have this problem, as it most certainly does not use CURSES to render things.

Grey
07-29-2009, 10:13 PM
Modern roguelikes are more often being written in C++ using an OpenGL rendering system. They run faster on modern computers due to certain rendering tricks like partial printing, and only-on-need updates.


I'd like to hear of one roguelike that uses OpenGL... (Okay, so I know a couple, but they're extremely rare - curses is still the primary library of choice for roguelike display, with perhaps jice's libtcod threatening to overtake it.)

Silfir
07-29-2009, 11:19 PM
Dwarf Fortress uses OpenGL.

sgeos
07-31-2009, 05:56 PM
As far as I know, Dwarf fortress isn't really possible for blind people to play.

foxfire29
08-04-2009, 06:10 PM
Hi Thanks for all these reponses and the feedback, I was doing okay until I decided I wasnt going to have a static map and that I would randomly generate areas, suffice to say I only got a little way with that and randomly generated stuff is much harder then it sounds :)

Im about to start workimng on it again which is one of the reasons Im luking/posting again :)

Thanks all

P.S I did read about ncurses but I figured if I go with c or c++ all the way then whatever I learn from the roguelike well because of the nature of C these skills are transferable, ncurses gets a good name from what I have read about it.

Prior to doing my roguelike I ended up doing some research on things like template classes ; I have used classes, inheritance, polymorphism in past programs and all that jazz lol but I hadnt used template classes, looking at various roguelikes source code I saw extensive use of such things so I kinda got bogged down learning this stuff and I initially decided to set myself an exersise as follows:

Read a random map into an array so you have say lots of ####### for walls ,
Next draw random squares, and make then all join until they exactly fill up the screen width and height

So like



######################
# ## #
#####################


As you can see thats like two rooms perfectly aligned, I wanted to do this all over the screen and near the edges of the screen if the random numbers for length and breadth didnt fit itb would roll another squares dimensions until one did fit, got so far and granted this system would not work for a roguelike but I figured it was a good excersise

mike3
08-18-2009, 11:31 PM
To be perfectly honest, QuickHack is not a good example to look at. More than likely, you are going to want to look into more "mainstream" and recent games. Remember that any 2D game tutorials can be translated into writing a roguelike. If anything, often the more modern tutorials will do you better than the same ten year old roguelike tutorials, as event-based architecture and OOP is much more developed and available this day.

Roguelikes that use the Curses/NCurses/PDCurses libraries are a huge waste of time due to certain limitations. For instance, curses can't "Shift" the display like you can using a backbuffered graphical drawing method.

Modern roguelikes are more often being written in C++ using an OpenGL rendering system. They run faster on modern computers due to certain rendering tricks like partial printing, and only-on-need updates.

This is why Biskup's roguelikes suffer/benefit from nostalgia or "old design". One-screen dungeons aren't a bad thing, but frankly, it's a little outdated. JADE, however, seems to not have this problem, as it most certainly does not use CURSES to render things.

Does this mean that I should use C++ instead of C for programming a Rogue-like game? Because I've got some code for one I was trying to make and it's all in C. And can one use OpenGL even without "graphical" tiles (but just "ASCII"-like characters)? And do those rendering tricks require additional programming? If so, where could I find out more about doing them?

Also, how and where could I find out more about how to use this "event based architecture", esp. in the context of a Rogue-like game?

mike3
08-21-2009, 07:46 PM
Does this mean that I should use C++ instead of C for programming a Rogue-like game? Because I've got some code for one I was trying to make and it's all in C. And can one use OpenGL even without "graphical" tiles (but just "ASCII"-like characters)? And do those rendering tricks require additional programming? If so, where could I find out more about doing them?

Also, how and where could I find out more about how to use this "event based architecture", esp. in the context of a Rogue-like game?

Any answer? *bump*

Sentinel
08-22-2009, 07:34 AM
For OpenGL and text output look here

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13

mike3
08-22-2009, 08:29 PM
For OpenGL and text output look here

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13

What about the backbuffered drawing/"shifting" display?

And as I mentioned, should I wholly toss out that code that I had because it's not C++?

Also, what about something on how to make this "event-driven" architecture, in the context of a Rogue-like game?

Sentinel
08-23-2009, 10:19 AM
Look, if you want to use something like OpenGL for rendering characters then prepare for :
* rewriting your game from scratch because of this windows event driven architecture thing
* problems with detecting the right key from keyboard buffer
* problems with drawing font texture on some older gfx cards
* problems with portability to other systems like linux, mac etc (if you wanted to do so)

You can choose the path of insanity, or use one of the solutions like :
* TINYCURSES : http://code.google.com/p/tinycurses/
* LIBTCOD library : http://doryen.eptalys.net/libtcod/
* SDL : http://www.libsdl.org/

But if i were you, then i would choose simple PDCurses or something like that.
(PDCurses is in windows only a wrapper to some windows console functions).

PS : I use C and something borrowed from C++. Programming in CodeLite IDE.

mike3
08-27-2009, 08:00 AM
Look, if you want to use something like OpenGL for rendering characters then prepare for :
* rewriting your game from scratch because of this windows event driven architecture thing
* problems with detecting the right key from keyboard buffer
* problems with drawing font texture on some older gfx cards
* problems with portability to other systems like linux, mac etc (if you wanted to do so)

You can choose the path of insanity, or use one of the solutions like :
* TINYCURSES : http://code.google.com/p/tinycurses/
* LIBTCOD library : http://doryen.eptalys.net/libtcod/
* SDL : http://www.libsdl.org/

But if i were you, then i would choose simple PDCurses or something like that.
(PDCurses is in windows only a wrapper to some windows console functions).

PS : I use C and something borrowed from C++. Programming in CodeLite IDE.

I suppose. However "Ter13" seemed to suggest OpenGL had some advantage.