I am following the introduction to c++ with game development tutorial and I have problems with the assignment. The first part of the assignment I understand, but the second part I don't understand. you have to
Quote
Add a gravity influence to the calculation of the new tank's position, to make it come down automatically instead of bouncing against the top every time.
// Template, major revision 3
// IGAD/NHTV - Jacco Bikker - 2006-2009
#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{
// put your initialization code here; will be executed once
}
Sprite theSprite( new Surface("assets/ctankbase.tga"), 16 );
float SpriteX = 0;
float SpriteY = 0;
bool Visible = true;
bool DirectionX = true;
bool DirectionY = true;
void Game::Tick( float a_DT )
{
// render a single frame here
m_Screen->Clear( 0 );
if (Visible == true) theSprite.Draw( SpriteX, SpriteY, m_Screen );
// alter our coords
if (DirectionX == true)
{ // he is moving right so add to his x
SpriteX += 0.5;
if (SpriteX > 600) DirectionX = false;
}
else
{ // he is moving left so sub tract from his x
SpriteX -= 0.5;
if (SpriteX < 0) DirectionX = true;
}
if (DirectionY == true)
{ // he is going down, so he is invisible and sub tract from his y
SpriteY += 0.5;
if (SpriteY > 440) DirectionY = false;
}
else
{ // he is going up, so it is visible and add to his y
SpriteY -= 0.9;
if (SpriteY < 0) DirectionY = true;
}
}
I hope someone can help me.











