Counting rows and columns

delphi, hexagonal-tiles, opengl

Solution

You are not reseting row in your loop, IHMO it should look like this

  RowOffset:= -0.9;
  Row := 0;
      while Row < TotalRow do

Problem

I am drawing hexagons in a map. For some reason it will only create one row. I believe my loops are correct. If on ``` glVertex3f(((sin(i/6.0*2*PI))/10)+RowOffset,((cos(i/6.0*2*pi))/10)+CollumnOffset,-2); ``` i swap `RowOffset` and `CollumnOffset` then I get one column. ``` procedure TFCreatemap.menuArea; var I: Integer; Row,Collumn: Integer; RowOffset,CollumnOffset: double; TotalRow,TotalCollumn:integer; begin Row := 0; Collumn:= 0; CollumnOffset := -0.9; TotalRow := 11; TotalCollumn := 11; while Collumn < TotalCollumn do begin CollumnOffset := CollumnOffset+0.4; RowOffset:= -0.9; while Row < TotalRow do begin RowOffset := RowOffset+ 0.2; glBegin(GL_POLYGON); for I := 0 to 6 do begin glVertex3f(((sin(i/6.0*2*PI))/10)+RowOffset,((cos(i/6.0*2*pi))/10)+CollumnOffset,-2); end; {for} glEnd; Row:= Row+1; end; {end collumns with} Collumn:= Collumn+1; end; {end rows with} end; ``` also my left/top is -1 to 1

Original source