about summary refs log tree commit diff stats
path: root/lunatic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lunatic.cpp')
-rw-r--r--lunatic.cpp72
1 files changed, 26 insertions, 46 deletions
diff --git a/lunatic.cpp b/lunatic.cpp index ca3140a..497c648 100644 --- a/lunatic.cpp +++ b/lunatic.cpp
@@ -43,65 +43,45 @@ int main(int argc, char** argv)
43 std::string imagePath = config["images"].as<std::string>() 43 std::string imagePath = config["images"].as<std::string>()
44 + "/" + imageName; 44 + "/" + imageName;
45 45
46 Magick::Image overlay;
47 overlay.read("res/overlay.png");
48
49 Magick::Image moonColor;
50 moonColor.read("res/" + ach.color + ".png");
46 51
47 try 52 try
48 { 53 {
54 // Start with the game image
49 Magick::Image image; 55 Magick::Image image;
50 image.read(imagePath); 56 image.read(imagePath);
51 image.transform("1600x900"); 57
52 image.scale("160x90"); 58 // Stretch and pixelate it
59 image.transform("1600x900!");
60 image.scale("80x45");
53 image.scale("1600x900"); 61 image.scale("1600x900");
62
63 // Add the text and moon image from Odyssey
64 image.composite(overlay, 0, 0, Magick::OverCompositeOp);
65 image.composite(moonColor, 672, 85, Magick::OverCompositeOp);
66
67 // Add the name of the achievement
68 image.fontPointsize(36);
69 image.fillColor("white");
70 image.font("@" + config["font"].as<std::string>());
71 image.annotate(
72 ach.title,
73 Magick::Geometry(0, 0, 0, 672),
74 Magick::GravityType::NorthGravity);
75
76 // Output for debug
54 image.magick("png"); 77 image.magick("png");
55 image.write("output.png"); 78 image.write("output.png");
56 } catch (const Magick::WarningCoder& ex) 79 } catch (const Magick::WarningCoder& ex)
57 { 80 {
58 // Ok 81 // Ok
59 } 82 }
60
61
62
63
64
65
66
67
68
69
70 83
71 84 std::string header = "YOU GOT A MOON!";
72
73 /*
74
75 // Reload achievements list every time in case it has been updated
76 std::vector<std::string> achievements;
77 std::ifstream datafile(config["achievements"].as<std::string>());
78 if (!datafile.is_open())
79 {
80 std::cout << "Could not find achievements file." << std::endl;
81 return 1;
82 }
83
84 std::string line;
85 while (getline(datafile, line))
86 {
87 if (line.back() == '\r')
88 {
89 line.pop_back();
90 }
91
92 achievements.push_back(line);
93 }
94
95 std::uniform_int_distribution<int> dist(0, achievements.size() - 1);
96 std::string achievement = achievements[dist(rng)];*/
97
98 std::string header;
99 if (std::bernoulli_distribution(1.0 / 50.0)(rng))
100 {
101 header = "YOU GOT A MULTI MOON!";
102 } else {
103 header = "YOU GOT A MOON!";
104 }
105 85
106 std::string action = header + "\n" + ach.title; 86 std::string action = header + "\n" + ach.title;
107 action.resize(140); 87 action.resize(140);