4 posts
stb_tilemap_editor.h
I am trying to use stb_tilemap_editor.h with sfml, And I have a few doubts

1.
 1 2 if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) stbte_mouse_button(tilemap, mousePos.x, mousePos.y, 0, 1, 0, 0); 

I am using this piece of code for clicking should I write a else condition for unclicking?

2.
  1 2 3 4 5 6 7 8 9 10 while(window.pollEvent(event)) { if (event.type == sf::Event::MouseMoved) { mousePos = sf::Vector2i(event.mouseMove.x, event.mouseMove.y); mousePos.x = mousePos.x * (640.0f / window.getSize().x); mousePos.y = mousePos.y * (480.0f / window.getSize().y); stbte_mouse_move(tilemap, mousePos.x, mousePos.y, 0, 0); } } 

because of the while loop the above code becomes laggy, how do i handle this?

Thanks.
Mārtiņš Možeiko
2374 posts / 2 projects
stb_tilemap_editor.h
Edited by Mārtiņš Možeiko on
1) Yes, you need to call stbte_mouse_button with 5th argument set to 0 ("false") when mouse button is released.
This is easy to see from SDL example function stb_tilemap_editor have in source code: https://github.com/nothings/stb/b...master/stb_tilemap_editor.h#L4099

2) What is this while loop? Aren't you handling all other events also in this loop? In what place have you put this loop?
4 posts
stb_tilemap_editor.h
yes, I got it to work, but have to run in release mode. for it to fast, in debug its very slow, I dont know why..
Mārtiņš Možeiko
2374 posts / 2 projects
stb_tilemap_editor.h
That's because in "debug" mode typically build system doesn't turn on compiler optimizations to make debugging easier. Without optimizations generated code is slow. That's expected behavior.