How to increment by original variable?

 private void buttonDrawBalls_Click(object sender, EventArgs e) { int NumBalls = 0; int x = DISPLAY_LEFT; int y = DISPLAY_TOP; int cols = 1; int rowheight = BALL_SIZE + GAP_SIZE; Graphics paper = pictureBoxDisplay.CreateGraphics(); SolidBrush brush1 = new SolidBrush(Color.Black); NumBalls = int.Parse(NumberOfBalls.Text); if(NumBalls * (BALL_SIZE + GAP_SIZE) <= DISPLAY_WIDTH) { while(rowheight <= DISPLAY_HEIGHT) { while (cols <= NumBalls) { paper.FillEllipse(brush1, x, y, BALL_SIZE, BALL_SIZE); x += DISPLAY_LEFT + GAP_SIZE; cols++; } cols = 1; x = DISPLAY_LEFT; y += BALL_SIZE + GAP_SIZE; rowheight += 50; } } 

Here is my code atm. it draws balls within the screen of an iPhone. i want it to draw the balls until they no longer fit on the screen neatly. ive been given a constant value to use for the display height. the above code is the solution to my problem but what i want to know is how could i have incremented rowheight by itself until it reached display height(50+50+50 as opposed to rowheight+=rowheight). ball size + gap size = 50 so i just put that in to see if i could get the code to stop once it reached the display height.

i hope my question makes sense. basically i want to increment by 50 each time but get that 50 from a variable…

by theplaymaker626 via /r/csharp

Leave a Reply