Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

case event_char

void Engine::update_event_system()
{

    ALLEGRO_TIMEOUT timeout;
    al_init_timeout( &timeout, 0.6 );

    al_wait_for_event_until( this->queue, &this->event, &timeout );

    switch ( this->event.type )
    {
        case ALLEGRO_EVENT_TIMER:
        {
            this->ticked = true;
        }
        break;

        case ALLEGRO_EVENT_KEY_DOWN:
        {
            this->input->set_key_state( this->event.keyboard.keycode, true );
        }
        break;

        case ALLEGRO_EVENT_KEY_UP:
        {
            this->input->set_key_state( this->event.keyboard.keycode, false );
        }
        break;

        case ALLEGRO_EVENT_KEY_CHAR:
        {
          std::string chat;
          ALLEGRO_FONT *font;
          al_init_font_addon();

          font = al_load_ttf_font("data/comic.ttf", 60,0);

          ALLEGRO_USTR *string = al_ustr_new("");
          al_ustr_append_chr(string,event.keyboard.unichar);
          chat = al_cstr(string);
          this->input->set_key_state( this->event.keyboard.unichar, true );
          al_draw_textf(font,al_map_rgb(250,250,250), 10, 10, ALLEGRO_ALIGN_LEFT, chat.c_str(), NULL);
        }
        break;

        case ALLEGRO_EVENT_MOUSE_AXES:
        {
            this->input->set_mouse_coord( this->event.mouse.x, this->event.mouse.y );
        }
        break;

        case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
        {
            this->input->set_button_state( this->event.mouse.button, true );
        }
        break;

        case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
        {
            this->input->set_button_state( this->event.mouse.button, false );
        }
        break;
    }
}