Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bglaze

Pages: [1] 2 3 4
1
SFML projects / Freighter - w/Source (Updated 11/04)
« on: November 09, 2011, 12:10:11 am »
Oh, thanks posva, I'll check those out!

2
SFML projects / CosmoScroll - space shooter game
« on: November 05, 2011, 05:54:40 am »
It just ran fine for me on Windows 7 Ultimate 64-bit.

Very very nice game!

3
SFML projects / Freighter - w/Source (Updated 11/04)
« on: November 04, 2011, 11:42:46 pm »
Added sound and tweaked the code a bit. The game is fully functional now.

4
General / Time as float?
« on: November 03, 2011, 07:43:08 pm »
Thank you, P@u1!

5
General / Time as float?
« on: November 03, 2011, 11:29:32 am »
I was taught that when programming, Time is is typically stored using an integer that represents milliseconds. However, I see that SFML uses floats to represent Time.

Should all of my sub-times that get assigned by and then compared to ElapsedTime() be floats? If I have them as as integers, will SFML have to convert them, thus using more (though I'm sure only slightly) processor power?

Or was I simply taught wrong, and using floats is actually the norm?

Thanks!!

6
Audio / Reusing Soundbuffer issues...
« on: November 03, 2011, 11:04:16 am »
You rock, Laurent. Thanks for explaining how the vector was working against my purposes. I have switched to a list, and I am good to go!

Sorry for the double post!

7
Audio / Reusing Soundbuffer issues...
« on: November 03, 2011, 03:48:46 am »
I think this block is the cause of my sounds getting cut short.

Code: [Select]
if(!iter->GetStatus()){
    iter = soundbox.erase(iter);
}else{
    ++iter;
}


Because, if I comment out this code, everything works fine, however my sounds aren't getting destroyed which means I will cap them out very soon.

I need to figure out a way to only remove them from the vector when they truly have finished playing.

Any idea of how I might go about this other than:

Code: [Select]
if(!iter->GetStatus())

?[/code]

8
Audio / Reusing Soundbuffer issues...
« on: November 03, 2011, 12:51:32 am »
Okay, so in order to play multiple instances of the same sound over top of each other (such as laser shots or explosions), I have created a vector to contain the Sound objects.

A SoundBuffer object matching each of my wav files is stored as a member in my file manager object and is always alive.

First I call my PlaySound function:

Code: [Select]
PlaySound(loads.MyBuffer);

This is my complete PlaySound function:

Code: [Select]
void Game::PlaySound(sf::SoundBuffer& buffer){
    soundbox.push_back(sf::Sound(buffer));
    soundbox[soundbox.size()-1].Play();
}


Then, I have a function that sits in my main loop that checks if each sound has finished playing, and if it has, it gets destroyed. Here is that function:

Code: [Select]
void Game::DestroySounds(){
    for(std::vector<sf::Sound>::iterator iter = soundbox.begin(); iter != soundbox.end(); ){
        if(!iter->GetStatus()){
            iter = soundbox.erase(iter);
        }else{
            ++iter;
        }
    }
}


All this works. However, as soon as one of the Sound objects is erased from the vector, the most recent Sounds that share the same SoundBuffer as the erased Sound are stopped short if they were still playing.

Any advice?

9
Audio / Playing the same sound over top of itself...
« on: November 02, 2011, 11:04:47 pm »
Okay, i could be missing something huge here, but I would like to be able to play the same sound over top of itself. For instance, when I shoot my lasers very fast in my game, I get buzzing sound if the sound hasn't finished playing. Then I tried using:

Code: [Select]
if(!lasersound.GetStatus())
    lasersound.Play();


However, this doesn't sound natural at all, because i have, say, 5 lasers in mid air, but I only heard one of them fire.

I understand (i think) that a new buffer must be created for each sound. But I am having a hard time conceptualizing how to do this. This must be a VERY common problem, because the need has arisen MANY times already in just my simple game.

Any ready solutions out there?
[/u]

10
Audio / Can OpenAL32.dll & libsndfile-1.dll be linked statically
« on: November 02, 2011, 11:01:05 pm »
Oh, makes perfect sense, thanks so much, Laurent!

11
SFML projects / Freighter - w/Source (Updated 11/04)
« on: November 02, 2011, 05:05:25 am »
Many of you have already seen and commented on my first SFML/C++ project located here: http://sfml-dev.org/forum/viewtopic.php?t=6110

This game -- "Freighter" -- is my second project.

The game is completely functional, though I will continue to add features. I apologize for using a .wav file for the background music. I am having trouble using .ogg files, none of them seem to load for me, so I need to work out that kink.

Freighter is a Space Skill game. You must collect the cargo crates that are floating outside your space station. The catch is that they are in an asteroid field, and you must navigate or blast your way through the asteroids to reach them without being killed. Your freighter ship (a millenium falcon =P ) has a shield, but it can only sustain so much damage. The weight of the asteroid determines how much damage it will do to your ship. So even though the big rocks move slowly, they will do lots of damage, so watch out!

Also, you can come back to your Space Station's "Safe Zone" at any time during the level to re-assess your strategy. A Force Field keeps the rocks from penetrating this safe zone, so you should be relatively safe there.

There are 10 levels.

The controls are as follows:
W-A-S-D or Arrow keys to move.
Left Mouse Button or Space Bar to shoot your laser.
F5 Restarts the game if you lose or advances you to the next "Zone" if you win.

Here is the compiled version for Windows:
http://bglz.net/files/cpp/projects/Freighter.zip

And here is the full source code in the form of a Code::Blocks project:
http://bglz.net/files/cpp/projects/Freighter-src-11-04.zip

I would REALLY appreciate suggestions and critiques on this game and especially on the code! As I stated in my first project--Yellow Snake--I am new to C++, so I am REALLY soaking up any advice you can give me on my coding techniques and logic.

Here are some screenshots:




12
Audio / Can OpenAL32.dll & libsndfile-1.dll be linked statically
« on: November 02, 2011, 03:13:26 am »
And if so how? I have my whole application statically linked, and these would be the only two dll's I would have in my exe's folder. So, I was hoping to be able to link them statically as well, for uniformity.

In other linker options, I use the following for my other dlls:

Code: [Select]
-static-libgcc
-static-libstdc++


I have tried adding -static-openal32, but this didn't work...

Any recommendations?

13
General / Advice on bullets? [SOLVED]
« on: October 31, 2011, 11:54:38 pm »
Relic, I definitely appreciate that suggestion, and I took it into consideration.

However, I had been trying so hard to figure out a create/destroy method for my bullets, that I wasn't going to be satisfied until I at least figured out a good way to do it. And I finally have.

Here is the solution I came up with, and hopefully this can be helpful to others in their games since bullets are such a prevalent part of gaming.

First I have a vector to store all of my Laser sprites called "laserbox".

Within the Laser class constructor, each laser sets its position to be the front tip of the space ship. As soon as the laser is created it begins moving upward based on its speed and movement functionality which is a different topic.

When the left mouse button is clicked, a new Laser sprite is create and added to the laserbox vector.
Code: [Select]
case sf::Event::MouseButtonPressed:
    if(event.MouseButton.Button == sf::Mouse::Left){
        laserbox.push_back(Laser(this));
    } break;


Then, inside the game's main loop, this for loop is called. It calls each laser's Update function first, which moves the sprite and checks to see if the laser is still Alive, then it calls Window.Draw() to draw each laser to the screen.

Secondly, and this has been the tricky part for me, it destroys the lasers if they are no longer "Alive". Each laser has a bool member called Alive, and if gets switched to false by its Update() function as soon as its position is out of the screen and/or it comes into contact with a space-rock.

Code: [Select]
for(std::vector<Laser>::iterator iter = laserbox.begin(); iter != laserbox.end(); ){
    iter->Update();
    Window.Draw(*iter);
    if(iter->Alive == false)
        iter = laserbox.erase(iter);
    else
        ++iter;
}


I hope this code can be helpful if anyone else comes across this need. It seems so simple now, but it solves a big problem for me.

14
General / Advice on bullets? [SOLVED]
« on: October 31, 2011, 03:58:22 pm »
Ok folks, I am having a hard time coming up with an efficient bullet system.

My problem isn't with the creation, display, or movement of the bullets--those are easy. However, I am having a hard time with destroying them when their life is over (i.e. they have gone out of screen or they have hit an object and must disappear).

I have been using a vector to contain my bullet sprites, but removing a specific bullet sprite from wherever it happens to reside in that vector has become a problem.

Does anyone have a recommendation for a good container and/or system to use for managing bullets?

If another container is suggested, I would also appreciate any simple code examples you are willing to give. Though, I am also willing to research it myself with whatever info is provided!

Thank you!
Brock

15
Graphics / Help with this bouncing code??
« on: October 31, 2011, 07:24:53 am »
Nevermind... It's actually working very well now that I have more rocks on the screen. Also, it looks far more natural when I am using rock images instead of colored squares...

Pages: [1] 2 3 4