Hey guys!
Code:
namespace CM_Commander
{ class Hexagon
{ RectangleShape pixel
; List
<List
<RectangleShape
>> hexfieldL
; int width
; int height
; int pos_x
= 0; int pos_y
= 0; public Hexagon
(Vector2f size
) { this.width = (int)size
.X; this.height = (int)size
.Y; pixel
= new RectangleShape
(new Vector2f
(1,
1)); } public void DrawHexagon
(RenderWindow renderwindow
) { for(int y
= pos_y
; y
<= pos_y
+height
; y
++) for(int x
= pos_x
; x
<= pos_x
+width
; x
++) { if (y
== pos_y
|| y
== pos_y
+height
) { pixel
.Position = new Vector2f
(x, y
); renderwindow
.Draw(pixel
); continue; } pixel
.Position = new Vector2f
(pos_x, y
); renderwindow
.Draw(pixel
); pixel
.Position = new Vector2f
(pos_x
+width, y
); renderwindow
.Draw(pixel
); } } }} Above you can see my class for drawing a rectangle (actually its the base for drawing a hexagon later - need to start with a simpler form first)
I have a big issue with memory here - It seems that the drawing of the rectangle affects FPS or Game Speed at all...because moving the map around (which u can't see) lags hardcore.
In fact I have a bunch of opinions how this memory littering occurs.
1) I always thought the Draw Buffer (if there exists one) will be cleared after .Display() has been called - if not I might produce a big load of buffer positions due the fact that I draw a simple rectangle out of a lot of rectangle objects.
2) Drawing a rectangle is anyhow a big issue anyway - but can't find a way to draw a pixel which is hierached by "Drawable" Class
What u guys know about these problems?