3 Questions for my Adventure/Mystery game; Saving/Loading data, Text Color and Sound

I have Windows 7 and use Dev-C++ 4.9.9.2

I'm making an adventure/mystery batch console game, i recently finished Chapter 1 and i started adding ASCII pictures to add more "life" to the game.

First, i tought "Well, i just made a way to load chapters, but it would be better if i could save the completed chapters bool values into a data file and be able to continue the game from where i left it!".
Now, HOW??? I read some ways to do this, and it mostly were thinks that used 4 or 5 different voids or classes and strange libraries. Well, I did'nt understand ANYTHING.

---------------------------------------------------------------------------------------------------

Then i started adding ASCII pictures (as i told before) and tought it would be much better with colors. I searched a little bit about this and i found conio.h commands, wich did'nt worked (probably because of Dev-C++) and i did'nt find the download of the conio library. I found system("color") command, but aside of the horribleness of system() it changes the whole text and background color of the batch... I want something that can be used with a single or multiple cout commands.

---------------------------------------------------------------------------------------------------

Then i wanted sound... Yeah, i'm very good with ideas but very bad at c++.
Again i found some commands, but the windows.h ones gave me error messages.

Oh, and finally, is there any any way to clear the console without using system("cls")?



If you want you can download the files and .exe of the current state of my game here:
https://dl.dropbox.com/u/43721327/TCF.rar
Last edited on
for question 1: to start it sounds like u could just create a .txt file using an ofstream (or the FILE class) to print a number that indicates where u r want to resume the game next time u start.
then at the beginning of the game, use ifstream to read the file and use that number to tell the game where to begin. u could use switch statements for each entry point...

for ur 2nd question look up the function: setconsoletextattribute

q3: for sound i'm not sure..
Huh, please tell me what libraries i need and what commands to use. I need to start the app, read the value of 5 bool variables, replace the default values with the ones of the txt, start the chapter selection (wich appears only if there's at least 1 chapter completed) and before the batch closes it saves the values to the txt. Maybe a "delete data" option too.

I know about setconsoletextattribute, but i tried it and it has around 15 colors and i need more. Also i tried it again later and it stoped working... Again, what libraries?
Last edited on
I know about setconsoletextattribute, but i tried it and it has around 15 colors and i need more


Live with the limitations of the console.... or leave the console behind and use an actual window.

Obligatory link (you might find it useful):
http://www.cplusplus.com/forum/articles/28558/
Last edited on
Ok, ok, so you tell me that the console is bad, windows are easier than i think and i should start making window games. But you did'nt tell me how to use images, sound and/or movement with all that window stuff, wich you say is easy.

I searched for tutorials and i only found linux ones.
Last edited on
That page linked to the SFML page: http://www.sfml-dev.org which has several tutorials.

But it's a library you have to download and install.
Last edited on
I don't understand ANYTHING. Really, sorry, but this is extremely hard for me. Wich one do i need to download? How do I install it? How do i include it? Does it work for other compilators apart from visual c++? How do i use it with Dev-c++? Does everyone wich use the programs i make with sfml need it? Can't i just make windows applications without this? How? Is there any simple way for this?
Woaaa back up a bit. it sounds like u want to do too many things than u r currently able to do. IMO u should just pick 1 thing that u want to be able to do and read everything u can on how to do that one thing.

Probably the easiest of them to do is storing and reading data to a file since u can learn this based on what u already know about console programming. I'd recommend learning how to do that 1st. For outputting it's the same idea as 'cout' except instead of printing it to the console screen, u want to print it to a file. #include <fstream> and create an ofstream object. There's lots of examples online.

It's true, Windows programming isn't that hard BUT there is a learning curve to get it started. Just be patient.

And yes, there shouldnt be much diff between Dev-c++ and VS c++. Install the libraries wherever u want (usually in the IDE) and add that folder to ur includes then within ur code write #include "thelibraryuwanttouse.h" .
Last edited on
I searched tutorials for storing variable values and did'nt find good information about it, can you explain that part to me?

And the problem with conio.h is that it's incomplete in Dev-C++ and i can't find a download of the full library, i don't know why D:
Last edited on
Wich one do i need to download?


I recommend getting SFML 2.0, as it's significantly better than 1.6. You have to download the source and compile it yourself.

Download link is here: https://github.com/LaurentGomila/SFML/tarball/master

It's in .tar.gz format, so you will need an archiving program to extract it. I use 7-Zip, which is free: http://www.7-zip.org/ (installer download links are at the very top of the page, can't miss them)

Once you extract the source, you can compile it. There's a step-by-step tutorial here:
http://sfml-dev.org/tutorials/2.0/compile-with-cmake.php

I think Dev-C++ uses MinGW, so follow the steps that the page tells you to do for MinGW environment (ie, make a MinGW makefile, etc).

I also recommend making a "static library" build, rather than dynamic. So tweak that option in CMake as well.


How do i include it?


Once it's installed:
#include <sfml/graphics.hpp>

Does it work for other compilators apart from visual c++?


It works with any reasonably modern compiler.

Note that Dev-C++ uses an extremely old and outdated compiler so I don't know if it will work with that. I might --- it's worth a try. But you might have to upgrade.


Does everyone wich use the programs i make with sfml need it?


If you build sfml so that it links statically (like I recommended above), then no. SFML will be built right into your program and anyone will be able to run it without installing anything extra.

Can't i just make windows applications without this?


Yes, but it's much more difficult.

How?


Google WinAPI tutorials.

Note that using WinAPI for graphics is slow because it's all done in software, and it just generally sucks. Graphic libs are much easier to use (although, granted, getting SFML set up for the first time is a pain... but once you do it, you'll be glad you did).


Is there any simple way for this?


If getting SFML set up is too hard, you can try SDL instead. SDL is much easier to install and use (you can just download the dll files -- you don't have to worry about building anything). Though I'm not really a fan of SDL because it uses outdated concepts and supports less features out of the box (doesn't even allow for sprite flipping!).

SDL is available here:

http://www.libsdl.org/




EDIT:

I might be willing to build sfml for you. Or try to anyway. Give me a link to whatever version of Dev-C++ you're using and I'll see if I can get it working there.
Last edited on
Well, that was useful! Thanks. I'll consider everything you told to me.

I use Dev-c++ 4.9.9.2, as everyone wich uses Dev-C++ i think.
A direct download link would be nice.
hrm that's the version that doesn't come bundled with gcc.

What version of gcc do you have installed?
hey i have a question for you too. do you happen to know if i can use SFML and QT together?
I've never done it myself, but I'm pretty sure you can, yes. I believe there's a class called QSfmlCanvas or something which creates an SFML-drawable window within Qt.

I'm sure there are some google-able examples.
okay thanks!
Topic archived. No new replies allowed.