0
101 Oct 08, 2013 at 10:26

i am having trouble figuring out the second assignment for this week, i have been browsing devmaster, but didnt find anything. if anyone knows how to do this, please help.

#### 8 Replies

0
139 Oct 08, 2013 at 16:04

What specifically are you having trouble with? The second assignment has several parts.

0
101 Oct 09, 2013 at 11:25

i am having trouble with loading the image, i can not even start with the rest without first having an image getting loaded. when i have the image loaded, i start on the next part of the assignment. i have already made an image to use.

0
101 Oct 09, 2013 at 11:54

thanks for trying to help me out :)

0
101 Oct 09, 2013 at 11:45

ok, i figured it out, i have to convert the image to a .tga file and then load it as a sprite for some reason, devmaster is placing my code weird, but you are probably able to make that out yourself

the code to load the image is:

Sprite TheSprite( new Surface("image name"), 1);
void Game::Tick( float a_DT )
{
TheSprite.Draw( 0, 0, m_Screen);
}

0
101 Oct 09, 2013 at 12:07

well, now i am stuck on the next part of the assignment

0
101 Oct 09, 2013 at 14:10

i am now using this code:

Sprite theSprite (new Surface("image.jpg"),1);

int whiteX= 320;
int y = 1;

void Game::Tick( float a_DT )
{
theSprite.Draw(0,0, m_Screen);
Pixel* white = m_Screen->GetBuffer();
white[whiteX + (640*y)] = 0x0000ff;
if (white[whiteX + (640 * (y + 1))] == 0xff000000) y++;
if (white[whiteX + (640 * (y + 1))] == 0xff000000)
{
if(y % 2 == 0) whiteX += 1;
else whiteX -= 1;
}
}

0
101 Oct 09, 2013 at 14:11

also, how do i add these grey code blocks i see on devmaster

0
139 Oct 09, 2013 at 16:32

Code blocks can be created on the forum by indenting the code by four spaces or one tab (we use Markdown for formatting). I edited your previous posts to fix that.

So it sounds like you’ve got the basic idea. You just need to finish implementing the logic specified in the assignment. You also need to erase the previous white dot when you move it, and draw it in the new position.