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

Pages: [1]
1
General / Displaying a game tileset which includes animated components.
« on: January 17, 2019, 07:23:45 pm »
Hi, so I was reading the SFML Vertex Array/Tileset articles and I understand them fairly well. But I had some concerns on how to implement/display a tilemap that can contain possible animated portions of a map. (Stuff like fountains on the walls, spikes on the floor, etc).

Right now I have a sprite animation class which is written like this:

https://github.com/Rietty/Hellcraft/blob/master/Animation.hpp
https://github.com/Rietty/Hellcraft/blob/master/Animation.cpp

And it works perfectly fine for my purposes.

What is the best way to animate different things on the map? Should I just include an empty tile in the tilemap/vertex array and then iterate over it later with an animated sprite? Is there a better way?

Any advice would be appreciated.

2
Aha!
That worked! Thank you so much. :)

3
Hi, so I have this project I'm working on, and here is the relevant code:

https://github.com/Rietty/Hellcraft/blob/master/Menu.hpp

The issue is that when I first start my application, the sprite shows up fully (aka all frames flash across the screen) before it goes to animation/frame cycling. Obviously this isn't something that should be happening and I'm a bit stumped to resolve it. I've tried moving various initialization calls around as well as having a Boolean check for when stuff is initialized however this does not seem to solve the problem.

What else can I try and is there something else I'm missing?

Currently it looks like this for the first second after loading:

(click to show/hide)


4
General / Re: [C++] Setting font crashes app / doesn't display.
« on: May 10, 2018, 03:48:36 pm »
I saw your callstack on Discord.

You're using a MinGW x64 compiler with SJLJ exception model, yet the binaries we provide uses the SEH exception model for x64 MinGW.

Either switch your compiler or build from source.

This is built from source however.

5
General / [C++] Setting font crashes app / doesn't display.
« on: May 10, 2018, 04:27:49 am »
Hi! So I have this code:



// SFML Headers.
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Image.hpp>
#include <fstream>


int main() {
    // Create the main window
    sf::RenderWindow *window = new sf::RenderWindow(sf::VideoMode(800, 600), "Window");
    sf::Font font; // Needed.
    if (!font.loadFromFile("font.ttf")){
        std::ofstream out("log.txt");
        out << "Failed to load font from file!" << std::endl;
        out.close();
    }
    // Loads it from file and sets it.
    while (window->isOpen()) {
        // Process events.
        sf::Event event;
        while (window->pollEvent(event)) {  
            // Close window: Exit.
            if (event.type == sf::Event::Closed) {
                window->close();
            }
        }
        // Clear screen.
        window->clear();
        sf::Text text;
        text.setFont(font);
        text.setString("Hello, Menu!");
        text.setCharacterSize(24);
        text.setFillColor(sf::Color::White);
        text.setStyle(sf::Text::Bold | sf::Text::Underlined);
        // Update the window.
        window->display();
    }
    return EXIT_SUCCESS;
}
 


For some reason this never displays anything in my window, which is just black box with no text at all. And in my main application (this is a minimal example.) it crashes on this line:



text.setFont(font);
 


I'm not sure why nothing displays? I followed tutorial to the word.

Pages: [1]