Chapter 16 // Exercise 3
Place an Image on top of a Button; move both when the button is pushed. Use this random number generator from std_lib_facilities.h to pick a new location for the "image button":
#include <random>
inline int randint(int min, int max)
{
static default_random_engine ran;
return uniform_int_distribution<>{min, max}(ran);
}
Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2016/Exercise%203#include <random>
inline int randint(int min, int max)
{
static default_random_engine ran;
return uniform_int_distribution<>{min, max}(ran);
}
This one was quite straightforward. I'm a little surprised at just how easy it is to get movable buttons up and running using fltk, it's a bit of a nightmare in DirectX. I modified My_window slightly to have another button and an image and changed the move() function in widget so it actually moves it to a new location instead of adding the new location to the current one.
No comments:
Post a Comment