Lesson 9 homework inquiry
-
- Posts: 19
- Joined: September 6th, 2012, 6:53 pm
Re: Lesson 9 homework inquiry
loopx and loopy define where each color pixel goes right? So changing loopx and loopy will change the placement of the pixels. That's all I can deduce because variables x, y and size define the area on the screen that the pixels are made.
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: Lesson 9 homework inquiry
can u post the circle code u'r working on? i have no idea why u keep changing size x and size y or loop x and loop y to change the size of a circle shape(circle have same width/height, loopx,loopy,sizex,sizey are both separate modifiers of either height or width,none of them changes them both.)
i'm asking u again what tells the drawing function how big the sizex,size y will be or how big the loopx,loop y should be?
i'm asking u again what tells the drawing function how big the sizex,size y will be or how big the loopx,loop y should be?
-
- Posts: 19
- Joined: September 6th, 2012, 6:53 pm
Re: Lesson 9 homework inquiry
Code: Select all
#include "Game.h"
Game::Game( HWND hWnd,const KeyboardServer& kServer )
: gfx ( hWnd ),
kbd( kServer ),
x( 1 ),
y( 1 ),
sizex( 798 ),
sizey( 598 ),
r( 200 )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::ComposeFrame()
{
loopy = y;
while( loopy < y + sizey )
{
loopx = x;
while( loopx < x + sizex )
{
gfx.PutPixel( loopx,loopy,
((loopx-r)*(loopx-r)+(loopy-r)*(loopy-r)) /100,
((loopx-500)*(loopx-500)+(loopy-400)*(loopy-400)) /100,
((loopx-300)*(loopx-300)+(loopy-100)*(loopy-100)) /100 );
loopx++;
}
loopy++;
}
if( kbd.DownIsPressed() )
{
loopx = loopx - 3;
}
}
-
- Posts: 19
- Joined: September 6th, 2012, 6:53 pm
Re: Lesson 9 homework inquiry
Alright i think i figured it out, this is what i got now:
It seems to work but it doesn't really look like what chili got, that might just be because it lags really bad though.
Is this the right route i shouldve been taking the whole time lol?
Code: Select all
#include "Game.h"
Game::Game( HWND hWnd,const KeyboardServer& kServer )
: gfx ( hWnd ),
kbd( kServer ),
x( 1 ),
y( 1 ),
sizex( 798 ),
sizey( 598 ),
divide( 100 ),
r( 200 )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::ComposeFrame()
{
loopy = y;
while( loopy < y + sizey )
{
loopx = x;
while( loopx < x + sizex )
{
gfx.PutPixel( loopx,loopy,
((loopx-r)*(loopx-r)+(loopy-r)*(loopy-r)) /divide,
((loopx-500)*(loopx-500)+(loopy-400)*(loopy-400)) /divide,
((loopx-300)*(loopx-300)+(loopy-100)*(loopy-100)) /divide );
loopx++;
}
loopy++;
}
if( kbd.DownIsPressed() )
{
divide = divide - 3;
}
}
Is this the right route i shouldve been taking the whole time lol?
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: Lesson 9 homework inquiry
well i first need to apolagise to u for missunderstanding lol,i thought u were talking about the circle shape not the colored circles inside that rectangle, that's why i asked where u see circle drawing in that code:)) but yeah the variable that need to be changed are pixel colors and respectively the color modifier variables .
i just tested it and it looks pretty much like chili's drawing:)
i just tested it and it looks pretty much like chili's drawing:)
-
- Posts: 19
- Joined: September 6th, 2012, 6:53 pm
Re: Lesson 9 homework inquiry
That's alright you helped allot anyhow I don't know if i would have noticed which variable to change without you telling me over and over that the variables i was using didn't do anything does it lag for you too or could that be my computer, please don't say my computer because i just got it lol
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: Lesson 9 homework inquiry
hmm it lags a bit once the circles grow really big and ther's just a few edges on screen.
but don't worry about it chili will teach us lots of new ways to do the drawing faster in the future so it will work on most pc's that are not really old(i mean those made before 2005 or so)
but don't worry about it chili will teach us lots of new ways to do the drawing faster in the future so it will work on most pc's that are not really old(i mean those made before 2005 or so)
-
- Posts: 19
- Joined: September 6th, 2012, 6:53 pm
Re: Lesson 9 homework inquiry
Ohkay good i was a little scared there, thanks allot for the help virus