# introduction to C++ part 8

No replies to this topic

### #1kees2125

New Member

• Members
• 2 posts

Posted 17 March 2012 - 06:13 PM

hello everyone,

im trying to complete the introductions to C++ but i'm stuk at part 8 2A
the assignement:
• DDraw a dotted line (skip every other dot) from (0, 0) to (400, 400). Do not use the Plot function, use a pointer variable instead. Figure out what the distance between dots in memory is to make this code super simple and fast.
• Create an application that does the following:
• Move a white dot from the top-centre (say, x = 320, y = 0) to the bottom. While doing so, the dot evades obstacles.
• When the pixel below the dot is black, it goes down. Otherwise, it goes one pixel to the left if its y is an odd number, or the right if its y is an even number.
• When the pixel reaches the bottom of the screen, it returns to the top.

Make sure that the image that you use for step (a) is suitable for the other steps. Also note that even though we're moving a single pixel now, this will be an avalanche soon. For this assignment, you need to use pointers: it's a great way to read screen pixels rather than writing to them.

the first part was not to difficult, but at part 2,1 i have a problem.
becaus i don't know how to use a Sprite when i need to use the information of the image and how to use that as a veriable.

o and for part 1 of the assignement it looks like this

void Game::Tick( float a_DT )
{
int i = 0;
Pixel* address = m_Screen->GetBuffer() + 100;
for (  int* c =&i; *c < 400; *c= *c+1) address[*c * 640] = *c;
}


#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users