1
Graphics / Re: Texture not working from header c++
« on: July 31, 2014, 12:39:13 am »This works
You should try passing the render window as a reference instead of a pointer to `GameObject::Draw` like you're doing here.
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.
This works
Stuttering isn't a result of any form of "time step method", it is the cause of something else in your code.
Just forget about using a fixed time step and focus on what matters: getting your game into a playable, fun state. That article is obviously geared to people who have passed that stage and are trying to polish their game, if what is mentioned in that article is even required, as I already explained above. Out of all the projects presented here on the SFML forum I haven't seen one that can realistically benefit from having a fixed time step, which is why I hate it when people recommend that article to beginners who are obviously struggling with other things and should better spend their time on those instead of this.
Do not recommend that article to beginners, please. Whoever understands why they would benefit from something like that will find it themselves when the time comes.
Just throw out that stuff, use a simple delta update and enjoy finishing the rest of your game. There are much more important issues... seriously...
As for optimizations, I'd recommend just learning to profile your code to speed up the things that need to be done and see what is unnecessary so you can get rid of them. The only way to make code faster, is to gather experience and get a feeling for writing efficient code. I'm helping you by not helping you, if that makes any sense.
If you want to follow that infamous article, you should really follow it all the way and more importantly understand what is said there. It was even explicitly mentioned that you would encounter stuttering if you didn't perform proper interpolation. I changed the last 2 methods of your player code to:
Unfortunately that code isn't complete so all I can really do is guess and say you should try doing things differently in your update() function and see what happens. As just one example, we can't see where left/right get set.
Plus, for semi-subjective issues like this, it's extremely helpful (even more so than usual) if we can compile your code and actually see the problem.
I tried to compile your app but there are some errors, to be exact:
/home/kuba/cpp/smooth-movement-test-master/src/Application.cpp: In member function ‘void Application::popWorld()’:
/home/kuba/cpp/smooth-movement-test-master/src/Application.cpp:45:21: error: ‘cont_worlds’ was not declared in this scope
private:
ltbl::LightSystem *ls;
ltbl::Light_Point *testLight;
World::World(sf::RenderWindow &rwin)
{
ls = new ltbl::LightSystem(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(screenWidth), static_cast<float>(screenHeight))), &rwin, "res/images/lightFin.png", "res/shaders/lightAttenuationShader.frag");
testLight = new ltbl::Light_Point();
testLight->SetCenter(Vec2f(400.0f, 400.0f));
testLight->SetRadius(500.05f);
testLight->m_size = 30.f;
testLight->m_spreadAngle = 2.f * static_cast<float>(M_PI);
testLight->m_softSpreadAngle = 0.f;
testLight->CalculateAABB();
ls->AddLight(testLight);
}
void World::draw(sf::RenderWindow &rwin)
{
rwin.setView(vw_main);
//Drawing logic (background, player, etc)
ls->RenderLights();
ls->RenderLightTexture();
}
sf::Clock animateTime;
if (animateTime.getElapsedTime().asMilliseconds() >= 50)
{
player.setTextureRect(sf::IntRect(src.x, src.y, spritesheet.getSize().x / 4, spritesheet.getSize().y / 4));
animateTime.restart();
}
Failed to create texture, its internal size is too high
for (int i = 0; i < spr_objs.size(); i++)
{
spr_objs[i].move(-(dt * 0.3f), 0);
}
cmake -G "MinGW Makefiles" .
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
CMake Error at cmake/Config.make:62 (message):
Unsupported compiler
Call Stack (most recent call first):
CMakeLists.txt:20 (include)
-- Configuring incomplete, errors occurred!
> g++
g++: fatal error: no input files
compilation terminated
You always have to preserve additional time that has been passed. My game right now runs at 100 updates per second and with the new Time stuff in SFML2 it runs very smooth at a constant rate of 100 updates per second.
const int gameTime = 10;
sf::Clock gameClock;
...
while (gameClock.GetElapsedTime().AsMilliseconds() > gameTime)
{
gameClock.Restart();
//update game
}
tim@debian:/usr/lib/x86_64-linux-gnu$ file libGL.so
libGL.so: broken symbolic link to `libGL.so.1'
tim@debian:/usr/lib/x86_64-linux-gnu$ cd ..
tim@debian:/usr/lib$ file libGL.so.1
libGL.so.1: symbolic link to `libGL.so.290.10'