@@ -30,29 +30,48 @@ const GraphicalPrimitive::PrimitiveType TextPrimitive::c_PrimitiveType = Primiti
30
30
const GraphicalPrimitive::PrimitiveType BitmapPrimitive::c_PrimitiveType = PrimitiveType::Bitmap;
31
31
32
32
Vector GraphicalPrimitive::WrapCoordinates (Vector targetPos, const Vector& scenePos) const {
33
- Vector drawPos = scenePos;
33
+ return targetPos + scenePos;
34
+ }
35
+
36
+ void GraphicalPrimitive::DrawTiled (BITMAP* drawScreen, const Vector& targetPos) {
37
+ DrawLineV (-targetPos + Vector (-30 , -30 ), -targetPos + Vector (30 , 30 ), {53 , 0 , 0 , 255 });
38
+ DrawLineV (-targetPos + Vector (30 , -30 ), -targetPos + Vector (-30 , 30 ), {53 , 0 , 0 , 255 });
34
39
40
+ Vector tiledTarget{targetPos};
35
41
if (g_SceneMan.SceneWrapsX ()) {
36
- float sceneWidth = static_cast <float >(g_SceneMan.GetSceneWidth ());
37
- if (targetPos.m_X <= sceneWidth && targetPos.m_X > sceneWidth / 2 ) {
38
- targetPos.m_X -= sceneWidth;
39
- }
42
+ tiledTarget.m_X = std::fmodf (targetPos.m_X , g_SceneMan.GetSceneWidth ());
40
43
}
41
- drawPos.m_X -= targetPos.m_X ;
42
-
43
44
if (g_SceneMan.SceneWrapsY ()) {
44
- float sceneHeight = static_cast <float >(g_SceneMan.GetSceneHeight ());
45
- if (targetPos.m_Y <= sceneHeight && targetPos.m_Y > sceneHeight / 2 ) {
46
- targetPos.m_Y -= sceneHeight;
45
+ tiledTarget.m_Y = std::fmodf (targetPos.m_Y , g_SceneMan.GetSceneHeight ());
46
+ }
47
+ DrawLineV (-tiledTarget + Vector (-30 , -30 ), -tiledTarget + Vector (30 , 30 ), {53 , 0 , 0 , 255 });
48
+ DrawLineV (-tiledTarget + Vector (30 , -30 ), -tiledTarget + Vector (-30 , 30 ), {53 , 0 , 0 , 255 });
49
+
50
+ float bitmapWidth = g_SceneMan.GetSceneWidth ();
51
+ float bitmapHeight = g_SceneMan.GetSceneHeight ();
52
+ int areaToCoverX = drawScreen->w ;
53
+ int areaToCoverY = drawScreen->h ;
54
+
55
+ for (int tiledOffsetX = 0 ; tiledOffsetX < areaToCoverX;) {
56
+ float destX = tiledOffsetX - tiledTarget.m_X ;
57
+
58
+ for (int tiledOffsetY = 0 ; tiledOffsetY < areaToCoverY;) {
59
+ float destY = tiledOffsetY - tiledTarget.m_Y ;
60
+ Draw (drawScreen, Vector (destX, destY));
61
+ if (!g_SceneMan.SceneWrapsY ()) {
62
+ break ;
63
+ }
64
+ tiledOffsetY += bitmapHeight;
65
+ }
66
+ if (!g_SceneMan.SceneWrapsX ()) {
67
+ break ;
47
68
}
69
+ tiledOffsetX += bitmapWidth;
48
70
}
49
- drawPos.m_Y -= targetPos.m_Y ;
50
- return drawPos;
71
+ // Draw(drawScreen, targetPos);
51
72
}
52
73
53
74
void LinePrimitive::Draw (BITMAP* drawScreen, const Vector& targetPos) {
54
- DrawLineV (targetPos + Vector (-30 , -30 ), targetPos + Vector (30 ,30 ), {53 , 0 , 0 , 255 });
55
- DrawLineV (targetPos + Vector (30 , -30 ), targetPos + Vector (-30 ,30 ), {53 , 0 , 0 , 255 });
56
75
Vector drawStart = WrapCoordinates (targetPos, m_StartPos);
57
76
Vector drawEnd = WrapCoordinates (targetPos, m_EndPos);
58
77
DrawLineEx (drawStart, drawEnd, m_Thickness, {m_Color, 0 , 0 , 255 });
0 commit comments