void test_ship_structure_should_delete_object_if_colliding_too_much() { sc::phi::Sector sector; test::TestObjectFactory objectFactory( sector ); test::TestObject* testObject_1( objectFactory.createTestShip( sc::phi::ObjectProperties( m_start_coordinate, m_speed_moving, 0.0, 10, 1 ) ) ); sc::phi::Model colliderModel( m_start_coordinate_2, m_speed_moving, 0.0, 0.0, 10.0, 1 ); sc::phi::CollisionEvent collisionEvent( sc::phi::ObjectRef( nullptr ), colliderModel ); for ( int i( 0 ); i < 100; ++i ) { testObject_1->dispatchEvent( collisionEvent ); } TS_ASSERT( testObject_1->isDeleted() ); }
void PlayerController::tick(float deltaTime) { sgde::CollisionEvent collisionEvent( playerControlledBox ->getRenderableSprite() ->getSprite() .getPosition() .x + 32, playerControlledBox ->getRenderableSprite() ->getSprite() .getPosition() .y + 32); /* Check for collisions. */ sgdc::DynamicArray< sgds::ICollidable* > collisions = std::move( sgds::SceneManager::getSceneGraph().getCollisions( playerControlledBox->getCollidable())); for (unsigned int i = 0; i < collisions.getSize(); i++) { if (playerControlledBox ->getCollidable() ->collides(collisions.get(i)->getBounds())) { collisions.get(i) ->getActor() ->getEventDispatcher() ->dispatch(&collisionEvent); } } /* Move the actor's sprite. */ if (sgdi::Input::getInstance().isDown(sgdi::Input::Type::A)) { playerControlledBox->move( -PLAYER_CONTROLLER_MOVEMENT_SPEED, 0.0f); } if (sgdi::Input::getInstance().isDown(sgdi::Input::Type::D)) { playerControlledBox->move( PLAYER_CONTROLLER_MOVEMENT_SPEED, 0.0f); } if (sgdi::Input::getInstance().isDown(sgdi::Input::Type::W)) { playerControlledBox->move( 0.0f, -PLAYER_CONTROLLER_MOVEMENT_SPEED); } if (sgdi::Input::getInstance().isDown(sgdi::Input::Type::S)) { playerControlledBox->move( 0.0f, PLAYER_CONTROLLER_MOVEMENT_SPEED); } }