Best way to use an output function in a loop?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Lividpayment
Posts: 10
Joined: April 13th, 2020, 8:47 pm

Best way to use an output function in a loop?

Post by Lividpayment » February 21st, 2021, 10:17 pm

Code: Select all

for (int curIndex = 0; curIndex < 1000; ++curIndex)
	{
		if (e.GetType() == Mouse::Event::Type::LPress)
		{
			pixelsX[curIndex] = wnd.mouse.GetPosX() - 5;
			pixelsY[curIndex] = wnd.mouse.GetPosY() - 5;
		}
		gfx.PutPixel(pixelsX[curIndex], pixelsY[curIndex], Colors::Red);
	}
---------------------------------------
Basically I have this code, and for every iteration of the loop I want to put some information into the array and then output this infomation as a graphics function, but i'm having trouble getting the loop to remember the previous iteration.

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

Re: Best way to use an output function in a loop?

Post by albinopapa » March 7th, 2021, 9:30 am

Depends on what the desired outcome you are looking for.

For instance, using the Mouse::Event::LPress means that for all 1000 iterations of the current frame, you are putting a pixel in the current position.

I think what you are wanting is more of a each frame, check if left mouse pressed, then place pixel.
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