Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Some questions

This thread is locked; no one can reply to it. rss feed Print
Some questions
psycho
Member #5,042
September 2004

OK, I have prepared some questions which all have something to do with the new release of Snake 256 (available under arcade\snakes under allegro.cc):

1. Do you know where to find some music and/or sound effects(screaming, ...) which fit to the game?
2. On (SuSE) Linux the game creates and reads the configuration file at/from /root.
If I start it in a console it does that in the working dir. Is there a way to make the game create it always in the directory of the game?
3. I compiled Allegro under SuSE Linux, will the game run on all other Linux systems, too?
4. Can I somehow replace Allegro's (hardware accelerated) circle function without having to recompile Allegro? If I have to, is that legal?
5. Is there a (very very) simple network library for Allegro which supports Linux and Windows and perhaps even both crossed (i.e. connect a Linux system with a Windows one)?

Thanks.

Simon Parzer
Member #3,330
March 2003
avatar

1) You can always try http://www.modarchive.com. I would use Google if I were you.
2) Use the forum search! This has been discussed many times (this thread for example)
3) If the executable is statically linked with Allegro and doesn't use any other external libraries, maybe...
4) Why replacing? Write your own function! To answer your question: No, Yes
5) I haven't used it yet, but enet could be your choice. HawkNL is also great, but maybe a bit too low-level for your purpose.

Tobias Dammers
Member #2,604
August 2002
avatar

1. Use the mighty google. There are tons of free music tracks and samples out there; whether they suit your needs and quality standards, is a different issue though.
2. get_executable_name()
3. For Linux, a source distribution is generally preferred (and why wouldn't you?)
4. You cannot replace it, but you can use your own function instead. But what's wrong with the allegro one? (It's not hw-accelerated btw, just some assembly iirc). Whatever you do is probably legal; allegro has one of the most liberal licenses I know of.
5. There are a few networking libraries available through allegro.cc. If you choose one that supports both linux and windows, and manage to get the two systems to connect through the same protocol, there is no reason why the two versions wouldn't be able to work together. Just don't do anything stupid like posting raw struct memory over the network.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Michael Faerber
Member #4,800
July 2004
avatar

Quote:

2. On (SuSE) Linux the game creates and reads the configuration file at/from /root.
If I start it in a console it does that in the working dir. Is there a way to make the game create it always in the directory of the game?

:o :o

It's generally considered as bad practice to create config files in another dir than /etc for system-wide config files and /home/<username> for user config files.

Also, on recent Windows systems you should NOT write your config files to the program's directory. When Vista (the new Windows version) will be released, you will have troubles if you ignore this advice.

I have solved the problem the way that I usually create a config file directory where all config files are written to.

My function for getting the path for the config files:

1std::string als::get_options_path(const string& progname)
2{
3#ifdef ALLEGRO_WINDOWS
4 // APPDATA is the environment variable on NT systems which points to the
5 // directory where programs should put their options
6 if (directory_exists(getenv("APPDATA")))
7 return slashed(getenv("APPDATA")) + progname + '\\';
8 
9 // if APPDATA doesn't exist, put the options in the executable directory
10 return als::get_bin_path();
11#else
12 
13 // return the options path on Unix/Linux systems
14 return slashed(getenv("HOME")) + '.' + progname + '/';
15#endif
16}

And the code for creating paths on Windows and other systems:

bool als::create_directory(const string& directory)
{
#ifdef ALLEGRO_WINDOWS
  return CreateDirectory(directory.c_str(), NULL);
#else
  return mkdir(directory.c_str(), S_IRWXU |
         S_IRGRP | S_IXGRP |
         S_IROTH | S_IXOTH);
#endif
}

A bit more code needed by the code above:

1bool als::directory_exists(const string& dirname)
2{
3 if (file_exists(dirname.c_str(), FA_DIREC, NULL))
4 return true;
5 return false;
6}
7 
8std::string als::slashed(const string& unslashed)
9{
10 // code taken from Allegro's file.c
11 // if the last character is '/', '\\', '#', or ':', return original path
12 char last = unslashed[unslashed.size() - 1];
13 if (last == '/' || last == '\\' || last == '#' || last == ':')
14 return unslashed;
15 
16 // else append the platform specific directory end character
17 
18#ifdef ALLEGRO_WINDOWS
19 return unslashed + '\\';
20#else
21 return unslashed + '/';
22#endif
23 
24}

I hope this helps you making a better program! :)

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Tobias Dammers
Member #2,604
August 2002
avatar

Quote:

When Vista (the new Windows version) will be released, you will have troubles if you ignore this advice.

Way to go microsoft!

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

A J
Member #3,025
December 2002
avatar

Quote:

When Vista (the new Windows version) will be released, you will have troubles if you ignore this advice.

:) Safety for application data. An excellent model... bring it on M$!

___________________________
The more you talk, the more AJ is right. - ML

Go to: