-
Notifications
You must be signed in to change notification settings - Fork 13
/
Landmark.cpp
63 lines (49 loc) · 1.37 KB
/
Landmark.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by jannik on 06.09.18.
//
#include "Landmark.h"
Landmark::Landmark(float x, float y, SDL_Color color)
{
pos.x = x;
pos.y = y;
id = color;
}
Landmark::~Landmark()
{
}
void Landmark::render(SDL_Renderer * ren)
{
int32_t radius = 5;
int32_t x = radius - 1;
int32_t y = 0;
int32_t tx = 1;
int32_t ty = 1;
int32_t err = tx - (radius << 1); // shifting bits left by 1 effectively
// doubles the value. == tx - diameter
int32_t int_pose_x = int(pos.x);
int32_t int_pose_y = int(pos.y);
while (x >= y)
{
// Each of the following renders an octant of the circle
SDL_RenderDrawPoint(ren, int_pose_x + x, int_pose_y - y);
SDL_RenderDrawPoint(ren, int_pose_x + x, int_pose_y + y);
SDL_RenderDrawPoint(ren, int_pose_x - x, int_pose_y - y);
SDL_RenderDrawPoint(ren, int_pose_x - x, int_pose_y + y);
SDL_RenderDrawPoint(ren, int_pose_x + y, int_pose_y - x);
SDL_RenderDrawPoint(ren, int_pose_x + y, int_pose_y + x);
SDL_RenderDrawPoint(ren, int_pose_x - y, int_pose_y - x);
SDL_RenderDrawPoint(ren, int_pose_x - y, int_pose_y + x);
if (err <= 0)
{
y++;
err += ty;
ty += 2;
}
if (err > 0)
{
x--;
tx += 2;
err += tx - (radius << 1);
}
}
}