int main() { while (1) { scanf("%s",inst); if (inst[0] == '8') break; pos = 0; int over = 0; A = B = 0; while (1) { switch (inst[pos]) { case '0':command0();break; case '1':command1();break; case '2':command2();break; case '3':command3();break; case '4':command4();break; case '5':command5();break; case '6':command6();break; case '7':command7();break; case '8':over = 1;break; default:over = 1;break; } if (over || pos > 255) break; } printf("%s\n",inst); } return 0; }
int _tmain(int argc, _TCHAR* argv[]) { ActiveObjectEngine active_objevt_engine; std::unique_ptr<ICommand> command1(new SleepDelayCommand( 1000, &active_objevt_engine, 'A' ) ); std::unique_ptr<ICommand> command2(new SleepDelayCommand( 5000, &active_objevt_engine, 'B' ) ); std::unique_ptr<ICommand> command3( new SleepDelayCommand( 500, &active_objevt_engine, 'C' ) ); std::unique_ptr<ICommand> command4(new SleepDelayCommand( 10, &active_objevt_engine, 'E' ) ); std::unique_ptr<ICommand> command5(new SleepDelayCommand( 4500, &active_objevt_engine, 'D' ) ); active_objevt_engine.AddCommand( std::move( command1 ) ); active_objevt_engine.AddCommand( std::move( command2 ) ); active_objevt_engine.AddCommand( std::move( command3 ) ); active_objevt_engine.AddCommand( std::move( command4 ) ); active_objevt_engine.AddCommand( std::move( command5 ) ); active_objevt_engine.Run(); return 0; }
void command3(int keycode, t_box *box) { if (keycode == KEY_SPACE) box->b_mouse = box->b_mouse == 1 ? 0 : 1; else if (keycode == KEY_PAD7) { box->var = ((4 / box->add_z) - (4 / (box->add_z / 1.1))) / 2; box->pos_x -= box->var; box->pos_y -= box->var; box->add_z /= 1.1; } else if (keycode == KEY_PAD8) { box->var = ((4 / box->add_z) - (4 / (box->add_z * 1.1))) / 2; box->add_z *= 1.1; box->pos_x -= box->var; box->pos_y -= box->var; } else if (keycode == KEY_CLEAR) reset(box); command4(keycode, box); }