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 - MrOnlineCoder

Pages: 1 [2] 3 4 ... 6
16
Audio / sf::Music hangs the app with PhysFS
« on: December 22, 2017, 01:34:49 pm »
Hello! I am working on a game and I load all resources from zip file using PhysFS. I am using this class from SFML wiki: https://github.com/SFML/SFML/wiki/Source:-PhysicsFS-Input-Stream

And I have noticed strange behaivour: if I open PhysFsStream once, open music from it, then everything is OK. But if I do this again (to change current music) -  my application hangs (100% of CPU core).

Minimal code (all variables are class members):

//GameState

//init() - called once when game state is shown up
pfsStream.open("music/1.ogg");
music.openFromStream(pfsStream);

music.play();

//input() - called on input.
music.stop();
pfsStream.open("music/2.ogg");
music.openFromStream(pfsStream);

music.play();
 

My PhysFS setup is fully wokrable (I use the same way to load textures, sounds, they are all working and loaded correctly). 

After debugging application for some time, I ended on this code in sf::SoundStream:

void SoundStream::stop()
{
    // Request the thread to terminate
    {
        Lock lock(m_threadMutex);
        m_isStreaming = false;
    }
...
 

I wil really appreciate any help concerning this topic, maybe newer version of PhysFS stream or any possible fixes.

17
SFML projects / Re: R-Type 2D shoot'em up (C++17)
« on: December 14, 2017, 09:14:27 pm »
Looks nice!

I really like that "sci-fi" GUI. Waiting to see gameplay video :)

18
SFML projects / Re: SFML multicolor text class
« on: December 10, 2017, 11:41:35 am »
Wow, haven't found that! Thanks

19
SFML projects / Re: SFML multicolor text class
« on: December 09, 2017, 09:11:29 pm »
Well, it just satisfies my needs, so I didn't think about bb code or streams so.  :)

20
SFML projects / SFML multicolor text class
« on: December 09, 2017, 07:51:27 pm »
Hello.

In my project I really needed multicolor text, for showing info about game objects and chat text, like this:

Price: 2500 Gold

or

Damage: 100-120

But I didn't found a solution online, so I wrote one by myself.
Usage:

Basically, this is just a copy of original sf::Text class with one modification in ensureGeometryUpdate method.

When setting Text string, you can specify new text color using % character (like printf):

FText text;
text.setFont(yourfont);
text.setPosition(100,100);
text.setString("%0Format%2ted %3text");
 

which will draw:

Formatted text

Escaping % is done by writing two %:

test.setString("%1Damage: %2100 %%");
 

Damage: 100 %

Character-color pair is translated in sf::Color FText::getColorForChar(char c):
sf::Color FText::getColorForChar(char c) {
        switch (c)
        {
                case '0':
                        return sf::Color::Black;
                case '1':
                        return sf::Color::White;
                case '2':
                        return sf::Color::Red;
                case '3':
                        return sf::Color::Green;
                case '4':
                        return sf::Color::Blue;
                case '5':
                        return sf::Color::Yellow;
                case '6':
                        return sf::Color::Magenta;
                case '7':
                        return sf::Color::Cyan;
                default:
                        return sf::Color::Black;
        }
}
 

You can expand number of available colors by adding new cases to this method.

Code:
Header: https://gist.github.com/MrOnlineCoder/579ddc7c513a8fc6f5b024aa8b43ffbb
Source: https://gist.github.com/MrOnlineCoder/69a3bd3e18e2958526b6bac14dd8d0c9

I am open to any suggestions or comments.

21
SFML projects / Re: AchBall
« on: October 08, 2017, 07:53:20 pm »
Link for demo version or something please?  ;)

22
Good job! If there was a aircraft machine gun, rocket launcher and some enemies, it would be great and fun!  ;)

23
SFML projects / Re: Dispersio 2
« on: June 29, 2017, 12:54:05 pm »
Looks very nice! I like this inventory :) Good luck, hope it will be interesting game! Will you have a story/plot in this game?

24
Very nice graphics and animations! However, I encountered a game crash on my Windows 7 x64, played Singleplayer quick game and in the middle of the game "Program PointlessWars.exe stopped working...."

25
SFML projects / Re: It Usually Ends In Nuclear War
« on: June 19, 2017, 11:16:29 pm »
That looks so cool and nice! Good luck in development! Hope "it will end in enjoyable game" (not a nuclear war :) ) How do you make this "terra incognita" effect? (unexplored areas are not shown)

26
SFML projects / Redstay - simple hobby 2D Platformer
« on: June 14, 2017, 12:31:35 am »
Hello  :) Last week I made a simple platformer on SFML for educational purposes.

Controls:

- A and D to move
- W to jump
- E to use magnet
- Enter in main menu to start new game

Game objects:
key - required to enter next level
teleport - teleports you to another position
time ray - slows down the time (useless :D )
magnet - pick it up to change gravity

Boss fight tactic:
avoid projectiles using magnet and jump on his head when he is moving

Tools used:
Visual Studio 2012
SFML 2.4.2
Tiled Map Editor
Paint/Photoshop
Audacity

Credits:
MrOnlineCoder (me) - creator, programmer, level designer
Eric Matyas and Kevin MacLeod - music

Thanks to Laurent Gomila for such useful library, of course!   ;)

Download: https://github.com/MrOnlineCoder/Redstay/releases/download/1.0.0/Redstay.by.MrOnlineCoder.zip

GitHub: https://github.com/MrOnlineCoder/Redstay

(click to show/hide)

27
Feature requests / addColor method
« on: June 11, 2017, 03:57:12 pm »
Hello. In game, I often use some "flash" effects, or fading animations, where I change sprite/shape color like this:

sf::Color color = sprite.getColor();
color.a++;
sprite.setColor(color);
 

It will be very nice and useful if addColor method exists:
sprite.addColor(0,0,0,1);
 

28
General / Creating open-source game engine
« on: May 28, 2017, 03:41:18 pm »
Hello. I have a question: how should I release game engine for public use? Should I release source code, so users will build it and link with their project, or should they just make a file which describes the game and it's resources, so user will run the engine and then it will load the game description file (like GoldSrc, you run hl -game >game folder>), or should I do it in another way?

Thanks.

29
Hello. I came here to share my extension - sfCoach. I created it for personal needs, but maybe it will be useful for someone. So it helps you to animate objects.

Short documentation
There are 2 main classes: Animation and Coach in sfCoach namespace. The first one is abstract calss and has an update() method. The second one is just a simple container. Let's create a circle:
sf::CircleShape shape(50);
shape.setPosition(150, 150);
shape.setFillColor(sf::Color::Green);

Now, you need to create instance of Coach class:
sfCoach::Coach coach;

Also, you should call Coach update() method every frame:
while (window.isOpen) {
  //Handle events....
 

  coach.update();

  window.clear();

  window.display();
}

Now you can animate your objects. You can animate: Sprite, Text, CircleShape, RectangleShape. Currently, there are 3 types of animation: DisplayAnimation, FadeAnimation, MoveAnimation.

DisplayAnimation hides or shows the target after specified amount of time.
FadeAnimation fades the target in or out.
MoveAnimation moves object from point A to point B (interpolation).

Creating animation (for example):
sfCoach::DisplayAnimation hide(sfCoach::createTarget(shape), 3.2f); //3.2f is delay in seconds after which shape will be hidden

sfCoach::createTarget is a factory method. It is overloaded for most drawables to create universal animatable targets.

The last step is simple: play it!
coach.playAnimation(&hide);

You can find example and source code in GitHub repository:

https://github.com/MrOnlineCoder/sfCoach

Thanks to therocode for factory methods idea

30
SFML projects / Re: HeedJet
« on: March 20, 2017, 03:35:12 pm »
Very nice!  Waiting for download link!

Pages: 1 [2] 3 4 ... 6
anything