-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.cpp
57 lines (43 loc) · 1.55 KB
/
Main.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
# include <Siv3D.hpp>
void Main()
{
// Set background color to sky blue
Scene::SetBackground(ColorF{ 0.8, 0.9, 1.0 });
// Create a new font
const Font font{ 60 };
// Create a new emoji font
const Font emojiFont{ 60, Typeface::ColorEmoji };
// Set emojiFont as a fallback
font.addFallback(emojiFont);
// Create a texture from an image file
const Texture texture{ U"example/windmill.png" };
// Create a texture from an emoji
const Texture emoji{ U"🐈"_emoji };
// Coordinates of the emoji
Vec2 emojiPos{ 300, 150 };
// Print a text
Print << U"Push [A] key";
while (System::Update())
{
// Draw a texture
texture.draw(200, 200);
// Put a text in the middle of the screen
font(U"Hello, Siv3D!🚀").drawAt(Scene::Center(), Palette::Black);
// Draw a texture with animated size
emoji.resized(100 + Periodic::Sine0_1(1s) * 20).drawAt(emojiPos);
// Draw a red transparent circle that follows the mouse cursor
Circle{ Cursor::Pos(), 40 }.draw(ColorF{ 1, 0, 0, 0.5 });
// When [A] key is down
if (KeyA.down())
{
// Print a randomly selected text
Print << Sample({ U"Hello!", U"こんにちは", U"你好", U"안녕하세요?" });
}
// When [Button] is pushed
if (SimpleGUI::Button(U"Button", Vec2{ 640, 40 }))
{
// Move the coordinates to a random position in the screen
emojiPos = RandomVec2(Scene::Rect());
}
}
}