Skip to content

tygasamurai/SFML_GUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SFML_GUI

1. Data Structure (Backend)

Most developers use standard C++ containers to store item data. With SFML 3 moving to C++17, you have access to modern tools for this:

  • std::vector: The most common choice for a simple list of items.
  • std::unordered_map: Ideal for an Entity Manager where you need to retrieve items by ID or name.
  • Custom Class: Create an Item class to hold properties like name, weight, and a pointer to an sf::Texture.

2. Rendering (Frontend)

SFML 3 introduced several changes to how you display graphics:

  • Grid Layout: Use a loop to draw a series of sf::RectangleShape objects to create slot backgrounds, then draw sf::Sprite icons on top of them.
  • Scoped Enums: If you use enums for item types (e.g., Weapon, Potion), remember that SFML 3 uses scoped enumerations. For example, your code would look like ItemType::Weapon instead of just Weapon.
  • Scissor Testing: You can now use sf::View's scissor testing to ensure inventory items stay within the UI panel and don't "bleed" into the main game area.

3. Interaction

  • Event Handling: Use the new sf::Event::getIf syntax in SFML 3 to check for mouse clicks on inventory slots.
  • UI Libraries: Instead of building from scratch, you can integrate imgui-sfml, which supports SFML 3 and provides ready-made window and button widgets. HOWEVER - You will have build these by yourself and deeply integrate with your project that mileage will greatly vary

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages