Jump to content


Need help with the 'Introduction to C++ with Game Development: Part 2' assignment


4 replies to this topic

#1 mrhelloworld

    New Member

  • Members
  • Pip
  • 3 posts

Posted 17 December 2012 - 12:17 PM

Hi,

I just started following the 'Introduction to C++ with Game Development' series of articles. Got stuck very soon though. Because English is not my mother tongue so I have some difficulties understanding some parts. In the assignment of part 2 you have to draw 'IGAD' on an 8x8 grid. Did that, using straight lines only. Well, kind of. I only got 'IGA' on my sheet. :P Here is what I drew on paper:

http://imageshack.us...1217131005.jpg/

Anyway, following the article, I thought I should have something like this (only for 'I'):



#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
m_Screen->Clear( 0 );
m_Screen->Print( "I", 2, 2, 0xffffff );
m_Screen->Line( 2, 9, 66, 9, 0xffffff );
m_Surface->Line( 60, 80, 60, 560, 0xffffff );
}


#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5340 posts
  • LocationSanta Clara, CA

Posted 17 December 2012 - 06:04 PM

So, what is your actual question?
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 mrhelloworld

    New Member

  • Members
  • Pip
  • 3 posts

Posted 19 December 2012 - 10:49 AM

View PostReedbeta, on 17 December 2012 - 06:04 PM, said:

So, what is your actual question?
The code I wrote to draw 'IGA' is not correct. And I would not know how to write the right code. So I am kinda stuck.

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 5340 posts
  • LocationSanta Clara, CA

Posted 19 December 2012 - 06:24 PM

It looks like you're on the right track. I don't think the Print() call belongs there as you're supposed to draw it using lines only. You've got the m_Surface->Line() call for the 'I' there; now you just need to add additional lines for the 'G' and 'A'. Just keep going.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 mrhelloworld

    New Member

  • Members
  • Pip
  • 3 posts

Posted 22 December 2012 - 07:48 PM

View PostReedbeta, on 19 December 2012 - 06:24 PM, said:

It looks like you're on the right track. I don't think the Print() call belongs there as you're supposed to draw it using lines only. You've got the m_Surface->Line() call for the 'I' there; now you just need to add additional lines for the 'G' and 'A'. Just keep going.
That is very logical, thank you.

The thing is that it brings another issue op for me. The code I have right now (following your advise) is this (only drawing one line, the 'I'):

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
    m_Screen->Clear( 0 );
    m_Screen->Line( 2, 9, 66, 9, 0xffffff );
    m_Surface->Line( 60, 80, 60, 560, 0xffffff );
}
That gives me the same errors (error C2065: 'm_Surface' : undeclared identifier and error C2227: left of '->Line' must point to class/struct/union/generic type) though and nothing is drawn.

I do notice though that " m_Screen->Line( 2, 9, 66, 9, 0xffffff );" does draw a horizontal line, so I tried that for drawing the 'I', so:

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
    m_Screen->Clear( 0 );
    m_Screen->Line( 60, 80, 60, 560, 0xffffff );
}
That does not give me any errors, but draws an empty window?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users