HeHe I'm done lesson 9's assignment!

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MrTuong
Posts: 3
Joined: February 2nd, 2013, 9:29 am

HeHe I'm done lesson 9's assignment!

Post by MrTuong » February 2nd, 2013, 9:42 am

Hi Hi :D , I can move color in the box but the result seems like opposite with the result of Chili
Attachments
Chili DirectX Framework change box color - Copy.zip
(35.88 KiB) Downloaded 209 times

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: HeHe I'm done lesson 9's assignment!

Post by LuX » February 3rd, 2013, 7:56 pm

Hmm... Can you specify the problem? I'm kinda lazy.

Looks cool for sure.
ʕ •ᴥ•ʔ

BestMan
Posts: 6
Joined: February 12th, 2013, 10:23 am

Re: HeHe I'm done lesson 9's assignment!

Post by BestMan » February 27th, 2013, 3:30 pm

Check it out!
Attachments
Chili DirectX Framework change box color - Copy.rar
(343.32 KiB) Downloaded 185 times

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: HeHe I'm done lesson 9's assignment!

Post by albinopapa » February 28th, 2013, 6:33 am

Code: Select all

void Game::ComposeFrame()
{
	int y = boxY;  // dividing int's where the result is less than 1 but greater than 0 will return 0
                           //  if you want a decimal use float instead of int

   while( y < boxY + boxWidth )
   {
      int x = boxX;   // if you change the int y to float y you might want to do the same here.

      while( x < boxX + boxWidth )
      { 
		  if (x/b==y/b)
          //  It didn't seem to make a difference, but you forgot the { } 
                          gfx.PutPixel( x,y,(x+50)*b/2/(y+50)*2,(y+50)/(x+50)*b+100,(y+50)*(x+50)/2/b);
		  else
         // again missing the { }
			  gfx.PutPixel(x,y,x+b,b-y,max(x,y));
                  x++;
      }
      y++;
   }
	// adjust the size of the box
	if( kbd.SpaceIsPressed() )
	{
                // missing the { } and b never changes, b = 400 the entire program so this code 
                // never gets executed.
		if ( b<3 || b>800)f*=-1;
		b+= f*2;
	}

	if( kbd.EnterIsPressed() )
	{
		boxWidth = boxWidth + 3;
	}
	
	// move the box
	if( kbd.RightIsPressed() )
	{
		boxX = boxX + 3;
	}

	if( kbd.LeftIsPressed() ) 
	{
		boxX = boxX - 3;
	}

	if( kbd.UpIsPressed() )
	{
		boxY = boxY - 3;
	}

	if( kbd.DownIsPressed() )
	{
		boxY = boxY + 3;
	}
	
	
}
not sure if it was your intention, but the window height is only 600 (0 - 599) so

Code: Select all

 
 while( y < boxY + boxWidth )
will make the box draw off the bottom of the screen, I'm not sure why there wasn't an error from drawing off the screen.

https://www.dropbox.com/s/psuv1y1rg6rsf ... ompare.png
Left half is what is displayed with x and y being int and right half is x and y being float.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply