I know classes, file io, and all that junk, but I want to know what a
good graphics library would be (I'm on Windows), and some help on file
io with something other than txt or binary. I'm just not sure where I
should head from here. Any help would be appreciated.
Start making a roguelike, you goof.
No, you see that's what I mean. I can't see how I can make one with my
current skills. I think I need a graphics library, and some way to
make some save files or preferencce files. Once I figure that out, I
should be able to start making one :)
> No, you see that's what I mean. I can't see how I can make one with my
> current skills. I think I need a graphics library, and some way to
> make some save files or preferencce files. Once I figure that out, I
> should be able to start making one :)
Ignore Krice. Everyone else does.
You probably want to start with ascii graphics, even if you hope to do
tiles at some point. Just partition off that part of your code behind
a print_map() function that is the only thing that interacts with the
graphics system.
Ascii graphics libraries that are good to use starting out on Windows
include pdcurses (close to ncurses, but not very documented), libtcod
(allows lots of colors and some other effects, multiplatform,
relatively new and untested), and just using the windows console to
start out (not portable). If you want to try to do 2D graphics like
tiles and stuff, then SDL is probably your best bet.
As far as something like a preference file, it is probably easier to
start out having things hard-coded and then only switching to an info
file or preferences when you have more than a couple. For instance,
you could start out reading a file consisting of '.' and '#' and '@',
and just hard-code it to mean that '.' is an empty floor, '#' is a
wall, and '@' is the player's start location without worrying about
trying to come up with a more general solution until later.
In general, you would be well-served by following the guide:
http://roguebasin.roguelikedevelopment.org/index.php?title=How_to_Write_a_Roguelike_in_15_Steps
Complete steps 1-4, then start thinking about save files. In general,
the easiest way to handle save files is to have a separate save and
load function for each kind of thing that you want to save. It should
directly save off all of the immediate data like ints and then
delegate to other save/load functions for more complex stuff. If you
create the two to be mirrors of each other, then saving and loading
should happen pretty smoothly. Most people here will be happy to help
you if you run into troubles when you get to this point.
-D
> On May 5, 4:57 pm, Krice <pau...@mbnet.fi> wrote:
>> On 5 touko, 23:41, m.ninj...@gmail.com wrote:
>>
>> > My question is this: After doing
>> > a few C++ tutorials, and even a book, I can't seem to find a big use
>> > for my skills.
>>
>> Start making a roguelike, you goof.
>
> No, you see that's what I mean. I can't see how I can make one with my
> current skills. I think I need a graphics library,
you don't. Read the documentation of your curses library, then use it.
> and some way to
> make some save files or preferencce files. Once I figure that out, I
> should be able to start making one :)
You have to write the logic for saving your stuff and reading it back,
but it's pretty simple. The calls you need are fopen(), fclose(),
printf(), and scanf(). That'll get you started. There are some more
calls that are useful, but you won't need them until you're unsatisfied
with the way things work.
Bear
I'm in exactly the same boat as you are right now, so good luck to
both of us = ).
You're going about this the wrong way, then. You need to figure out
what it is you want to do before you can decide in any rational way
what steps you need to take to get there.
> I know classes, file io, and all that junk, but I want to know what a
> good graphics library would be (I'm on Windows), and some help on file
> io with something other than txt or binary. I'm just not sure where I
> should head from here. Any help would be appreciated.
There's no other IO method other than ASCII and binary. To start with,
you can use the basic GDI to render tiles, or you can use command line
mode to render ASCII. There are libraries, such as curses and SDL,
that can help with either approach you take.
The first you take on any journey needs to be the decision on where
you want to end up.
- Pfhoenix
http://adeo.pfhoenix.com
Thanks again.
You don't need skills to make a roguelike. If you don't
see how to do something, then you figure out how to do it.
Making a roguelike or any program has nothing to do with skills.
Some people seem to think that programming is reading books
about C++ and following some tutorials. No it's not. It's
"reading books and following tutorials". Nothing to do with
the idea of programming.
> I think I need a graphics library
SDL.
Are you looking to do traditional ASCII "graphics" or get your hands
directly on some of those pixels I keep hearing about? PDCurses, I
believe, is good for the former, and for the latter I think you will
like SDL (with SDL_image, probably) or Allegro.
As for file IO, there is nothing but text files and binary files. It's a
choice between choosing a human-readable format (text file) and devising
a syntax with which to represent your data, or doing the same with a
non-human-readable format (binary files). Since C++ has reading/writing
of structures built-in, you may want to start there when you need to do
file io. You won't need it to begin your game though, since Roguelikes
usually generate the world internally, and your graphics library should
take care of loading images.
I just want the normal ascii for now. As for the file io, I didn't
know about that. Thanks for the help. Any tips on installing PDCurses
with Borland? I keep just getting "Cannot find make.cpp" when I try to
compile it. Once again, I'm a big newb.
You might want to consider Following the Sheep:
http://roguebasin.roguelikedevelopment.org/index.php?title=How_to_Write_a_Roguelike_in_15_Steps
Cheers,
Nathan
> I just want the normal ascii for now. As for the file io, I didn't
> know about that. Thanks for the help. Any tips on installing PDCurses
> with Borland? I keep just getting "Cannot find make.cpp" when I try to
> compile it. Once again, I'm a big newb.
Sorry, I don't know anything about that setup.
with Bloodshed Dev C++ I did it this way:
1) dl precompiled pdcurses
2) throw the curses.h into the includes folder
4) add pdcurses.dll to your linker parameters
3) #inlcude curses.h
5) dance a jig
I would think that other IDE's would follow approximatley the same
steps without too much variation. Hope it helps.
Numeron
All right, I think I got it, thanks.
While that may work, another option is fread() and fwrite() rather
than fscanf and fprintf. I personally find scanf very confusing to
interface with, and good old binary writes with sizeof() a lot more
simple to understand.
--
Jeff Lait
(POWDER: http://www.zincland.com/powder)
First rule of stdio programming: scanf(), fscanf(), and gets() should be
nova bombed from the next star system. The first two are broken as
specified (they're *insanely* hard to use correctly) and the third
*will* get you a buffer overrun sooner or later.
Use fread()/fgets() to pull stuff from the stream in bounded amounts,
then sscanf() to parse it.
--
\_\/_/ some girls wander by mistake into the mess that scalpels make
\ / are you the teachers of my heart? we teach old hearts to break
\/ --- Leonard Cohen, "Teachers"
Well there is MFC, i.e. Microsoft's OO wrapper around Windows API. They
also have another one called WTL. Good choices if you want to make
native Windows applications. Some have said that my MFC game Lair looks
too much like office software, but of course all the controls can be
drawn in arbitrary fashions if you want. MFC itself only offers basic
blitting functions, but that's all you need really for 2D graphics.
That said, Windows API and thus MFC/WTL are basically designed for
producing Windows apps rather than games. For a mouse-driven game like
Lair, that's very convenient in terms of selection boxes etc., but for a
keyboard-based game it might be less helpful.
Text and binary are pretty much the basics offered by any C-like file io
system; essentially binary covers everything.
- Gerry Quinn
--
Lair of the Demon Ape (a coffee-break roguelike)
<http://indigo.ie/~gerryq/lair/lair.htm>
I thought you said you knew file io? In that case, what's the
difficulty in creating a preference file?
// Primitive Prefs class
class Prefs
{
public:
int m_DifficultyLevel;
bool m_FullScreen;
public:
Prefs()
{
InitDefaults();
}
void InitDefaults()
{
m_DifficultyLevel = 2; // normal
m_FullScreen = false; // windowed
}
void Save( const CString & filePath )
{
// write it as a binary file using standard file io
}
bool Load( const CString & filePath )
{
// read it, returning false if there were problems
}
};
Just save it out as a binary file called "prefs.sav" when you quit, and
load it again into a single instance of a Prefs object (could be global)
when you load the game. If it fails to load, InitDefaults() should be
called.
On a related note, maybe GDI would be a better choice for a starting
RL programmer in Windows. I assume that VS has standard wrapper
classes for the GDI in the same way Delphi does (i.e. TBitmap,
TCanvas, TPaintbox, TImage and so on). Portability might not be a
factor if WINE can emulate the GDI as I'm told it can.
Best,
P.
Visual Studio (VS) does not provide wrappers for the API - it is
strictly an Integrated Development Environment (IDE). That being said,
I wouldn't develop for Windows with anything else, simply due to the
nice integration of resource creation/management tools. Having to
create resource files by hand can be a real headache.
If you end up with C# or C++ and are on Windows, I highly recommend at
least trying Visual Studio 2008 Express Edition. You'd be surprised
how nice it is once you figure out where things are, and its
intellisense, code completion, and debugging abilities will only aid
you in learning the language faster.
I'm writing Adeo in C++, but it's crossed my mind a few times to look
into rewriting it in C# (especially if I decided to try and get Adeo
up and running in a web browser).
- Pfhoenix
http://adeo.pfhoenix.com
o_O
Guess I'm spoilt with Delphi *grins*
Best,
D.
> > Well there is MFC, i.e. Microsoft's OO wrapper around Windows API. They
> > also have another one called WTL. Good choices if you want to make
> > native Windows applications. Some have said that my MFC game Lair looks
> > too much like office software, but of course all the controls can be
> > drawn in arbitrary fashions if you want. MFC itself only offers basic
> > blitting functions, but that's all you need really for 2D graphics.
> >
> > That said, Windows API and thus MFC/WTL are basically designed for
> > producing Windows apps rather than games. For a mouse-driven game like
> > Lair, that's very convenient in terms of selection boxes etc., but for a
> > keyboard-based game it might be less helpful.
> Gerry, as far as C++ Programming on Windows goes, wouldn't Visual
> Studio be a good choice? (almost all my experience on C++ has been on
> Solaris/Unix so I don't know the current standard for C++ dev under
> Windows).
Yes, it's a good IDE.
> On a related note, maybe GDI would be a better choice for a starting
> RL programmer in Windows. I assume that VS has standard wrapper
> classes for the GDI in the same way Delphi does (i.e. TBitmap,
> TCanvas, TPaintbox, TImage and so on). Portability might not be a
> factor if WINE can emulate the GDI as I'm told it can.
Well, what you are looking for here is Visual C++ (when you buy it you
get Visual Studio as well).
Full versions come with MFC which does have wrappers for GDI. However,
you might instead want to download GDI+, which is a class-based API for
an enhanced version of GDI. Both of them have the equivalent of your
Delphi wrapper classes.
You'll still need to access the Windows API for device contexts etc.
> On a related note, maybe GDI would be a better choice for a starting
> RL programmer in Windows. I assume that VS has standard wrapper
> classes for the GDI in the same way Delphi does (i.e. TBitmap,
> TCanvas, TPaintbox, TImage and so on). Portability might not be a
> factor if WINE can emulate the GDI as I'm told it can.
I forgot to add, Wine can indeed emulate GDI and I should imagine
probably GDI+ as well. GDI is very standard Windows stuff, and if you
stick to that, emulators should be happy.
- Gerry Quinn
> > On a related note, maybe GDI would be a better choice for a starting
> > RL programmer in Windows. I assume that VS has standard wrapper
> > classes for the GDI in the same way Delphi does (i.e. TBitmap,
> > TCanvas, TPaintbox, TImage and so on). Portability might not be a
> > factor if WINE can emulate the GDI as I'm told it can.
>
> Well, what you are looking for here is Visual C++ (when you buy it you
> get Visual Studio as well).
*noddles* I have VS at work but only use it for occasional C#
development (where I work is overwhelmingly a Delphi establishment)
>
> Full versions come with MFC which does have wrappers for GDI. However,
> you might instead want to download GDI+, which is a class-based API for
> an enhanced version of GDI. Both of them have the equivalent of your
> Delphi wrapper classes.
>
> You'll still need to access the Windows API for device contexts etc.
Ah, the Delphi VCL also encapsulates DCs (http://delphi.about.com/
library/bluc/text/uc052102a.htm) and makes using the GDI a hell of a
lot less painful. I assume Lazarus also does so in a similar manner as
well.
Hmm, a quick gander on google reveals http://lummie.co.uk/gdi-controls-for-delphi/
- GDI+ controls for Delphi - I don't have performance issues at the
moment just using the GDI, but I'll keep the GDI+ in mind - if I don't
deside to go down the OpenGL route.
Best,
P..