int main(int argc, char** argv) { boost::scoped_ptr<DSP::MonoFilter<double> > low_wah_filter(create_low_wah()); boost::scoped_ptr<DSP::MonoFilter<double> > high_wah_filter(create_high_wah()); boost::mt19937 engine(0); boost::normal_distribution<double> generator; boost::variate_generator<boost::mt19937, boost::normal_distribution<double> > binded(engine, generator); for(int i = 0; i < size; ++i) { in[i] = binded(); } low_wah_filter->process(in, out, size); high_wah_filter->process(in, temp, size); for(int i = 0; i < size; ++i) { out[i] += temp[i]; } std::ofstream infile("in_time_varying.raw", std::ofstream::binary); infile.write(reinterpret_cast<const char*>(in), size * sizeof(double)); std::ofstream outfile("out_time_varying.raw", std::ofstream::binary); outfile.write(reinterpret_cast<const char*>(out), size * sizeof(double)); return 0; }
bool Babar::check_unbind() { Rect rectdown = m_rel_pos; rectdown.y += 1; if (binded() ) { if (!CollisionsManager::is_down_coll (m_bind->down_collision_type (m_rel_pos) ) && !CollisionsManager::is_down_coll (m_bind->down_collision_type (rectdown) ) ) { PRINT_DEBUG (1, "AIUYGFSGDF"); unbind(); return true; } // si on descend et qu'on rencontre un static, on s'y arrete if (m_bind->is_going_down() && CollisionsManager::is_down_coll (gCollision->get_matrix()->down_collision_type (position() ) ) ) { unbind(); PRINT_DEBUG (1, "oIURHGELIUHFGELIUGHLEISHRGHSDLIUH"); PRINT_DEBUG (1, "oIURHGELIUHFGELIUGHLEISHRGHSDLIUH"); PRINT_DEBUG (1, "oIURHGELIUHFGELIUGHLEISHRGHSDLIUH"); PRINT_DEBUG (1, "oIURHGELIUHFGELIUGHLEISHRGHSDLIUH"); return true; } } return false; }
Babar::~Babar() { PRINT_CONSTR (1, "Destruction de Babar"); if ( binded() ) { unbind(); } }
void Babar::unbind() { if (binded() ) { m_pos.x = m_rel_pos.x + m_bind->position().x; m_pos.y = m_rel_pos.y + m_bind->position().y; m_bind->unbind(); m_bind = NULL; } }
PointContainer generate(long size) { PointContainer data; boost::mt19937 engine(static_cast<long unsigned int>(clock())); boost::normal_distribution<double> generator; boost::variate_generator<boost::mt19937, boost::normal_distribution<double> > binded(engine, generator); for(long i = 0; i < size; ++i) { Point point; for(long j = 0; j < POINTSIZE; ++j) { point.push_back(binded()); } data.push_back(point); } return data; }
bool Babar::is_on_something() { if (binded() ) { return CollisionsManager::is_down_coll (m_bind->down_collision_type (m_rel_pos) ); } else { return CollisionsManager::is_down_coll (gCollision->get_matrix()->down_collision_type (position() ) ); } }
void Babar::move (int x, int y) { if (binded() ) { m_rel_pos.x += x; m_rel_pos.y += y; } else { m_pos.x += x; m_pos.y += y; } }
Rect Babar::position() const { if (binded() ) { Rect res = m_bind->position(); res.x += m_rel_pos.x; res.y += m_rel_pos.y; res.h = m_pos.h; res.w = m_pos.w; return res; } else { return m_pos; } }
bool Babar::can_go_down() const { CollisionsMatrix *plop; Rect pos; if (binded() ) { plop = m_bind; pos = m_rel_pos; } else { plop = gCollision->get_matrix(); pos = m_pos; } return (Keyboard::GetInstance()->key_down (k_jump) && Keyboard::GetInstance()->key_down (k_down) && CollisionsManager::is_down_coll (plop->down_collision_type (pos) ) ) && !plop->double_collision (pos); }
void Babar::go_down() { m_pos.y += 2 * BOX_SIZE; m_speed.y += BOX_SIZE; if (binded() ) { while (CollisionsManager::is_down_coll (m_bind->down_collision_type (m_rel_pos) ) ) { if (m_bind->double_collision (m_rel_pos) ) { m_rel_pos.y -= BOX_SIZE; break; } else { m_rel_pos.y += BOX_SIZE; } } } else { while (CollisionsManager::is_down_coll (gCollision->get_matrix()->down_collision_type (m_pos) ) ) { if (gCollision->get_matrix()->double_collision (m_pos) ) { m_pos.y -= BOX_SIZE; break; } else { m_pos.y += BOX_SIZE; } } } unbind(); PRINT_TRACE (1, "Descente d'une plateforme"); }
void Babar::update_pos() { if (locked() ) return; m_phase++; unsigned int coll; /* cas où le sprite descend */ for (int speed_y = m_speed.y ; speed_y > 0 ; speed_y -= BOX_SIZE) { check_unbind(); gCollision->update_babar_platforms(); coll = gCollision->get_matrix()->down_collision_type (position() ); if (binded() ) { coll |= m_bind->down_collision_type (m_rel_pos); } if (CollisionsManager::is_down_coll (coll) ) { speed_y = 0; m_speed.y = 0; if ( !binded() ) { m_last_pos = m_pos; } } else { move (0, BOX_SIZE); //~ if (position().y + position().h > (int)gStatic->StaticData_height()) //~ m_rel_pos.y = gStatic->StaticData_height() - m_pos.h; } } /* cas où le sprite monte */ for (int speed_y = m_speed.y ; speed_y < 0 ; speed_y += BOX_SIZE) { check_unbind(); gCollision->update_babar_platforms(); coll = gCollision->get_matrix()->up_collision_type (position() ); if (binded() ) { coll |= m_bind->up_collision_type (m_rel_pos); } if (CollisionsManager::is_up_coll (coll) ) { speed_y = 0; m_speed.y = 0; } else { move (0, -BOX_SIZE); } } /* cas où le sprite va � droite */ for (int speed_x = m_speed.x ; speed_x > 0 ; speed_x -= BOX_SIZE) { check_unbind(); gCollision->update_babar_platforms(); move (0, -BOX_SIZE); coll = gCollision->get_matrix()->right_collision_type (position() ); if (binded() ) { coll |= m_bind->right_collision_type (m_rel_pos); } if (CollisionsManager::is_right_coll (coll) ) { speed_x = 0; m_speed.x = 0; } else { move (+BOX_SIZE, 0); // On avance! } if (!is_on_something() ) // s'il n'y avait pas de pente montante, on revient move (0, BOX_SIZE); if (!is_on_something() ) // gestion de la pente descendante move (0, BOX_SIZE); if (!is_on_something() ) move (0, -BOX_SIZE); // ce n'était pas une pente descendante, on revient do_stay_in_level(); } /* cas où le sprite va � gauche */ for (int speed_x = m_speed.x ; speed_x < 0 ; speed_x += BOX_SIZE) { check_unbind(); gCollision->update_babar_platforms(); move (0, -BOX_SIZE); coll = gCollision->get_matrix()->left_collision_type (position() ); if (binded() ) { coll |= m_bind->left_collision_type (m_rel_pos); } if (CollisionsManager::is_left_coll (coll) ) { speed_x = 0; m_speed.x = 0; } else { move (-BOX_SIZE, 0); // On avance! } if (!is_on_something() ) // s'il n'y avait pas de pente montante, on revient move (0, BOX_SIZE); if (!is_on_something() ) // gestion de la pente descendante move (0, BOX_SIZE); if (!is_on_something() ) move (0, -BOX_SIZE); // ce n'était pas une pente descendante, on revient } do_stay_in_level(); }