I am trying to finish every C++ that IGAD posted here on this website.
I currently am in tutorial part 4: loops
It's going okay but I've ran into a problem with the assignment..
This is the assignment:
Create a nestedfor loop (a loop inside a loop) that draws 10 lines of 13 tank
This is what I had before I started the assigment (so after I completed all the steps of the tutorial)
// 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 );
void Game::Tick( float a_DT )
{
// render a single frame here
m_Screen->Clear( 0 );
or( int i=0; i < 13; i++ )
{
theSprite.SetFrame( i );
theSprite.Draw( i*50, 0, m_Screen );
}
}
So the assignment tells me to create a second loop within the current loop: for( int i=0; i < 13; i++ )
I have no idea how to do this.. I have tried several things such as trying to implement a second variable into the loop, which (i think?) should look as the following code:
// 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;[/size][/font]
void Game::Init()
{
// put your initialization code here; will be executed once
}
Sprite theSprite( new Surface("assets/ctankbase.tga"), 16 );
void Game::Tick( float a_DT )
{
// render a single frame here
m_Screen->Clear( 0 );
for( int i=0; int u=0; i < 13; u < 10; i++; u++; )
{
theSprite.SetFrame( i );
theSprite.Draw( i*50, u*50, m_Screen );
}
}
As you can see, I have added the variable u in the loop and changed the 0 in theSpite.Draw into u*50.. yet I get a build error.
Help much appreciated
Cheers !












