MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / OnUserCreate

Method OnUserCreate

examples/TEST_QuickGUI.cpp:97–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96public:
97 bool OnUserCreate() override
98 {
99 // Horizontal Slider
100 guiSlider1 = new olc::QuickGUI::Slider(guiManager,
101 { 30.0f, 10.0f }, { 246.0f, 10.0f }, 0, 100, 50);
102 // Diagonal Slider!
103 guiSlider2 = new olc::QuickGUI::Slider(guiManager,
104 { 20.0f, 20.0f }, { 120.0f, 120.0f }, 0, 100, 50);
105 // Vertical Slider
106 guiSlider3 = new olc::QuickGUI::Slider(guiManager,
107 { 10.0f, 30.0f }, { 10.0f, 230.0f }, 0, 100, 50);
108
109 // Theme colour slider - Red
110 guiThemeColourR = new olc::QuickGUI::Slider(guiManager,
111 { 150.0f, 30.0f }, { 246.0f, 30.0f }, 0, 255, 0);
112 // Theme colour slider - Green
113 guiThemeColourG = new olc::QuickGUI::Slider(guiManager,
114 { 150.0f, 50.0f }, { 246.0f, 50.0f }, 0, 255, 0);
115 // Theme colour slider - Blue
116 guiThemeColourB = new olc::QuickGUI::Slider(guiManager,
117 { 150.0f, 70.0f }, { 246.0f, 70.0f }, 0, 255, 128);
118
119 // Labels for theme colour sliders
120 guiLabelR = new olc::QuickGUI::Label(guiManager,
121 "Red:", { 80.0f, 22.0f }, { 50.0f, 16.0f });
122 guiLabelG = new olc::QuickGUI::Label(guiManager,
123 "Green:", { 80.0f, 42.0f }, { 50.0f, 16.0f });
124 guiLabelB = new olc::QuickGUI::Label(guiManager,
125 "Blue:", { 80.0f, 62.0f }, { 50.0f, 16.0f });
126
127 // Customize how the labels look
128 guiLabelB->nAlign = olc::QuickGUI::Label::Alignment::Right;
129 guiLabelG->nAlign = olc::QuickGUI::Label::Alignment::Right;
130 guiLabelG->bHasBorder = true;
131 guiLabelR->nAlign = olc::QuickGUI::Label::Alignment::Right;
132 guiLabelR->bHasBorder = true;
133 guiLabelR->bHasBackground = true;
134
135 // Some Buttons, 1 is just a thing, 2 has its text updated and 3 resets the theme
136 guiButton1 = new olc::QuickGUI::Button(guiManager,
137 "Button 1", { 30.0f, 150.0f }, { 100.0f, 16.0f });
138 guiButton2 = new olc::QuickGUI::Button(guiManager,
139 "Button 2", { 30.0f, 170.0f }, { 100.0f, 16.0f });
140 guiButton3 = new olc::QuickGUI::Button(guiManager,
141 "Reset Theme", { 30.0f, 190.0f }, { 100.0f, 16.0f });
142
143 // A CheckBox, switches between sprite or decal drawing
144 guiCheckBox1 = new olc::QuickGUI::CheckBox(guiManager,
145 "Use Decals", false, { 30.0f, 210.0f }, { 100.0f, 16.0f });
146
147 // TextBox, allows basic text entry
148 guiTextBox1 = new olc::QuickGUI::TextBox(guiManager,
149 "", { 150.0f, 140.0f }, { 100.0f, 16.0f });
150 guiTextBox2 = new olc::QuickGUI::TextBox(guiManager,
151 "0.04", { 150.0f, 160.0f }, { 100.0f, 16.0f });
152
153 listExample.push_back("Item 1");
154 listExample.push_back("Item 2");

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected