Exemple #1
0
void Fingerprint::set_shape(int left, int right, int top, int bottom, int middle) {
	s_left = left;
	s_right = right;
	s_top = top;
	s_bottom = bottom;
	s_middle = middle;
	width = s_left + s_right;
	height = s_top + s_middle + s_bottom;

	if (shape_map) delete[] shape_map;
	shape_map = new float[width*height];

	generate_shape();

	/*if (dir_map) delete[] dir_map;
	dir_map = new float[width*height];

	if (dens_map) delete[] dens_map;
	dens_map = new float[width*height];

	if (master_fin_img) delete[] master_fin_img;
	master_fin_img = new float[width*height];*/
}
    void KeyboardInputSystem::process(sf::RenderWindow *window) {

        if (event_count_) {
            auto p = sf::Mouse::getPosition();
            auto window_p = window->getPosition();
            float x = p.x - window_p.x , y = p.y - window_p.y ;
            for (unsigned int i =0; i < event_count_;i++) {
                auto &key = event_pool_[i];
                switch (key.code) {
                    case  sf::Keyboard::Escape:
                        window->close();
                        break;
                    case sf::Keyboard::I:
                        // TESTING
                        generate_shape(em_, 
                                (x / rh::SCREEN_RESOLUTION_W) * 100.f,
                                (y / rh::SCREEN_RESOLUTION_H) * 100.f * rh::SCREEN_RESOLUTION_RATIO
                                );
                        break;
                    case sf::Keyboard::A:
                        em_->add_component<rh::components::Movement>(0);
                        break;
                    case sf::Keyboard::R:
                        em_->remove_component<rh::components::Movement>(0);
                        break;
                    case sf::Keyboard::D:
                        if (entities.size()) {
                            em_->remove_entity(entities.back());
                            entities.pop_back();
                        }
                    default:
                        break;
                }
            }
            event_count_ = 0;
        }
    }