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

Pages: [1] 2 3 ... 231
1
SFML projects / Re: FiveBlocksFall - My first SFML videogame
« on: Today at 12:15:11 am »
This code doesn't seem too bad. If it works, it shouldn't matter anyway! ;D

With that said, you could probably do both event loops as just one and just change what is drawn by the current time (whether it's in the splash section or the fade out section).

2
General / Re: making menu with different files
« on: March 09, 2026, 11:58:23 pm »
It sounds like you want to write a program (menu) that can execute another program (game)...

I would question this design.
It's likely that the main menu (or similar) would be accessible from within the game (paused, for example) anyway but, even if not, you'll likely be returning to the menu after the game has been played.
So, it's probably better to include the menu "program" and game "program" into just one executable.

You can still access files from within C++ so you can always load main menu (or other menu) data from a separate file, if required.


With that being said, if you do need to launch another executable from within your program, you can do this but you'll need OS-specific code.

3
Graphics / Re: How to handle normalized coordinates and resolution changes
« on: February 23, 2026, 05:47:50 pm »
If I got this right, there is no way to cleanly use normalized coordinate system in SFML? Is sf::View view({ 0.f, 0.f }, { 1.f, 1.f }); not suitable for this use case?
It's worth noting here that the view constructor that takes two sf::Vector2fs presumes the first one is the centre of the view, not the 'start' or top-left.
So, it you wanted a view that went from (0,0) to (1,1), the centre of the view would be (0.5,0.5):
sf::View view({ 0.5f, 0.5f }, { 1.f, 1.f });
As opposed to a sf::Rect, which would take the 'position' and 'size' so would be the top-left.
And, since a view's constructor can take an sf::FloatRect, you could do this:
sf::View view({ { 0.f, 0.f }, { 1.f, 1.f } });
Note the extra braces. This means that you are creating a sf::FloatRect (from 0,0 to 1,1).
Without the braces, it would be (-0.5,-0.5) to (0.5,0.5). That is, a size of 1x1 with 0,0 at the centre.


4
Graphics / Re: Rounded Rectangle
« on: February 06, 2026, 08:02:23 pm »
You could also use Grambol (header-only library), which comes with rounded rectangles provided, along with many others such as: rounded frames, parallelogram, common icons and customisable arrows (see the yellow rectangle and the green rectangular frame, both rounded):


Other than that, you could use a sf::ConvexShape and plot the rounded edges yourself.

5
SFML projects / Dais
« on: January 31, 2026, 05:16:50 am »
Hi!

I was working on a platformer-style game idea for a bit a while back.
I call it Dais.



It has gone through many internal modifications, including changing the way it draws its map (from Selba Ward's Console Screen to using Cheese Map) and, now, fully updated to use SFML 3.

It's allowed me to experiment with some different things at once:
menus,
states,
controllers and control customisation,
platformer game internals,
manual character animation,
implementing player/enemy animation,
considering preparing for multiple language support,
resource packing,
and more...

I've learnt a lot from experimenting with it and there isn't much of a game, to be fair, but there is a simple level created for testing some features.

I'm still considering whether or not to continue with it as a game. I think I would like to...

Therefore, I'd be very interesting in some feedback on things like how it "feels" to play and the user experience overall.

So, here is a downloadable zip file:
https://www.dropbox.com/scl/fi/5twjfm5grc7ziup47dor2/Dais-early-alpha-tests-0.0.1.zip?rlkey=xqb1k2t5mqqmiuw1fmc80fa2j&st=80axyuz6&dl=0
(click on the download icon at top-right)
It's for 64-bit Windows only, unfortunately.
Remember to extract the zip file before running.

Included in the zip is Dais.exe (the main program), DaisDev.exe (the DEV mode version with ability to modify the map live and other stuff) and a resources folder.

If you don't have the latest Visual C++ Redistributable (required for this to run), I believe you can download it directly from Microsoft here:
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-supported-redistributable-version

I look forward to your feedback :)

p.s. If you want to use a controller, make sure it is connected before starting Dais.



EDIT: added screenshot.

6
SFML projects / Re: Cheese Map
« on: January 24, 2026, 04:31:27 am »
Added some tutorials with guidance on how to easily create the different type of maps:
https://github.com/Hapaxia/CheeseMap/wiki/Tutorials

Some examples of the simple maps created by the tutorials:



7
Graphics / Re: SFML 3.0.2 - How to get Resized Size?
« on: January 22, 2026, 11:45:05 pm »
You don't need to check "if" the event is Resized, the "getIf" can do that for you; it fails the if condition if it isn't.
So, you can do this (as shown in the tutorial):
if (const auto* resized = event->getIf<sf::Event::Resized>())
{
    std::cout << "new width: " << resized->size.x << std::endl;
    std::cout << "new height: " << resized->size.y << std::endl;
}
instead of your:
if (event->is<sf::Event::Resized>()) {}

the "size" member of the resized event is an sf::Vector2 (of the 2u variety) and SFML can convert between its Vector2 types so you can create an sf::Vector2f directly from a sf::Vector2u.
sf::Vector2f(resized->size)
or
static_cast<sf::Vector2f>(resized->size)
both create a sf::Vector2f from resized->size.

This means, you could do something like this:
if (const auto* resized = event->getIf<sf::Event::Resized>())
{
    const sf::Vector2f newSize(resized->size);
    mainView.setSize(newSize);
    mainView.setCenter(newSize / 2.f);
    window->setView(mainView);
}

Oh yeah, and you can divide a sf::Vector2 by a single value (scalar), shown above in setCenter. :)

8
Graphics / Re: How would you manage a game with a very large world?
« on: January 16, 2026, 10:24:05 pm »
Hi! Welcome! :)

The main point of using tiles is so that they can be repeated.
If you are not repeating anything at all, there's no point to split things into smaller pieces.

With that said, the texture size limit then forces breaking down larger images into multiple textures but each textures does not need to be broken into multiple smaller tiles unless they are going to be repeated (or will be or can be used in  a different order).
If I remember correctly, Thor (library for use with SFML) provides the ability to draw an image larger than you can with a single texture using multiple textures.

This might be moot depending on the size of the textures available to the more modern graphics cards but increasing resolutions basically tip the balance back again. If a card can handle 32k x 32k textures, you can work with 4k and 8k resolutions directly. If not, those resolutions would require either stitched textures (see Thor recommendation above) or using a lower resolution scaled up.

It's not fully clear what your map requirements actually are. Do you need full, single images that don't repeat or break down into smaller components?
It's worth noting that often it can be optimistic (and also have the side-effect of helping with parallax effects) to use multiple layers. For example, a background that is not so complicated and can be represented using tile and probably doesn't move as much so less image needed overall, and a foreground that comprises of specific components; these components can be repeated when needed but, even if not, they don't need to represent the entire view, just some parts. I personally would call these components "free tiles" or something similar (as I did in Cheese Map).
Providing multiple layers may 'cost' more, of course, depending on the design.

So, really, what do you need? Full-view maps that can be represented by a single image? If so, apart from the consideration mentioned above, draw it with a single tile from a single texture. You would need to be able to draw the next (in any direction) map image so you'd need to be prepared for that by drawing the 8 (all direction) images around the one you can see. If a texture cannot store multiple of these images, you'd need a different texture for each.
Your considerations then would be when to load a texture that a player is approaching but no yet reached and also when to unload a texture that a player has left or, better still, will definitely no be returning to.
You will also need to consider your process for dealing with the different possibilities of each graphics card and work different for each situation (e.g. splitting a single image into multiple 'tiles' with different textures if it can't deal with a size of texture that doesn't fill the screen (this is quite rare but 1k x 1k or 2k x 2k are usually expected so 4 (for 2k textures, or 16 for 1k textures) textures should be enough to fill a 4k view.

Again, though, really consider if you might be able to break down an image into smaller, preferably repeated, components. Most images are made up of smaller components and if you can find a way that it works for your design, it should be considered.

Rendering ALL the world in a RenderTexture? But is RenderTexture limited in size as well as regular textures? And would it consume large GPU memory as well?
Render textures render to a texture so the requirements for textures also apply to render textures.

9
SFML projects / Re: nyxfx - Audio Plugins Using SFML v3
« on: January 14, 2026, 04:34:26 pm »
Nice. It's always nice to see more things available for audio production, let alone seeing it done with SFML. :)

I find VST a pretty daunting coding venture. I use lots of VSTs, of course, but programming them? Eek!

I watch with interest in your progress and experiments.

I would advise that you consider creating your website to still look appealing without JavaScript. It's pretty ugly and unusable until JavaScript is enable and I wouldn't want you to put off any potential viewers/readers.

10
Great. So, I've switched image hoster for the future. :D
Which one do you use?
I'm currently using imgbox. Seems fine.

11
Sorry, you gotta talk to your gov to not implement "child safety" laws that can't be reasonably adhered to. ;D
There are a lot of things I'd like to talk to them about.
But it's entire UK's fault; we shouldn't have to be excluded from everything because of some fools.

imgur is blocked in the UK or the other way around...
Imgur have chosen to not serve UK requests. I can't see most of the images I've posted - myself - on this forum (without using a VPN/proxy). I also cannot access my account. Great. So, I've switched image hoster for the future. :D

13
Graphics / Re: sf::Text no longer has a default constructor, so...?
« on: December 03, 2025, 04:18:58 pm »
I just want to add that this "could do this before" code seems problematic:
Quote
text.setFont("font/directory.ttf");

This would have created a temporary font and passed that to the text. The font would then be destroyed.
Remember that the font must exist for as long as the text is being used.

Although you can store a font in the same class as the text, it's likely best to store it externally and just pass it in and construct the text with it when you construct the class (as shown in fallahn's resource manager example, although this also applies when not using a resource manager).

class Engine
{
private:
    sf::Text m_text;
public:
    Engine(const sf::Font& font)
        : m_text(font)
    {
    }
}

int main()
{
    sf::Font font("fonts/directory.ttf"); // this may throw an exception if loading fails!
    Engine engine(font);
}

14
SFML projects / Re: Dispersio 3
« on: November 21, 2025, 12:13:39 am »
Nice to see it completed. Congratulations!

Added! :)

15
SFML projects / Re: Selba Ward
« on: November 21, 2025, 12:00:00 am »
Thanks!
I just wanted to test Polygon to see if it could do it.
It failed first time and I spent hours following Polygon's code until I realised I was duplicating a point so it wasn't Polygon's fault after all! ;D

Loading the SVG was easy:
Open with Notepad++ and then copy&paste values into { x, y } style code.
 :-[

Pages: [1] 2 3 ... 231
anything