[Audyssey] sfml and cross-platform game

2010-08-06 Thread Travis Siegel
Just a note for those who are interested.
I've updated the chopper patrol port to sfml,
and reposted it at:
http://www.thesiegelsnest.us/mac/chopper_patrol_sfml.zip
I added panning (for the jet, though the sound probably needs replaced since 
the default one doesn't pan well)
This was done by simply moving the listener back a little along the Z axis, 
which allows the sound to smoothly move from right to left
or left to right without the 
jump from one side to the other you get if you leave
the listener at it's default position.

I've also modified the filenames in the load files section, so that
there should now be no changes required to compile properly under case 
sensitive file systems
like most linux variants have.  Osx supports case sensitive file systems, but I 
never did like those, so I have mine set not to be case sensitive,
so had overlooked this little problem in the initial release.
Anyway, I hope this gives developers some ideas on how to make games 
cross-platform,
so there's no more excuse for not making their games multi-os compatible. :)
And, as I mentioned before, I'm perfectly willing to help any developers port 
their games to osx/sfml as desired/required.
hth.

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-28 Thread Thomas Ward
Hi Travis,
Thanks. I'll give it a try. If given a choice I'd rather use SFML over
SDL for OpenAL support alone. However, I've been playing with the
latest SFML build for Linux here and the keyboard input is much better
than SDL. The event handling for keyboard events is much more like
what I am use to from DirectInput, and is very smooth and natural.
With SDL it only accepts a single key pressed or key released event
which means if you have to hold an arrow key down to walk, run, etc
you have to use some sort of boolean flag to tell the application that
the key is being held down or if it has been released. That's not too
cool, but is an easy enough problem to solve with a little extra
coding. With SFML though the way the event system is setup you can
test if the key is being held down and take the proper action without
having to take the extra step of writing a separate keyboard handler
to determine if the key is being held down for a certain period of
time.


Smile.



On 7/28/10, Travis Siegel  wrote:
>
> On Jul 27, 2010, at 8:14 PM, Thomas Ward wrote:
>
> Hi travis,
> Hmmm...That's what I was afraid of. Back during the winter when I was
> thinking about a cross-platform engine I tried both SFML and SDL
> extensively and was able to do what you did witht the sound objects by
> using the sf::Sound::SetBuffer() function to reassign buffers. As you
> pointed out it solves the problem of reassigning a sound object to a
> new sound buffer, but it waistes a lot of memory in the process. Even
> worse this kind of creating a buffer without the ability to destroy it
> when you are done with it can lead to a major memory leak in your
> program.
>
> I just asked on the sfml forums, and I'm guessing the developer of sfml
> doesn't use english as his first language, (though he does speak it quite
> well) my first attempt met with confusion, pointing me to the sounds instead
> of their buffers.  Further clarification lead to the answer you wanted.
> Apparently, you can clear a buffer (if you want to use it later) simply by
> assigning it an empty resource.
> I.E.
> buffer = SoundBuffer();
> This will reassign the buffer to null, thereby allowing the memory to be
> used for other things.
> If you allocate the buffer using new, you could also free it (permanently)
> by using delete.
> I didn't set mine up that way in the chopper patrol port, so teh new/delete
> wouldn't work, but the reassigning buffers to empty values does seem to do
> the trick though.
> Hope this helps.
>
>
> ---
> Gamers mailing list __ Gamers@audyssey.org
> If you want to leave the list, send E-mail to
> gamers-unsubscr...@audyssey.org.
> You can make changes or update your subscription via the web, at
> http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
> All messages are archived and can be searched and read at
> http://www.mail-archive.com/gam...@audyssey.org.
> If you have any questions or concerns regarding the management of the list,
> please send E-mail to gamers-ow...@audyssey.org.
>

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-28 Thread Thomas Ward
Hi Travis,
Cool. I'd be interested to know what you find out on the SFML dev
forums. SFML is a pretty decent API all things considered as it wraps
OpenGL, OpenAL, and some other Mac and Linux higher end gaming
libraries, but the way in which it was done I think certainly could be
improved upon. So any information you find out about this would be
helpful.
As far as giving potential developers more than one option I think you
and I are in full agreement on this. Although, you use Mac OS an I am
using Linux we both want to see more games developed for those
platforms, and to show potential game developers that there are
reasonable alternatives to DirectX and Windows for gaming. As you
pointed out Linux users have SDL installed by default, and there are
libraries for just about any programming language you can think of
including C, C++, C#, Java, Python, Perl, you name it. From what I've
seen on the SFML web site it looks like they also are getting a lot of
help supporting .Net, Python, etc as well. So these APIs are
definitely are growing in terms of end user support, use by game
developers, and best of all support more than one platform allowing
you or I to create a game that can be recompiled on any platform with
only miner changes here and there. So showing potential developers
these different APIs, and how to use them is essential for growth of
Mac and Linux accessible games.
So I guess this weekend or so I'll sit down and create a simple game
like Chopper Patrol, or something similar. I think the Chopper Patrol
game itself is getting a bit old. Maybe I should create a game where
you shoot down spaceships or something, but with the same game
mechanics etc as Chopper Patrol. Although, we have all seen more than
our share of Space Invader clones to last a lifetime.

Smile.

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-28 Thread Travis Siegel

On Jul 27, 2010, at 8:14 PM, Thomas Ward wrote:

Hi travis,
Hmmm...That's what I was afraid of. Back during the winter when I was
thinking about a cross-platform engine I tried both SFML and SDL
extensively and was able to do what you did witht the sound objects by
using the sf::Sound::SetBuffer() function to reassign buffers. As you
pointed out it solves the problem of reassigning a sound object to a
new sound buffer, but it waistes a lot of memory in the process. Even
worse this kind of creating a buffer without the ability to destroy it
when you are done with it can lead to a major memory leak in your
program.

I just asked on the sfml forums, and I'm guessing the developer of sfml doesn't 
use english as his first language, (though he does speak it quite well) my 
first attempt met with confusion, pointing me to the sounds instead of their 
buffers.  Further clarification lead to the answer you wanted.
Apparently, you can clear a buffer (if you want to use it later) simply by 
assigning it an empty resource.
I.E.
buffer = SoundBuffer();
This will reassign the buffer to null, thereby allowing the memory to be used 
for other things.
If you allocate the buffer using new, you could also free it (permanently) by 
using delete.
I didn't set mine up that way in the chopper patrol port, so teh new/delete 
wouldn't work, but the reassigning buffers to empty values does seem to do the 
trick though.
Hope this helps.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread Travis Siegel

On Jul 27, 2010, at 8:14 PM, Thomas Ward wrote:

If you wouldn't mind I'd be happy to create a Chopper Patrol clone
written in C++ using SDL rather than SFML. As SDL is cross-platform
too I think it would demonstrate both our aims but give potential
cross-platform developers another option or alternative to SFML with
some useful source code. What do you think?

Actually, I think this would be an excellent idea, by all means, give potential 
developers as many options as possible.  Show them there's more than one way to 
build cross-platform games that takes nothing away from their initial 
development process.
Also, point out that although sdl comes preinstalled on a lot of linux boxes, 
sfml comes preinstalled on osx, so both options are definitely worth checking 
out.

I agree with your assessment about sfml, and a lot of folks feel that way, but 
after all, the S in sfml does stand for simple, so it's understandable that 
some things may not be doable.  I will raise the question on the sfml-dev 
forums though, and see if anyone has any suggestions on how to handle multiple 
buffer reassigning with buffer freeing.  It's possible it can be done with some 
non-public functions.  I've not scanned all the sfml code, so it's possible 
such a thing does exist, but just isn't in the oficial documentation.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread Thomas Ward
Hi travis,
Hmmm...That's what I was afraid of. Back during the winter when I was
thinking about a cross-platform engine I tried both SFML and SDL
extensively and was able to do what you did witht the sound objects by
using the sf::Sound::SetBuffer() function to reassign buffers. As you
pointed out it solves the problem of reassigning a sound object to a
new sound buffer, but it waistes a lot of memory in the process. Even
worse this kind of creating a buffer without the ability to destroy it
when you are done with it can lead to a major memory leak in your
program. That's the primary reason why I have stayed clear of SFML. It
doesn't necessarily use best code practices in doing some of the
things it does. For that reason I am strongly looking at using SDL
instead for my cross-platform games.
With SDL Mixer, for example, all of the sound chunks are pointers. If
you do something like
Mix_Chunk* g_pSound = NULL;
you have a global pointer here that remains in memory until you free
it with delete. To initialize this pointer simply do something like
Mix_LoadChunk(1, &g_pSound, "Sound/Some_File.wav");
which does three things. It initializes the pointer, asigns
Some_File.wav to it, and the pointer is asigned to the first audio
channel in the mixer. To free that pointer up use
Mix_FreeChunk(&g_pSound);
g_pSound = NULL;
which frees up any memory used by that pointer and resets its state
back to null. If you then want to use another sound with that same
pointer simply use Mix_LoadChunk() again to reinitialize the pointer
with some new sound data. This to me seams a lot more memory safe and
much better way of handling audio than the way SFML does it.
If you wouldn't mind I'd be happy to create a Chopper Patrol clone
written in C++ using SDL rather than SFML. As SDL is cross-platform
too I think it would demonstrate both our aims but give potential
cross-platform developers another option or alternative to SFML with
some useful source code. What do you think?

Cheers!

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread Travis Siegel
While I can't find anything in sfml that allows actual buffer destruction, you 
can reassign buffers.  I just tried this, and it worked perfectly.

if (!buffer1.LoadFromFile("sound/background.wav"))
printf("error is: %d\n",EXIT_SUCCESS);
sf::Sound Background(buffer1);
Background.Play();
getchar();
if (!buffer2.LoadFromFile("sound/helicopter.wav"))
printf("error is: %d\n",EXIT_SUCCESS);
sf::Sound Helicopter(buffer2);
Background.SetBuffer(buffer2);
Background.Play();
getchar();
exit(0);

While this doesn't actually destroy the contents of the buffer, it does allow 
you to reassign what sounds the call to any particular sound.play function will 
play.
It won't help with memory usage I'm afraid, but it will solve your problem with 
needing to change sounds on the fly w/o modifying the code being called to play 
the sounds.

Failing that, there is a function (for internal use only) that is used to reset 
buffers.  I've not looked at the source for it, but it's possible you could use 
that one if you needed to actually delete the buffers in question.
Hope this helps.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread Thomas Ward
Hi Travis,
I've just downloaded and read your C++ port of Chopper Patrol, and I'm
left with some questions. Unfortunately, like alot of other sample
SFML games I've seen everything is all wrapped up in the main
function, and all of the sounds in this case are static. That is you
never have to unload all of the game sounds, and load a lot of new
ones when the next level loads as is the case in games like Mysteries
of the Ancients.
For example, in Mysteries of the Ancients when you select pistol from
the inventory menu or select 1 on the keyboard all of the weapon sound
buffers are destroyed and then are recreated on the fly with all the
sounds for the pistol. The Same happens regardless if you select the
pistol, magnum, shotgun, whatever. That way I only have to worry about
SecondaryBuffers like g_fire, g_empty, g_draw, and g_holster which are
loaded and unloaded depending on which sound is needed at the current
time. With SFML I have not been able to find a way to do this.
To clarify things some. Let's assume we have an SFML audio buffer like
sf::Buffer g_fire;
which is global. Now, at some point in my game I am going to load the
sound of the pistol into the global buffer like
g_fire.LoadFromFile("Sounds/Fire_Pistol.wav");
which loads our pistol sound into our global sound buffer. However,
let's assume some one wants to switch to the magnum. In DirectX I can
simply close the buffer like
g_fire->Close();
g_fire = NULL;
that closes the buffer and resets the pointer to NULL. Which I think
is the problem here. In DirectX SecondaryBuffers are pointers not
objects so are never destroyed until you delete them. They allow you
to close the SecondaryBuffer but you still can use the g_fire pointer
to load a new file into the SecondaryBuffer without losing control of
the global SecondaryBuffer object. How on earth can you do something
like this in SFML?
Basically, what I am looking for is a way to close an SFML buffer equal to doing
g_fire->Close();
that doesn't destroy the actual buffer. That is if I did something like
g_fire.Close();
g_fire.LoadFromFile("some_file.wav");
it should work, but doesn't. I haven't been able to find anything that
remotely works like that in SFML. Any help?

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread Zachary Kline

Hi there,
As a Linux user, I can confirm that this game compiles with minimal
changes to the source code.  It appears to run properly.
One thing to note is that the names used for header files are 
case-sensitive under Linux, so they required tweaking.  Other than that, 
it seems to run as designed.

Now to understand the code...
Best,
Zack.



On Tue, 27 Jul 2010, Travis Siegel wrote:


Hello folks.
I've taken the chopper patrol game from bscgames
and ported it to C++.
It uses the sfml libraries, and since they exist for linux, mac osx, and 
windows, I think
this probably qualifies as the first truly cross-platform accessible game for 
the blind
not written in java or python, or some other scripting type language.
You can find both the intel-based mac binary as well as the source (with lots 
of comments) at:
http://www.thesiegelsnest.us/mac/chopper_patrol_sfml.zip
I certainly hope other developers will take a look, and realize how simple it 
is to write
cross-platform games.
And, it took no additional effort to make it so, so no additional development 
time as is often the complaint.
Enjoy, and of course, feel free to contact me if anyone has additional 
questions.
The osx binary that is included may or may not work on your system, it depends 
on where your sfml libs are.
I made no attempt to make it work on other systems, except my own, but I will 
put up an mp3 of the game being played later on, so folks can see how it plays.
Let me state that I've never played the original version of the game for 
windows, so this port is strictly based on the readme.txt file and the vb 
source code.
All of which is explained in the comments of the program.
(yes, the C++ source is included)
I'm not great at formatting code, so it's probably not up to most folks 
standards of pretty code, but it works, so there you go
It could use improvements in a couple places too, but this was more a proof of 
concept than anything else, so
I suppose the code will have to speak for itself, bad coding practices and all.
The primary intent of this port was to prove it's not hard (in fact, rather 
easy) to write cross-platform games with nothing but sfml and a c++ compiler.
I do not have access to a linux box, so haven't tested it on that platform, and
my windows machines don't have compilers on them at the moment, so that's not 
tested either, but sfml code *should* compile with few (if any) changes on the 
other platforms.
Again, enjoy, and I hope this kicks off a great many cross-platform games for 
us all.

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.



---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


Re: [Audyssey] sfml and cross-platform game

2010-07-27 Thread shaun everiss

do you have this as windows to or can you make it such?
At 11:17 p.m. 27/07/2010, you wrote:

Hello folks.
I've taken the chopper patrol game from bscgames
and ported it to C++.
It uses the sfml libraries, and since they exist for linux, mac osx, 
and windows, I think
this probably qualifies as the first truly cross-platform accessible 
game for the blind

not written in java or python, or some other scripting type language.
You can find both the intel-based mac binary as well as the source 
(with lots of comments) at:

http://www.thesiegelsnest.us/mac/chopper_patrol_sfml.zip
I certainly hope other developers will take a look, and realize how 
simple it is to write

cross-platform games.
And, it took no additional effort to make it so, so no additional 
development time as is often the complaint.
Enjoy, and of course, feel free to contact me if anyone has 
additional questions.
The osx binary that is included may or may not work on your system, 
it depends on where your sfml libs are.
I made no attempt to make it work on other systems, except my own, 
but I will put up an mp3 of the game being played later on, so folks 
can see how it plays.
Let me state that I've never played the original version of the game 
for windows, so this port is strictly based on the readme.txt file 
and the vb source code.

All of which is explained in the comments of the program.
(yes, the C++ source is included)
I'm not great at formatting code, so it's probably not up to most 
folks standards of pretty code, but it works, so there you go
It could use improvements in a couple places too, but this was more 
a proof of concept than anything else, so
I suppose the code will have to speak for itself, bad coding 
practices and all.
The primary intent of this port was to prove it's not hard (in fact, 
rather easy) to write cross-platform games with nothing but sfml and 
a c++ compiler.
I do not have access to a linux box, so haven't tested it on that 
platform, and
my windows machines don't have compilers on them at the moment, so 
that's not tested either, but sfml code *should* compile with few 
(if any) changes on the other platforms.
Again, enjoy, and I hope this kicks off a great many cross-platform 
games for us all.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.




---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


[Audyssey] sfml and cross-platform game

2010-07-27 Thread Travis Siegel
Hello folks.
I've taken the chopper patrol game from bscgames
and ported it to C++.
It uses the sfml libraries, and since they exist for linux, mac osx, and 
windows, I think
this probably qualifies as the first truly cross-platform accessible game for 
the blind
not written in java or python, or some other scripting type language.
You can find both the intel-based mac binary as well as the source (with lots 
of comments) at:
http://www.thesiegelsnest.us/mac/chopper_patrol_sfml.zip
I certainly hope other developers will take a look, and realize how simple it 
is to write
cross-platform games.
And, it took no additional effort to make it so, so no additional development 
time as is often the complaint.
Enjoy, and of course, feel free to contact me if anyone has additional 
questions.
The osx binary that is included may or may not work on your system, it depends 
on where your sfml libs are.
I made no attempt to make it work on other systems, except my own, but I will 
put up an mp3 of the game being played later on, so folks can see how it plays.
Let me state that I've never played the original version of the game for 
windows, so this port is strictly based on the readme.txt file and the vb 
source code.
All of which is explained in the comments of the program.
(yes, the C++ source is included)
I'm not great at formatting code, so it's probably not up to most folks 
standards of pretty code, but it works, so there you go
It could use improvements in a couple places too, but this was more a proof of 
concept than anything else, so
I suppose the code will have to speak for itself, bad coding practices and all.
The primary intent of this port was to prove it's not hard (in fact, rather 
easy) to write cross-platform games with nothing but sfml and a c++ compiler.
I do not have access to a linux box, so haven't tested it on that platform, and
my windows machines don't have compilers on them at the moment, so that's not 
tested either, but sfml code *should* compile with few (if any) changes on the 
other platforms.
Again, enjoy, and I hope this kicks off a great many cross-platform games for 
us all.

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.