sfml

SFML Error loading font under Windows

和自甴很熟 提交于 2019-12-01 13:30:39
问题 I've been trying to develop a cross-platform application for Windows and Linux using SFML. Everything's been going fine so far, except that the Windows version cannot seem to load fonts. I have no issues under Linux however. I did my research and made sure the file was in place, according to where I was executing from, but sf::Font::loadFromFile still returns false. Here's the code: sf::Font _font; sf::Text _text; if (!(_font.loadFromFile("resources/fonts/arial.ttf"))) { std::cerr << "Error

How can I set gravity using this code?

喜你入骨 提交于 2019-12-01 11:35:21
I am trying to make a game and am stuck on gravity..... In the following code a rectangle stands for a player and when I press up key it moves in y-axis but when I activate gravity on it (i.e resetting its previous position) it does not animate (i.e. It does not jumps) instead it just stays in its position. I am using SFML library of C++ and that's a game development tool. Please Help! #include <SFML/Graphics.hpp> int main(){ sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Gravity"); sf::RectangleShape rectangle; rectangle.setSize(sf::Vector2f(100, 100)); rectangle.setFillColor(sf::Color

Mouse position with screen scrolling in SFML

孤街浪徒 提交于 2019-12-01 01:58:06
Im trying to create a block placement with snap to grid. Everything is working, and in my head this should update the position of the mouse relative to the window each frame right? sf::Vector2i position = sf::Mouse::getPosition(window.mywindow); //get position int xSnap = (position.x / gridWidth) * gridWidth; int ySnap = (position.y / gridHeight) * gridHeight; But i also have screen scrolling using if (player.playerSprite.getPosition().x + 16 > screenDimensions.x / 2) position.x = player.playerSprite.getPosition().x + 16; else position.x = screenDimensions.x / 2; //Y if (player.playerSprite

How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

放肆的年华 提交于 2019-11-30 20:56:36
hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D in cMake , i get a bunch of errors when building it(i was going through the steps in the readme.txt, but onfortunately, theyre for Visual C++...) so im wondering hot to set this up as i guess a library (.lib or .a) and use it in my project(my friend passed me his library and when i loaded it in and tried #include ing the box2D headers, they didnt read at all(i got a list of undefined errors) also his box2d was i believe made for

How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

旧街凉风 提交于 2019-11-30 17:20:36
问题 hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D in cMake, i get a bunch of errors when building it(i was going through the steps in the readme.txt, but onfortunately, theyre for Visual C++...) so im wondering hot to set this up as i guess a library (.lib or .a) and use it in my project(my friend passed me his library and when i loaded it in and tried #include ing the box2D

Alternative to texelFetch? [duplicate]

牧云@^-^@ 提交于 2019-11-30 14:58:39
问题 This question already has answers here : OpenGL Texture Coordinates in Pixel Space (3 answers) Closed 2 years ago . I'm getting into GLSL and need some help with texture lookups. I'm trying to use a texture for storage but I cannot get "proper" texture lookups. I would prefer using the usual texture2D method (using GLSL 1.2) but the results are not good enough. Using texture2D: Using texelFetch: Now obviously something is wrong with the first one. Here is what I am trying to do (yes sizes are

Movement Without Framerate Limit C++ SFML

拟墨画扇 提交于 2019-11-30 10:04:02
I'm working an making a game in SFML right now, but I am getting stuck on movement without a framerate limit. Right now the only way I have figured out how to get consistent framerate on all computers is by using window.setFramerateLimit(30); I want to find a way to not have a framerate cap so it does look better on better computers and so that if anybody has a really slow computer, they can still play the game. What would be the best way to do this. You should pass the time that has elapsed since the last frame to the object that needs to be drawn, and then calculate the space the object has

configure SFML for clion (windows)

拜拜、爱过 提交于 2019-11-29 23:08:16
问题 i am setting up a work environment for a school project on my windows computer. We are going to make a basic game using c++ and CLion. To make a game i need to use the SFML library. I have followed a few tutorials but i cant seem to get it to work anyway. I have: Downloaded CLion and configured it with MinGW Downloaded SFML and copied its "findSFML.cmake" file to a new directory in my project that i call cmake_modules. Edited my CMakeLists.txt file so it looks like this: cmake_minimum

I can not open and image using the SFML library

試著忘記壹切 提交于 2019-11-29 17:32:25
I am having trouble opening the test15.bmp. When I run the program it tries to open a window but crashes. The problem line as much as I could understand is image.loadFromFile(...); Exception thrown at 0x50E82CC4 (vcruntime140.dll) in MandelbrotProject.exe: 0xC0000005: Access violation reading location 0x00741000. This is the exception I get when I use image.loadFromFile("test15.bmp") instead of the absolute path. I have linked and included everything as it was described in the SFML tutorials. https://www.sfml-dev.org/tutorials/2.5/start-vc.php I am using Visual C++(2017)-32 bit SFML and

Movement Without Framerate Limit C++ SFML

心不动则不痛 提交于 2019-11-29 15:08:15
问题 I'm working an making a game in SFML right now, but I am getting stuck on movement without a framerate limit. Right now the only way I have figured out how to get consistent framerate on all computers is by using window.setFramerateLimit(30); I want to find a way to not have a framerate cap so it does look better on better computers and so that if anybody has a really slow computer, they can still play the game. What would be the best way to do this. 回答1: You should pass the time that has