Lesson 9 homework inquiry

The Partridge Family were neither partridges nor a family. Discuss.
KillerDonkey
Posts: 19
Joined: September 6th, 2012, 6:53 pm

Re: Lesson 9 homework inquiry

Post by KillerDonkey » September 11th, 2012, 3:27 pm

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.

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: Lesson 9 homework inquiry

Post by viruskiller » September 11th, 2012, 3:42 pm

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?

KillerDonkey
Posts: 19
Joined: September 6th, 2012, 6:53 pm

Re: Lesson 9 homework inquiry

Post by KillerDonkey » September 11th, 2012, 4:00 pm

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;
		 }
}
Alright this is the last thing i tried and i knew that it wouldnt work but i thought that loopx and loopy determine the size.

KillerDonkey
Posts: 19
Joined: September 6th, 2012, 6:53 pm

Re: Lesson 9 homework inquiry

Post by KillerDonkey » September 11th, 2012, 4:08 pm

Alright i think i figured it out, this is what i got now:

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;
		 }
}
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?

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: Lesson 9 homework inquiry

Post by viruskiller » September 11th, 2012, 4:15 pm

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:)

KillerDonkey
Posts: 19
Joined: September 6th, 2012, 6:53 pm

Re: Lesson 9 homework inquiry

Post by KillerDonkey » September 11th, 2012, 4:54 pm

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 :P does it lag for you too or could that be my computer, please don't say my computer because i just got it lol

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: Lesson 9 homework inquiry

Post by viruskiller » September 11th, 2012, 5:12 pm

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)

KillerDonkey
Posts: 19
Joined: September 6th, 2012, 6:53 pm

Re: Lesson 9 homework inquiry

Post by KillerDonkey » September 12th, 2012, 2:49 pm

Ohkay good i was a little scared there, thanks allot for the help virus :)

Post Reply