• -- Coming Soon
  • contact@radlabgaming.com

Introducing some code snippets!

Introducing some code snippets!

Hey everyone!

We made some major changes this week and are excited to introduce code snippets into our blog as well as changing some of our classes to template based!

To start we decided to change our dropdown system into a template where we can not only take sprites but we can also take text, custom shapes, or whatever we would need.

Here is a small sample piece for our new dropdown system:

 template<class TypeClass>
 void dropdown<TypeClass>::addDropDownItem(TypeClass tempDropdown, sf::Vector2f resolution)
 {
 this->dropdownListVector.push_back(tempDropdown);
 this->dropdownListDataVector.push_back(resolution);
 }
 template<class TypeClass>
 void dropdown<TypeClass>::setObjectTexture(std::string filepath, sf::Vector2f scale)
 {
 this->objectTexture.loadFromFile(filepath);
 this->object.setTexture(this->objectTexture);
 this->object.setScale(scale);
 }

As you can see it is a extremely simple template class but it does allow us to add multiple types without a ton of different functions and etc. Overall I am very excited to continue using the system and to expand our other classes into template based classes allowing us to remove tons of useless code and add more opportunities for different types.

Thanks!
RadLab

blanet910@yahoo.com

Leave a Comment