| 44 | } |
| 45 | |
| 46 | TestWorld::TestWorld() : World() { |
| 47 | //weak ref test |
| 48 | { |
| 49 | WeakRef<SharedObject> weak; |
| 50 | { |
| 51 | Ref<SharedObject> obj(new SharedObject()); |
| 52 | weak = obj; |
| 53 | } |
| 54 | assert(weak.isNull()); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | //setup inputs |
| 59 | Ref<RavEngine::InputManager> is = new RavEngine::InputManager(); |
| 60 | //setup control mappings |
| 61 | is->AddAxisMap("MoveForward", SDL_SCANCODE_W); |
| 62 | is->AddAxisMap("MoveForward", SDL_SCANCODE_S, -1); //go backwards |
| 63 | is->AddAxisMap("MoveRight", SDL_SCANCODE_A, -1); //go left |
| 64 | is->AddAxisMap("MoveRight", SDL_SCANCODE_D); //turn left |
| 65 | is->AddAxisMap("MoveUp", SDL_SCANCODE_SPACE); |
| 66 | is->AddAxisMap("MoveUp", SDL_SCANCODE_LSHIFT, -1); |
| 67 | is->AddAxisMap("LookUp", Special::MOUSEMOVE_YVEL,-1); //turn up |
| 68 | is->AddAxisMap("LookRight", Special::MOUSEMOVE_XVEL,-1); |
| 69 | is->AddAxisMap("SpawnTest", SDL_SCANCODE_G); //press g to spawn objects |
| 70 | is->AddActionMap("ResetCam", SDL_SCANCODE_R); |
| 71 | is->AddActionMap("SampleFPS",SDL_SCANCODE_T); |
| 72 | |
| 73 | //game controller input |
| 74 | is->AddAxisMap("MoveForward", ControllerAxis::SDL_CONTROLLER_AXIS_LEFTY, -1); |
| 75 | is->AddAxisMap("MoveRight", ControllerAxis::SDL_CONTROLLER_AXIS_LEFTX); |
| 76 | is->AddAxisMap("LookRight", ControllerAxis::SDL_CONTROLLER_AXIS_RIGHTX, -10); |
| 77 | is->AddAxisMap("LookUp", ControllerAxis::SDL_CONTROLLER_AXIS_RIGHTY, -10); |
| 78 | is->AddAxisMap("MoveUp", ControllerAxis::SDL_CONTROLLER_AXIS_TRIGGERLEFT); |
| 79 | is->AddAxisMap("MoveUp", ControllerAxis::SDL_CONTROLLER_AXIS_TRIGGERRIGHT,-1); |
| 80 | is->AddAxisMap("SpawnTest", ControllerButton::SDL_CONTROLLER_BUTTON_A); |
| 81 | is->AddActionMap("ResetCam", ControllerButton::SDL_CONTROLLER_BUTTON_START); |
| 82 | is->AddActionMap("SampleFPS", ControllerButton::SDL_CONTROLLER_BUTTON_Y); |
| 83 | |
| 84 | |
| 85 | //bind controls |
| 86 | auto playerscript = player->Components().GetComponent<PlayerScript>().get(); |
| 87 | is->BindAxis("MoveForward", playerscript, &PlayerScript::MoveForward); |
| 88 | is->BindAxis("MoveRight", playerscript, &PlayerScript::MoveRight); |
| 89 | is->BindAxis("MoveUp", playerscript,&PlayerScript::MoveUp); |
| 90 | is->BindAxis("LookUp", playerscript,&PlayerScript::LookUp); |
| 91 | is->BindAxis("LookRight", playerscript, &PlayerScript::LookRight); |
| 92 | |
| 93 | is->BindAxis("SpawnTest", this, &TestWorld::SpawnEntities); |
| 94 | is->BindAction("ResetCam", this, &TestWorld::ResetCam, ActionState::Pressed); |
| 95 | |
| 96 | //test unbinding |
| 97 | is->UnbindAxis("SpawnTest", this, &TestWorld::SpawnEntities); |
| 98 | is->UnbindAction("ResetCam", this, &TestWorld::ResetCam, ActionState::Pressed); |
| 99 | |
| 100 | is->BindAxis("SpawnTest", this, &TestWorld::SpawnEntities); |
| 101 | is->BindAction("ResetCam", this, &TestWorld::ResetCam, ActionState::Pressed); |
| 102 | is->BindAction("SampleFPS",this, &TestWorld::SampleFPS,ActionState::Pressed); |
| 103 | //is->BindAction("Click", click, ActionState::Released); |
nothing calls this directly
no test coverage detected