Skip to content

Instantly share code, notes, and snippets.

View Groogy's full-sized avatar

Groogy Groogy

View GitHub Profile
playButtonAction = [this](GUI::Component& sender) { // The argument is not needed actually, just common in .NET and Java
startGame(); // Member function in the state that defines this action
};
std::shared_ptr<GUI::Button> playButton(new GUI::Button("Play", playButtonAction));
myContainer.pack(playButton);
@Groogy
Groogy / button.hpp
Last active December 13, 2015 18:09
namespace GUI
{
class BOOK_MENUS_API Button : public GUI::Component
{
public:
Button(const std::string& text, const FontHolder& fonts, const TextureHolder& textures, std::function<void> callback);
bool isSelectable() const;
void handleEvent(const sf::Event& event);
@Groogy
Groogy / button.cpp
Last active December 13, 2015 18:48
void GUI::Button::activate()
{
GUI::Component::activate();
if(mIsToggle)
mSprite.setTexture(mPressedTexture)
if (mCallback)
mCallback();
describe Tyr::Application do
context "minial application" do
subject { Tyr::Application.new() }
it "should load the default module" do
subject.num_controllers.should == 0
subject.num_renderers.should == 0
subject.load(:default)
subject.modules.should include(:default)
subject.num_controllers.should == 1
Application::loadModule(const tyr::Module& module)
{
myModules.push_back(module);
module.initialize(this);
}
static VALUE load(VALUE self, VALUE name)
{
tyr::Module module(RSTRING(name)->ptr);
auto application = tyr::toNative<tyr::Application>(self);
// SFML.memory_usage
VALUE rbSFML::GetMemoryUsage( VALUE aSelf )
{
void* table = rb_mod_const_at( aSelf, 0 );
VALUE list = rb_const_list( table );
GetMemoryUsageInfo info;
info.memoryUsage = 0;
info.listPointer = RARRAY_PTR( list );
info.listLength = RARRAY_LEN( list );
void Player::fire(const sf::Vector2f& direction)
{
if(myFireCooldown <= sf::Time::Zero)
{
float angle = std::atan2(direction.y, direction.x);
sf::Vector2f centerPosition = getCenterPosition();
myFireCooldown = Player::FireCooldown;
myMuzzleTimer = Player::MuzzleTime;
myProjectiles->createProjectile(centerPosition + direction * Size / 2.f, rad2Degrees(angle), sf::Color::White);
static int ToRubyHashIterator( VALUE aKey, VALUE aValue, VALUE anExtra )
{
ToRubyHashInfo* info = ( ToRubyHashInfo* )anExtra;
std::string sym;
if( rb_type( aKey ) == T_SYMBOL )
sym = rb_id2name( SYM2ID( aKey ) );
else
sym = StringValueCStr( aKey );
describe "rb_obj_instance_variables" do
it "gets an array with instance variable names" do
o = ObjectTest.new
@o.rb_obj_instance_variables(o).should include(:@foo)
end
end
[groogy@isa rubinius]$ bin/mspec ci -t r -d spec
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]
..FEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFEEE............E...FE.EEE.........E.EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...................................................................................................................................................................................................................................................................................................................................................................E.E.....................................E.....E...EE........................................................................F.........................................E............mkfifo: cannot create fifo ‘/home/groogy/.rubies/rubini