Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RL games in C#

183 views
Skip to first unread message

Thund

unread,
Mar 10, 2009, 10:12:08 PM3/10/09
to
Hello group,

Please can anyone tell me some guidelines how to make roguelike game (like
ADOM) in C# ? Is there any guide, reference, tutorial, resource on internet?
It would be really helpfull to me, thanks alot.

Goran, Croatia

thep...@gmail.com

unread,
Mar 11, 2009, 1:25:04 AM3/11/09
to
Your probably going to need to be more specific about what help you
want, although alot of the stuff on roguebasin is quite good
http://roguebasin.roguelikedevelopment.org/

My c# roguelike which is pretty simple is up at
http://code.google.com/p/realtimerl/

John Palmer

vchris80

unread,
Mar 11, 2009, 5:13:26 AM3/11/09
to

Coding a RL in C# is not really different than any other language, you
have to deal with almost the same problems: line of sight, FOV, my
turn your turn, random generations etc.

The real difference is in the fact that you have an entire, rich
framework ready to use, but maybe the question becomes: how to program
with the .NET framework? ;)

Greetings
Chris

Ido Yehieli

unread,
Mar 11, 2009, 7:05:51 AM3/11/09
to
On Mar 11, 3:12 am, "Thund" <thun...@xnet.hr> wrote:
> Please can anyone tell me some guidelines how to make roguelike game (like
> ADOM) in C# ?

I wonder where these really specific questions come from. You don't
see people going around asking "can someone point me to a pacman in
COBOL tutorial?" or "can someone tell me how to program tetris in
javascript?".

The only thing you have to know is that you can use the Console class
(http://msdn.microsoft.com/en-us/library/system.console.aspx) instead
of curses, otherwise there is nothing c# or .net specific you need to
know.

-Ido.

Thund

unread,
Mar 11, 2009, 9:18:04 AM3/11/09
to
Thanks John, thats exactly what I needed, some good example in source code
where can I find guidelines how to start :)


<thep...@gmail.com> wrote in message
news:236ab730-7f07-457c...@l33g2000pri.googlegroups.com...

Thund

unread,
Mar 11, 2009, 9:23:38 AM3/11/09
to
Well i was being so specific cause I am new to the language, and
if I need the practice I would like it to be a roguelike game for a first
project. Thats exactly on what I thought, how to move cursors throughout
the game, is there any hint how to write maps in text (like putting them in
arrays or something) and how to make cursor or some character on that
map to move. (for example, if # are the walls and @ is your character)
But thanks on the link, I will study it. If anyone have some good advice,
please let me now.
Greetings, Goran

"Ido Yehieli" <Ido.Y...@gmail.com> wrote in message
news:9b78962f-dc1f-46d0...@j8g2000yql.googlegroups.com...

Ed

unread,
Mar 11, 2009, 9:35:33 AM3/11/09
to
On Mar 11, 9:23 am, "Thund" <thun...@xnet.hr> wrote:
> Well i was being so specific cause I am new to the language, and
> if I need the practice I would like it to be a roguelike game for a first
> project. Thats exactly on what I thought, how to move cursors throughout
> the game, is there any hint how to write maps in text (like putting them in
> arrays or something) and how to make cursor or some character on that
> map to move. (for example, if # are the walls and @ is your character)
> But thanks on the link, I will study it. If anyone have some good advice,
> please let me now.
> Greetings, Goran

If you're new to the language, roguelikes might not be the best place
to start, unless you're an uber genius or have significant prior
programming experience in other languages... they are often
deceptively complex!
Not to belittle your skill, but perhaps something like Yahtzee or
Battleship might be a better choice for learning the language? Then
perhaps chess (2-player that is, not vs. an AI - chess AI's are
notoriously difficult even for IBM!), and then a roguelike?

Darren Grey

unread,
Mar 11, 2009, 2:46:32 PM3/11/09
to

Why not roguelike Yahtzee? :P There's really nothing wrong with
learning programming throuh making a roguelike, as long as you keep
your designs simple to start with. Try to make something the scale of
Nethack to start off with and you're sure to fail.

--
Darren Grey

jimmy...@gmail.com

unread,
Mar 11, 2009, 4:49:06 PM3/11/09
to
On Mar 11, 3:12 am, "Thund" <thun...@xnet.hr> wrote:

I downloaded NCursesSharp http://home.nedlinux.nl/~florian/downloads/NCursesSharp.tar.gz
it is a c# wrapper for pdcurses. Not all functions, constants for
keycodes & colors are supported but it will give you a good start.

Are you familiar with Object oriented programming?

Thund

unread,
Mar 11, 2009, 8:21:55 PM3/11/09
to
Thanks on the link, but im trying to add NCWrapper.dll to reference to
c# project but it gives me error: "a referemce to C:\....\NCWrapper.dll
could not be added. Please make sure that the file is accessible, and that
it is a valid assembly or COM component"

As to your question, Im familiar with OOP as a concept and in theory
from reading some of c# books, but never in theory. I made simple
applications
like money exchanger, tic tac toe, random dice generator but never made
with classes *blush*


<jimmy...@gmail.com> wrote in message
news:d6797d77-afc5-4571...@e38g2000yqa.googlegroups.com...

Thund

unread,
Mar 11, 2009, 9:20:09 PM3/11/09
to
Thanks on advice, ill try that :) My games experiences just relly for now
on tic tac toe in WinApp *blush*

"Ed" <edk...@gmail.com> wrote in message
news:287e1c0a-2431-4ec2...@r27g2000vbp.googlegroups.com...

Ido Yehieli

unread,
Mar 12, 2009, 4:47:29 AM3/12/09
to
On Mar 12, 2:20 am, "Thund" <thun...@xnet.hr> wrote:
> Thanks on advice, ill try that :)  My games experiences just relly for now
> on tic tac toe in WinApp *blush*
>


Please bottom post, top posting makes your messages hard to read.

Usenet etiquette is different than email.

-Ido.

Brigand

unread,
Mar 12, 2009, 10:18:06 AM3/12/09
to
> "Ed" <edko...@gmail.com> wrote in message

Actually, I think programming a roguelike is a pretty good way to
learn a programming language, for several reasons:

1) You aren't at the point where you need to learn how to code
specific, low level instructions, or how to optimize graphics routines
(for example, why burden yourself with learning DirectX in addition to
your base language). Indeed, nothing could be more simply than select
X, select Y, and print a "@".

2) A roguelike game will teach you some basic concepts, like logic,
arrays, keyboard handling, file handling, etc., that are useful in any
program you will attempt.

2) All your coding is very high level, allowing your code to read
almost like spoken logic: If X > 3 then Y = Y + 1. Any completely
computer illiterate person could figure something like that out. And
really, at the heart of it, Rogues don't really use any complicated
programming structures or techniques...

EXCEPT for (the one place I heartily agree with you) certain
'advanced' topics, like line of sight or pathfinding. But let's face
it - every single one of us out there, regardless of what language we
were programming in, had to sit down and read and understand the logic
of A* or Djikstra algorithms before we attempted to code something
like that. But really, you don't HAVE to have pathfinding in a rogue;
you probably need line-of-sight, but high school trig should pretty
much let you puzzle out how to do a basic raycasting algorithm.

@ the Original Poster: Give it a shot and post what you create here.
The people on this forum are for the most part very nice and helpful,
and will be more than happy to help you with your project. We all love
rogue-like games, and having more players and developers is in every
possible way a good thing! I will actually download and play (at least
once) EVERY rogue that gets posted here. You WILL learn a lot, and
there are some talented people here that know there stuff. Above all,
don't get discouraged - and keep your first attempt modest - if you
bite off more than you can chew, it will be painful admitting you
can't finish that project you've spent so much time on.

B-

David Damerell

unread,
Mar 12, 2009, 11:49:05 AM3/12/09
to
Quoting Brigand <marka...@hotmail.com>:
>like that. But really, you don't HAVE to have pathfinding in a rogue;
>you probably need line-of-sight, but high school trig should pretty
>much let you puzzle out how to do a basic raycasting algorithm.

MPRDB1 had no fancy line of sight and was quite playable. It's
rogue-style; 8 spaces around you in a corridor, all of a room if in a
room.
--
David Damerell <dame...@chiark.greenend.org.uk> flcl?
Today is Saturday, March - a weekend.

Thund

unread,
Mar 12, 2009, 12:02:48 PM3/12/09
to

"Thund" <thu...@xnet.hr> wrote in message
news:gpbauh$ji9$1...@gregory.bnet.hr...
>
> "Brigand" <marka...@hotmail.com> wrote in message
> news:d4d6d080-06e7-4df8...@c36g2000yqn.googlegroups.com...


Thanks B, I really appretiate that!!
Well actually I just made my first code, actually "room" where the cursor
moves through the room. Im not sure it would be appropriate to paste the
whole code here, so i added project in .rar or .cs who doesnt have time to
open it all.
Well i managed to make a room and move character with cursor, but the real
> problem comes with cursor, apparently when i reach the east wall and if i
> am
> starting to click to the right, character '@' stops on the place but
> cursor moves
> to the right and deletes my precious wall. What should i do?
> Is that because i used .NET Console, or that depends from portability and
> OS from
> computer to computer? Anyway, this is my for starters code, and any
> recommendation
> and advice will do!
> Thanks alot guys,
> Goran
>
>
>
p.s. this is my attach-less post, for any case my post with attachements
didnt make through
just source code: http://rapidshare.com/files/208386482/Program.cs.html
the whole project:
http://rapidshare.com/files/208386795/RoguelikeGameFromNews.rar.html

(its option for rapidshare to delete this after 10 times download, so if
anyone wants to see it again
can email me or post for more download)


jimmy...@gmail.com

unread,
Mar 12, 2009, 4:13:20 PM3/12/09
to
On Mar 12, 1:21 am, "Thund" <thun...@xnet.hr> wrote:
> Thanks on the link, but im trying to add NCWrapper.dll to reference to
> c# project but it gives me error: "a referemce to C:\....\NCWrapper.dll
> could not be added. Please make sure that the file is accessible, and that
> it is a valid assembly or COM component"
>
> As to your question, Im familiar with OOP as a concept and in theory
> from reading some of c# books, but never in theory. I made simple
> applications
> like money exchanger, tic tac toe, random dice generator but never made
> with classes *blush*
>

Hi again,

You should not try to add NCWrapper.dll, this file is a dll of ncurses/
pdcurses based on c code - hence your error.
The file you should add is NCurses.dll - which is a dll based on C#
functions that calls the functions in NCWrapper.dll.

...

I have made some modifications to the NCursesSharp project, you can
download it here: http://rapidshare.com/files/208474825/NCursesSharpMod.zip.html
(note the file can only be downloaded 10 times), the difference
between is that my project has more functions and keep the names of
the original functions. Here is a guide: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html

Ido Yehieli

unread,
Mar 12, 2009, 5:31:39 PM3/12/09
to
On Mar 12, 9:13 pm, jimmy.ab...@gmail.com wrote:
> You should not try to add NCWrapper.dll, this file is a dll of ncurses/
> pdcurses based on c code - hence your error.


Why use it at all when you can use the built-in System.Console class?

-Ido.

thep...@gmail.com

unread,
Mar 12, 2009, 6:07:52 PM3/12/09
to
> p.s. this is my attach-less post, for any case my post with attachements
> didnt make through
> just source code: http://rapidshare.com/files/208386482/Program.cs.html
> the whole project:
> http://rapidshare.com/files/208386795/RoguelikeGameFromNews.rar.html
>
> (its option for rapidshare to delete this after 10 times download, so if
> anyone wants to see it again
> can email me or post for more download)
>
>

Hi, had a look at the code - some comments

I think you missed some closing brackets somewhere as you have your
Actor class completely inside your Program class which seems a bit
pointless. I think you need a } around line 70.

Also, the room is not redrawn inside your main loop which can cause
the edges to disappear

For the drawing I think your better with something like:

for each actor
{
Console.setposition(actor.x,actor.y)
Cosole.DrawString("@")
}

This means all your drawing code is in one location

Also, your functions for left right up and down are basically all the
same - it would be simpler to have one function which needs a
direction input as well

The reason you hace disappearing walls in the console cursor is
getting moved to a wall spot and deleting the cursor. Putting your
map drawing code inside your main loop should fix this - probably -
but I don't use a console for displaying. The actual .net console
should be reasonably portable using Mono.

John Palmer

Thund

unread,
Mar 13, 2009, 4:59:44 AM3/13/09
to

<thep...@gmail.com> wrote in message
news:a40fb455-7335-4dd2...@n33g2000pri.googlegroups.com...

>> p.s. this is my attach-less post, for any case my post with attachements
>> didnt make through
>> just source code: http://rapidshare.com/files/208386482/Program.cs.html
>> the whole project:
>> http://rapidshare.com/files/208386795/RoguelikeGameFromNews.rar.html
>>
>> (its option for rapidshare to delete this after 10 times download, so if
>> anyone wants to see it again
>> can email me or post for more download)
>>
>>
>
> Hi, had a look at the code - some comments
>
> I think you missed some closing brackets somewhere as you have your
> Actor class completely inside your Program class which seems a bit
> pointless. I think you need a } around line 70.
Thanks, I solved the mistake.


> Also, the room is not redrawn inside your main loop which can cause
> the edges to disappear
>
> For the drawing I think your better with something like:
>
> for each actor
> {
> Console.setposition(actor.x,actor.y)
> Cosole.DrawString("@")
> }
> This means all your drawing code is in one location

Thank you, that was really usefull. I put this code in while loop,
draw a room then added this code:
Console.SetCursorPosition(player.x, player y);
Console.Write("@");
I also modified all methods erasing code wich is no longer needed

> Also, your functions for left right up and down are basically all the
> same - it would be simpler to have one function which needs a
> direction input as well

Well I must admit that as a newbie im still feeling unconfortable using
methods and classes, and I just didnt maked the solution how to achieve
that with only one method since every method has different if expression
and different arguments for SetCursorPositiion. Can you please show me
how did you mean that.

> The reason you hace disappearing walls in the console cursor is
> getting moved to a wall spot and deleting the cursor. Putting your
> map drawing code inside your main loop should fix this - probably -
> but I don't use a console for displaying. The actual .net console
> should be reasonably portable using Mono.
>
> John Palmer

Putting the code in the main loop solve all my problems, thanks.
Can you explain me please little more about actual .net console,
as I am still new to all this. Do you mean some cross between
Windows application and Console application or what exactly?
But thanks alot John, I have now good beggining example how to
make a game start.

But still I have a lot of others problems on my mind what to do next:
1. How to change font collors and/or background collors?
2. How to interact with obstacles (in the form of other character types)
like different objects, items and sooner or later NPCs ?
3. How to make multiple rooms, should I implement it in the class, or like
independent static method for each incoming room or some other alternative
way?

But in spite of that, youve been all very helpfull, thanks!
Please guide me at least on some of my questions if not all.

Greetings, Goran =)


Thund

unread,
Mar 13, 2009, 5:27:30 AM3/13/09
to
Hi again,

You should not try to add NCWrapper.dll, this file is a dll of ncurses/
pdcurses based on c code - hence your error.
The file you should add is NCurses.dll - which is a dll based on C#
functions that calls the functions in NCWrapper.dll.

...

I have made some modifications to the NCursesSharp project, you can
download it here:
http://rapidshare.com/files/208474825/NCursesSharpMod.zip.html
(note the file can only be downloaded 10 times), the difference
between is that my project has more functions and keep the names of
the original functions. Here is a guide:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html

-------

Thank you on modified NCursesSharp project and for the guide, I will
take time in recent days to read it. PDCurses.dll have a lot of methods and
options which will help me to make my succesfull roguelike game, but please
take notice that Im a still begginer, and Im in this language for only three
months
so some advanced topics like interfaces, polymorphism, inheritance, generics
and simmilar are still mystery to me, but I firmly believe the best way to
learn is
through practice. That means im still not familiar with all the fields in
your dll.
and .cs files (especially not in .c file) but as I cruise through your
tutorial I hope
that subject will starting to be more familiar for me too :)

greetings, Goran


thep...@gmail.com

unread,
Mar 13, 2009, 5:36:01 AM3/13/09
to

> Well I must admit that as a newbie im still feeling unconfortable using
> methods and classes, and I just didnt maked the solution how to achieve
> that with only one method since every method has different if expression
> and different arguments for SetCursorPositiion. Can you please show me
> how did you mean that.
Something like
moveplayer(Actor player,point changeinposition)
{
player.position.x += changeinposition.x;
player.position.x = Math.min(player.position.x,0);
player.position.x = Math.max(player.position.x,map.size(0));

//repeat same for y
}
It is better to have some other method which actually checks whether
it is actually possible to move the player - you can use this to see
whether movement is blocked by walls


>
> But still I have a lot of others problems on my mind what to do next:
> 1. How to change font collors and/or background collors?

You can use Console.Foregroundcolor/backgroundcolor to change console
colors - but according to http://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
you are limited to one color at a time. I use forms to avoid this
problem but people who use the Console in c# may have a better answer


> 2. How to interact with obstacles (in the form of other character types)
> like different objects, items and sooner or later NPCs ?

You'll just need to find what works - although your going to need at
least a 2D array for the map and an array or list for the NPC's.
Probably best to have a look at some code. My current Rl is
reasonably simple - only 1250 lines its at http://realtimerl.googlecode.com/svn/trunk/
- easiest to use SVN to grab it or I could upload a tar


> 3. How to make multiple rooms, should I implement it in the class, or like
> independent static method for each incoming room or some other alternative
> way?

I have a static class which generates maps

> But in spite of that, youve been all very helpfull, thanks!
> Please guide me at least on some of my questions if not all.
>
> Greetings, Goran =)

Thanks

Gerry Quinn

unread,
Mar 13, 2009, 10:56:54 AM3/13/09
to
In article <gp9nvr$k2f$1...@gregory.bnet.hr>, thu...@xnet.hr says...

> If you're new to the language, roguelikes might not be the best place
> to start, unless you're an uber genius or have significant prior
> programming experience in other languages... they are often
> deceptively complex!
> Not to belittle your skill, but perhaps something like Yahtzee or
> Battleship might be a better choice for learning the language? Then
> perhaps chess (2-player that is, not vs. an AI - chess AI's are
> notoriously difficult even for IBM!), and then a roguelike?

Depends how good you want the AI to be. Minimax combined with a
mobility heuristic will give you something that recognisably tries to
play chess, after the fashion of 1980s PCs.

- Gerry Quinn
--
Lair of the Demon Ape (a coffee-break roguelike)
<http://indigo.ie/~gerryq/lair/lair.htm>

0 new messages