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.


Topics - Haze

Pages: [1]
1
SFML projects / Wallbreaker (Arkanoid clone)
« on: October 28, 2019, 01:14:12 pm »
Hi,

This is Wallbreaker, a clone of the old classic Arkanoid/Breakout games.



There are various power-ups and you can create/edit your own levels with the built-in editor.



This is a very simple game, but it's quite complete. I just wanted a small project that I could actually finish to play with the SFML API. You can found:
- a particle system
- animations (move, zoom, and fade effects)
- a custom GUI module
- bitmap fonts
- state management
Some people might be interested in that so I decided to properly release it. Feel free to have a look!

Windows release: https://github.com/abodelot/wallbreaker/releases/download/v0.3/wallbreaker_0.3-windows.zip
Github project: https://github.com/abodelot/wallbreaker

2
Graphics / Unexpected alpha-blending result with render texture
« on: April 17, 2019, 06:48:21 pm »
Hi,

I want to draw a white square with half-opacity (alpha 128), but the alpha-blending isn't rendered as expected when I draw on a render texture.

Why don't the two following methods render the same result?

Method A:
    1. Draw something on a render texture
    2. Draw the render texture on render window
    3. Draw a white square with half-opacity on render window

Method B:
    1. Draw something on a render texture
    2. Draw a white square with half opacity on the render texture
    3. Draw the render texture on render window

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(320, 240), "sfml", sf::Style::Close);

    sf::RectangleShape black({20 ,240});
    black.setPosition(100, 0);
    black.setFillColor(sf::Color::Black);

    sf::RectangleShape white({60, 60});
    white.setPosition(80, 50);
    white.setFillColor(sf::Color(255, 255, 255, 128));

    sf::RenderTexture texture;
    texture.create(window.getSize().x, window.getSize().y);
    sf::Sprite sprite(texture.getTexture());

    // Method A: Draw white square on render texture
    texture.clear(sf::Color::Transparent);
    texture.draw(black);
    texture.draw(white);
    texture.display();

    white.setPosition(80, 160);
    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
        // Method B: Draw white square on render window
        window.clear(sf::Color::Blue);
        window.draw(sprite);
        window.draw(white);
        window.display();
    }
    return 0;
}
 

Image result in attachement.


Am I missing something?

- OS: Debian 9
- GPU: Mesa DRI Intel(R) Haswell Mobile (0xa16)
- SFML Version: 2.5.1

3
Window / Best way to save a screenshot
« on: March 31, 2019, 07:12:59 pm »
Hi,

I'm trying to catch up with last SFML releases, and noticed that RenderWindow::capture is now deprecated:
Quote
Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.

My use case is saving to a image file what is currently rendered on a render window.

Is the following code the best approach for SFML >= 2.4?
sf::Texture texture;
texture.create(render_window.getSize().x, render_window.getSize().y);
texture.update(render_window);
if (texture.copyToImage().saveToFile(filename))
{
    std::cout << "screenshot saved to " << filename << std::endl;
}
 

Also, this seems like quite a common task. Maybe it should be added in the wiki?

4
Feature requests / Return type of sf::String::toUtfX
« on: July 08, 2014, 06:00:35 pm »
Currently, sf::String::toUtf8 returns a std::basic_string<Uint8> object.

I think It would be better if toUtf8 returned a std::string, because this method isn't very useful: you can't do much with these std::basic_string<> objects, and you need to convert them if you want to do very basic things such as:
  • display them with std::cout
  • write them in a file
  • use them in a 3rd party library...

Doing any of these things requires a conversion which could be avoided:

std::basic_string<sf::Uint8> tmp = sfString.toUtf8();
std::string utf8(tmp.begin(), tmp.end());
 

So, why not returning standard, more convenient objects?
Same remark for toUtf16 / std::wstring.

5
Graphics / [SOLVED] How to draw a repeated pattern?
« on: February 19, 2013, 01:50:48 pm »
Hi,

I want to display a background using a tiled pattern.
I know this can be achieve by using a sprite with a repeated texture, but I want to avoid using one image per pattern, because I'd like to group them in a single sprite sheet (I intend to deal with many small patterns so a single image would be much more efficient and convenient).

For example, this is a 64x64 spritesheet with 4 32x32 patterns.

Let's say I want to draw a 640x480 background with the top-left pattern.
I tried using a RectangleShape and a repeated texture:

sf::Texture patterns;
patterns.loadFromFile("patterns.png");
patterns.setRepeated(true);

sf::RectangleShape background;
background.setTexture(&patterns);
background.setTextureRect(sf::IntRect(0, 0, 32, 32));
background.setSize(sf::Vector2f(640, 480));

But I just ended with a streched/scaled background:


Any advices?

6
Feature requests / Missing OpenGL primitive types
« on: July 10, 2012, 12:42:06 pm »
I've noticed that only 7 out 10 OpenGL primitive types are represented in sf::PrimitiveType.
Why are the 3 other ones missing? (GL_LINE_LOOP, GL_QUADS_STRIP, GL_POLYGON)?
Could they be added? They could be useful.

7
Feature requests / Extended operations for sf::String
« on: November 16, 2011, 01:58:04 am »
SFML 2.0 introduces sf::String, which is really convenient for handling strings.
Since this class already has string manipulation methods (Erase, Insert, Find and iterators), that would be very useful if sf::String provides more of these.

I am thinking about basic operations such as:

- Removing leading and trailing whitespaces:
sf::String Trim() const;
And why not LTrim (leading only) and RTrim (trailing only)

- Extracting a sub-string:
sf::String Substr(size_t Index, size_t Length) const;

- Replacing occurences:
sf::String Replace(const sf::String& LookFor, const sf::String& ReplaceBy) const;

- Converting to lowercase:
sf::String ToLowerCase() const;

- Converting to uppercase:
sf::String ToUpperCase() const;

8
Feature requests / Remove texture from sprite
« on: September 28, 2011, 12:37:56 pm »
I would like SFML users were able to remove a texture from a sprite, because sometimes a plain colored rectangle is just what you need.

I am thinking about something like :
Code: [Select]
void sf::Sprite::RemoveTexture();
or maybe :
Code: [Select]
mysprite.SetTexture(NULL);
by using a pointer instead of a reference.

9
SFML projects / CosmoScroll - space shooter game
« on: March 13, 2010, 04:38:59 pm »
Here is Cosmoscroll, an horizontal-scrolling space shooting game written in C++/SFML.

This space shooter features space bandits, aliens and various power-ups.
Cosmoscroll comes in two flavors:
  • Story Mode : Complete all levels, beat the final boss and unlock the hardcore version!
    Collect credits and use them for upgrading your spaceship and buying better weapons.
  • Arcade Mode : Hold as long as possible against more and more powerful bad guys.
    Try to establish a new high score and share it online to compete against other players!
    Don't forget to upgrade your spaceship in the Story Mode for improving your score.

The game is also internationalized (english/french/german) and should load the appropriate translation file according to your system locale.







Download CosmoScroll 0.4 :
Old version for Mac OS X (0.3) : Mac OS X version

CosmoScroll is free software (GPL), source code is available on Google Code

Your comments and suggestions are welcome!.

Pages: [1]
anything