31
General / should i use inline functions?
« on: February 28, 2012, 03:30:57 pm »
As a general rule, leave such decisions to the compiler until you have reason not to.
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.
don't know whether it's a good idea to introduce bugs in chapters and fix them later. For some topics this can be meaningful because of the learning effect, but doing this too much gives the impression that your tutorial is incorrect. Maybe you had better fix them in the original code (given this doesn't complicate it as hell).
GetFrameTime() is a relict, it has been removed from SFML. You should use sf::Clock directly. By the way, even though this is out of scope for the tutorial, I have developped a StopWatch class which can be paused.
The other thing I've noticed is that any time I try to make changes to the game class I end up with more errors than I'd like.
void GameObjectManager::UpdateAll()
{
std::map<std::string,VisibleGameObject*>::const_iterator itr = _gameObjects.begin();
float timeDelta = Game::GetWindow().GetFrameTime();
...
if(timeDelta > 0.1f) timeDelta = 0.0f;
Quote from: "Razzeeyy"Maybe other people can offer a better wayIf anyhow possible, I'd probably use a myObj instead of myObj*. This is problematic for polymorphic objects, but one approach is to use smart pointers like std::unique_ptr or specialized containers like boost::ptr_map...
Serapth, oh yeah... that was stupid confuse about coordinates...
But I lack at math knowledge at this point so I can't model an elegant collision response model... Maybe you can advice me what to read on this topic?
BTW: If you want to take a look at current state of my project https://github.com/Razzeeyy/Re-tank-dev
The code organization (mostly) "inspired" by your great tutorial )
Serapth, Hi again.
I came back with couple of questions about collision (actually about response to collisions...)
So as far as you know I'm making the tank game...
The collision between tank and bullet was easy to made.
But the collision between tanks more complicated.
My Collision model is something like this:
1)Test Collisions in pairs through all objects
2) if collision happend, then execute Collide method of objects and pass references to the collided objects, one to another
3) objects decide on their own what to do on collision
This model is enough for bullets, but for collision between tanks.. em.. Should I pass the coordinates of obstacle or... something else?
I tried to make a 'simple' tank collision (just forcing the forward movement to act as backward on collision so we make step out of collision..) but I don't think this is an elegant solution.
Serapth, i mean how to install SFML 1.6 or 2.0 to Visual Studio 2010 Professional. All instructions that i have found were made with Express, where all menus were fully different. But i will test those instructions today...
int _tmain(int argc, _TCHAR* argv[])
{
sf::Window app = sf::Window(sf::VideoMode(800,600,32),"test");
sf::Event event;
for(;;)
{
while (app.PollEvent(event))
{
if (event.Type == sf::Event::Closed)
app.Close();
if (event.Type == sf::Event::KeyPressed)
{
if (event.Key.Code == sf::Keyboard::Key::Escape)
app.Close();
}
}
sf::Uint32 elapsedTime = app.GetFrameTime();
if(elapsedTime == 0.0f) app.SetTitle("Lots");
else
{
std::ostringstream ost;
ost << 1000.f / elapsedTime;
app.SetTitle(ost.str());
}
app.Display();
}
}