void GameScene::spawn_tube_pair() { auto upper_tube = get_an_inactive_tube(); int upper_tube_pos_y{ std::rand() % 250 + 350 }; // dummy upper_tube->initialize_position((float)upper_tube_pos_y); upper_tube->setAnchorPoint(Vec2{ 1, 0 }); upper_tube->set_score(0); upper_tube->start_moving(); auto lower_tube = get_an_inactive_tube(); float lower_tube_pos_y{ (float)upper_tube_pos_y - TUBE_UPPER_LOWER_GAP }; lower_tube->initialize_position(lower_tube_pos_y); lower_tube->setAnchorPoint(Vec2{ 1, 1 }); lower_tube->setFlippedY(true); lower_tube->set_score(1); lower_tube->start_moving(); }
int main(void) { uint8_t retval; while (1) { init(); for (retval = 0; retval < 50; retval++) { /* wait x ms until inputs are debounced */ wait_for_timer_tick(); } if (direction == ASK) { if (position() == OPEN) direction = DOWN; else direction = UP; } if (!get_key_press(START_BT)) { goto unintended_wakeup; } led1(GREEN); start_moving(direction); retval = 1; while (run_enable && retval) { wait_for_timer_tick(); retval = pwm_ramp_up(); if (get_key_press(START_BT)) { disable(); } } while (run_enable) { wait_for_timer_tick(); if (get_key_press(START_BT)) { disable(); } } retval = 1; while (retval) { wait_for_timer_tick(); retval = pwm_ramp_down(); } stop_moving(); unintended_wakeup: led1(OFF); deinit(); sleep(); } /* never reached */ return 0; }