LuX wrote:Alright. There's something wrong there. I personally haven't used the while command, at least knowing what is does.
Here's how I would do it:In addition to that, take a look at where "r" is defined as 30. At the top of compose frame, which means what ever you do to "r" it's going to become 30 anyways, so nothing will happen to it. You need to put that "r = 0;" under the initialization as you have done with the Box variables.Code: Select all
/*Drawing the Box*/ int y = boxY; while( y < boxY + boxHeight ) { int x = boxX; while( x < boxX + boxWidth ) { gfx.PutPixel( x,y,r,g,b ); x++; } y++; } if( kbd.SpaceIsPressed() && kbd.LeftIsPressed()) { r++; }
Oh, and the reason for you code crashing, I bet its because of the "while (kbd.leftispressed())" as it creates a loop which wont be exited since the left wont be unpressed in the middle of a frame.
that code is pretty much the same thing as this
Code: Select all
for( int y = boxy; y < (boxY + boxHeight); y++ )
for( int x = boxX; x < (boxX + boxWidth); x++ )
gfx.PutPixel( x, y, r, g, b );
if( kbd.SpaceIsPressed() && kbd.LeftIsPressed())
r++;
EDIT:
That was some sloppy code, I think I fixed it lol