Skip to content
Snippets Groups Projects
Commit 4db8244d authored by Joakim Hunskaar's avatar Joakim Hunskaar
Browse files

updated featuredemo

parent dbb5204b
No related branches found
No related tags found
1 merge request!10More button widgets
......@@ -11,7 +11,7 @@
#include "widgets/Button.h"
#include "widgets/TextInput.h"
#include "widgets/RadioButton.h"
#include "widgets/CheckBox.h"
#include "widgets/TextBox.h"
#include "widgets/RadioButton.h"
#include "widgets/CheckBox.h"
......@@ -67,6 +67,8 @@ int main(int argc, char* argv[]) {
TDT4102::TextBox b{{300, 200}, 108, 35, "TEXTBOX!"};
window.add(b);
b.setBoxColor(TDT4102::Color::dark_orange);
b.setTextColor(TDT4102::Color::green);
input.setCallback(&textChanged);
window.add(input);
......@@ -87,24 +89,6 @@ int main(int argc, char* argv[]) {
// cb.setCheckBoxColorActive(TDT4102::Color::green);
cb.setLabel("This is a");
TDT4102::RadioButton rb{{200, 200}, 100, 30, "Easy"};
window.add(rb);
rb.setLabelColor(TDT4102::Color::salmon);
rb.setRadioColor(TDT4102::Color::gold);
rb.setRadioColorHover(TDT4102::Color::lime_green);
rb.setRadioColorActive(TDT4102::Color::aquamarine);
TDT4102::CheckBox cb{{200, 300}, 120, 50, "Check"};
window.add(cb);
// cb.setLabelColor(TDT4102::Color::blue);
cb.setCheckBoxColorHover(TDT4102::Color::red);
// cb.setCheckBoxColorActive(TDT4102::Color::green);
cb.setLabel("This is a");
int x = 10;
int y = 10;
......@@ -120,8 +104,8 @@ int main(int argc, char* argv[]) {
std::vector<Ball> circles;
circles.resize(5000);
for (unsigned int i = 0; i < circles.size(); i++) {
circles.at(i).x = randint(0, window.get_width());
circles.at(i).y = randint(0, window.get_height());
circles.at(i).x = randint(0, window.width());
circles.at(i).y = randint(0, window.height());
circles.at(i).radius = randint(5, 10);
circles.at(i).xSpeed = float(randint(-400, 400)) / 100.0f;
circles.at(i).ySpeed = float(randint(-400, 400)) / 100.0f;
......@@ -166,8 +150,8 @@ int main(int argc, char* argv[]) {
bool allAtCenter = true;
for (Ball& ball : circles) {
float gravityX = (float(window.get_width()) / 2.0f) - ball.x;
float gravityY = (float(window.get_height()) / 2.0f) - ball.y;
float gravityX = (float(window.width()) / 2.0f) - ball.x;
float gravityY = (float(window.height()) / 2.0f) - ball.y;
float absoluteSpeed = std::max(std::sqrt(gravityX * gravityX + gravityY * gravityY), 3.0f);
const float gravity = 0.07f;
ball.xSpeed += (gravityX / absoluteSpeed) * gravity;
......@@ -186,7 +170,7 @@ int main(int argc, char* argv[]) {
} else if(ball.y + ball.radius < 0) {
ball.y = window.h() + ball.radius;
}*/
if ((std::abs(ball.x - float(window.get_width()) / 2.0f) > 1.0f) && (std::abs(ball.y - float(window.get_height()) / 2.0f) > 1.0f)) {
if ((std::abs(ball.x - float(window.width()) / 2.0f) > 1.0f) && (std::abs(ball.y - float(window.height()) / 2.0f) > 1.0f)) {
allAtCenter = false;
}
// window.draw_circle({int(ball.x), int(ball.y)}, ball.radius, ball.colour, TDT4102::Color::black);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment