about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 16:21:18 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 16:21:18 -0500
commitc1cc06fa5b3ae49b7cdadf0af439f5858d8483eb (patch)
tree6422d77eb46481f73a2ac4681f861b64b2155869
parent09a36afd0731b4565dc4628114e6cd76a42e8893 (diff)
downloadlunatic-c1cc06fa5b3ae49b7cdadf0af439f5858d8483eb.tar.gz
lunatic-c1cc06fa5b3ae49b7cdadf0af439f5858d8483eb.tar.bz2
lunatic-c1cc06fa5b3ae49b7cdadf0af439f5858d8483eb.zip
Added "YOU GOT A MOON!" overlay to image
The font used is MOON GET! (https://maxigamer.deviantart.com/art/Font-MOON-GET-A-Super-Mario-Odyssey-Typeface-732847350). The name of the achievement is also printed in a config-defined font. The correct moon image is also added to the output.

Fixed issue where images wouldn't be stretched to conform to a 16:9 ratio.

The bot will no longer generate multi moons.
-rw-r--r--lunatic.cpp72
-rw-r--r--res/overlay.pngbin0 -> 17715 bytes
-rw-r--r--res/overlay.psdbin0 -> 180381 bytes
3 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);
diff --git a/res/overlay.png b/res/overlay.png new file mode 100644 index 0000000..79d863b --- /dev/null +++ b/res/overlay.png
Binary files differ
diff --git a/res/overlay.psd b/res/overlay.psd new file mode 100644 index 0000000..2f7808b --- /dev/null +++ b/res/overlay.psd
Binary files differ