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

Pages: [1]
1
General / Re: Where to calculate collisions and physics
« on: March 18, 2019, 07:30:43 pm »
Welcome! :)

The general philosophy (with SFML) is to keep rendering (the actual drawing/displaying of stuff) and game logic separated from each other as much as possible.
As such, you'd be doing the physics & collision handling in the update phase.

For your game loop the most important part (as explained in the book) is to do the updating inside the inner while loop. As that one gets executed for as long and as many times as possible, before the next frame should be rendered (see also the famous Fix Your Timestep article).

Thank you so much eXpl0it3r!

2
General / Re: loadFromFile always returns false (SFML 2.5.1 64-bit)
« on: March 18, 2019, 10:25:48 am »
I had this same issue. The first problem was like Hapax said, be carefull where you put your dll's or lib's. The other problem came with the linker, where you put all your sfml-system.lib... or with the -d or/and with -s. I mixed them and in some of them I put .lib and in others .dll, so that caused all my problems, you probably have read this, but here's the documentation for the linker and so:

https://www.sfml-dev.org/tutorials/2.5/start-vc.php

Review the linkers and the options you have put, hope it helps.

3
General / Where to calculate collisions and physics
« on: March 18, 2019, 10:18:32 am »
Hi! This is my first question in the forum as I'm new in SFML. I usually use Libgdx as 2d gamedev framework and I wanted to start coding games in C++. In Libgdx there's a method call render(), where you get the input, do updates and then render, all in the same method, but in a specific order.

Now I have this nice game loop that I've learnt from the book SFML Game Development:
void Game::run(){
      sf::Clock clock;
      sf::Time timeSinceLasUpdate;
     
      while(this->renderWindow.isOpen()){
              this->handleEvents();
              timeSinceLastUpdate += clock.restart();

              while(timeSinceLastUpdate > this->timePerFrame){
                      timeSinceLastUpdate -= this->timePerFrame;
                      this->handleEvents();
                      this->update(this->timePerFrame);
              }

              this->render();
      }
}
 

Where timePerFrame is 1.f/fps, and in my case fps=60.f.
Where handleInput() is a method that detects the input of the player (mouse and keys)
Where update() is the method to update positions of player...
Where render() is the method that draws on screen.

Here is my question, given my game loop (btw, if there's any problem with it, pls tell me), where should I calc if entities are colliding and the physics? It's better in the handleInput, update or render?

I think handleInput is not really the method where it should be calculated, but due to the frame I've been using, I'm not too sure.

Thanks!

Pages: [1]
anything