Sign in with
Sign up | Sign in
Your question

Xenocide-style console programming.

Last response: in Video Games
Share
Anonymous
May 10, 2005 11:14:21 AM

Archived from groups: rec.games.roguelike.development (More info?)

Hey all.

I was wondering if anyone could tell me how Xenocide draws its console. SDL
maybe? I don't know, but it's smooth, and I was looking for a way to make
larger consoles like these.

Links to source would be appreciated, I can't find it.

Thanks a lot.

--Nolithius
Anonymous
May 10, 2005 3:42:50 PM

Archived from groups: rec.games.roguelike.development (More info?)

Hi,

> I was wondering if anyone could tell me how Xenocide draws its console. SDL
> maybe? I don't know, but it's smooth, and I was looking for a way to make
> larger consoles like these.

Xenocide uses Curses library (PDCurses on Dos/Win). The game is closed
source, but I can tell you how it is done.

The game uses wrappers to standard Curses functions, so Curses can be
replaced by any other library.

Example:

// prints string at position x,y on the console.

void print_text(int x,int y,string toprint)
{
if (x>=0 && y>=0)
{
// text passed to mvprintw can be formatted, so we have to change %->%%
string t2;
for (int a=0;a<toprint.size();a++)
{
if (tekst[a]=='%')
t2+="%%";
else
t2+=tekst[a];
}
mvprintw(y,x,(char *) t2.c_str());
print_text_to_buffer(x,y,(char *)tekst.c_str());
}
}

print_text_to_buffer at the end of function prints the same to "screen
copy" structure.

struct Screen_copy {
char copy[SCREEN_SIZE_X][SCREEN_SIZE_Y];
char color[SCREEN_SIZE_X][SCREEN_SIZE_Y];
};

It is used for taking chars and colors from the current screen, and
storing/restoring screen copies. For example in "target selection mode"
screen is stored, and the copy is used to redraw "background" under the
line-of-fire.

Do you like the game? :) 
Maybe if more people play it I have more motivation to write it...

regards,
Jakub
--
"We're just toys in the hands of Xom"
xenocide.e-plan.pl - SF roguelike in development
www.graveyard.uni.cc - visit Roguelike Graveyard
www.alamak0ta.republika.pl - my other projects
Anonymous
May 10, 2005 3:44:49 PM

Archived from groups: rec.games.roguelike.development (More info?)

Dnia Tue, 10 May 2005 11:42:50 +0200, Jakub Debski napisa³(a):
> void print_text(int x,int y,string toprint)

Sorry, I didn't translate everything.
The function should be as below.

void print_text(int x,int y,string toprint)
{
if (x>=0 && y>=0)
{
// text passed to mvprintw can be formatted, so we have to change %->%%
string t2;
for (int a=0;a<toprint.size();a++)
{
if (toprint[a]=='%')
t2+="%%";
else
t2+=toprint[a];
}
mvprintw(y,x,(char *) t2.c_str());
print_text_to_buffer(x,y,(char *)toprint.c_str());
}
}

regards,
Jakub
--
"We're just toys in the hands of Xom"
xenocide.e-plan.pl - SF roguelike in development
www.graveyard.uni.cc - visit Roguelike Graveyard
www.alamak0ta.republika.pl - my other projects
Related resources
Anonymous
May 11, 2005 5:24:23 AM

Archived from groups: rec.games.roguelike.development (More info?)

[...]
> Xenocide uses Curses library (PDCurses on Dos/Win). The game is closed
> source, but I can tell you how it is done.
[...]

I am having a real hard time getting PDCurses to work. I installed it and
set the include and lib directories in MSVC, yet when I #include <curses.h>
I get a horrible amount of linker errors which are in native files, like
xstring, etc.-- this is usually a sign of another problem making the
compiler go crazy.

Any ideas? Do I need to set any special settings on the project? I've tried
setting in the Command Line for the linker "curses.lib" (this fixed a
similar compiler-go-crazy problem with me for SDL), but no luck.

Please help, I've RTFM'd to no avail, and Google turns up nothing about how
to properly set up PDCurses with MSVC.

[...]
> Do you like the game? :) 
> Maybe if more people play it I have more motivation to write it...
[...]

I actually do like it a lot. It plays smoothly and the UI is great (this
style menus are what all RLs need).

Please help me with my problem if you can, else I'll have to go back to the
old Windows native commands which I so often hear criticized. I also have
heard of using SDL, but both of these options are last resorts, I really
want to get PDCurses to work!

Thank you.

--Nolithius
Anonymous
May 11, 2005 1:59:48 PM

Archived from groups: rec.games.roguelike.development (More info?)

Dnia Wed, 11 May 2005 01:24:23 GMT, Nolithius napisa³(a):
> I am having a real hard time getting PDCurses to work. I installed it and
> set the include and lib directories in MSVC, yet when I #include <curses.h>
> I get a horrible amount of linker errors which are in native files, like
> xstring, etc.-- this is usually a sign of another problem making the
> compiler go crazy.

I use it in different way:
From sourceforge download pdc25_vc_w32.zip for MSVC (6.0)

place pdcurses.lib into %MSVC%\Vc98\Lib\
and curses.h into %MSVC%\Vc98\include\

next choose your Project Settings and on Link tab add pdcurses.lib
(PDcurses.lib, not curses.lib) in Object/Library modules.
If your project is Win32 Console Application then everything should work.

regards,
Jakub
--
"We're just toys in the hands of Xom"
xenocide.e-plan.pl - SF roguelike in development
www.graveyard.uni.cc - visit Roguelike Graveyard
www.alamak0ta.republika.pl - my other projects
Anonymous
May 11, 2005 1:59:49 PM

Archived from groups: rec.games.roguelike.development (More info?)

[...]
> I use it in different way:
> From sourceforge download pdc25_vc_w32.zip for MSVC (6.0)
>
> place pdcurses.lib into %MSVC%\Vc98\Lib\
> and curses.h into %MSVC%\Vc98\include\
>
> next choose your Project Settings and on Link tab add pdcurses.lib
> (PDcurses.lib, not curses.lib) in Object/Library modules.
> If your project is Win32 Console Application then everything should work.
[...]

I did all of this and it still doesn't work, I get over 100 errors at
compile time, which go away when I remove the #include <curses.h> line.

Really bizarre, can anyone help me?
Anonymous
May 11, 2005 3:05:37 PM

Archived from groups: rec.games.roguelike.development (More info?)

Dnia Wed, 11 May 2005 08:59:50 GMT, Nolithius napisa³(a):
> I did all of this and it still doesn't work, I get over 100 errors at
> compile time, which go away when I remove the #include <curses.h> line.
>
> Really bizarre, can anyone help me?

put first errors here.
Maybe you include <windows.h> before or any other libraries
that PDCurses tries to redefine?

regards,
Jakub
--
"We're just toys in the hands of Xom"
xenocide.e-plan.pl - SF roguelike in development
www.graveyard.uni.cc - visit Roguelike Graveyard
www.alamak0ta.republika.pl - my other projects
Anonymous
May 11, 2005 10:16:47 PM

Archived from groups: rec.games.roguelike.development (More info?)

[...]
> put first errors here.
> Maybe you include <windows.h> before or any other libraries
> that PDCurses tries to redefine?
[...]

I tried including <windows.h>, <stdio.h>, <stdlib.h>, and tried without
including them, nothing. Still the same errors. I know it's not in my code
(which consists of a blank main that returns 0) because if I take out the
<curses.h> include it works normally.


Here are the first few errors:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(807):
error C2040: 'std::basic_string<_Elem,_Traits,_Ax>::wmove' : 'int (void)'
differs in levels of indirection from 'int &(void)'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::_DebugHeapAllocator<char>
]
*snip 1 more of the same error*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(807):
error C2040: 'std::basic_string<_Elem,_Traits,_Ax>::wmove' : 'int (void)'
differs in levels of indirection from 'int &(void)'
with
[
_Elem=wchar_t,
_Traits=std::char_traits<wchar_t>,
_Ax=std::allocator<wchar_t>
]

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(790):
error C2059: syntax error : '('
*snip 11 more of the same error*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(790):
error C2059: syntax error : ')'
*snip 13 more of the same error*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(790):
error C2059: syntax error : ','
*snip 10 more of the same error*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(790):
error C2059: syntax error : 'constant'
*snip 11 more of the same error*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iosfwd(183):
error C2061: syntax error : identifier 'stdscr'
*2 more*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(821):
error C2143: syntax error : missing ')' before '->'
*about 12 more*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(821):
error C2143: syntax error : missing ';' before '->'
*x3*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(821):
error C2182: 'stdscr' : illegal use of type 'void'
*x3*

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(792):
error C2334: unexpected token(s) preceding '{'; skipping apparent function
body
*x about 12*

Thanks a lot for your help.

--Nolithius
Anonymous
May 13, 2005 2:01:21 PM

Archived from groups: rec.games.roguelike.development (More info?)

Dnia Wed, 11 May 2005 18:16:47 GMT, Nolithius napisa³(a):
> Here are the first few errors:
>
> c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(807):
> error C2040: 'std::basic_string<_Elem,_Traits,_Ax>::wmove' : 'int (void)'
> differs in levels of indirection from 'int &(void)'

I thought that the problem may lay in Visual Studio .NET, but it PDCurses
works fine with it.
Check your email box. I've sent you simple project with curses library.

Happy programming :) 

regards,
Jakub
--
"We're just toys in the hands of Xom"
xenocide.e-plan.pl - SF roguelike in development
www.graveyard.uni.cc - visit Roguelike Graveyard
www.alamak0ta.republika.pl - my other projects
!