Asteroid::Asteroid(Game& game) : Super(game) { auto mesh = MeshComponent::Create(*this); auto meshPtr = game.GetAssetCache().Load<Mesh>("Meshes/AsteroidMesh.itpmesh2"); mesh->SetMesh(meshPtr); auto movement = MoveComponent::Create(*this, Component::PreTick); movement->SetLinearSpeed(150.0f); movement->SetLinearAxis(1.0f); SetRotation(Random::GetRotation()); SetScale( 0.1f ); }
Laser::Laser(Game & game) :Actor(game) { //Create a sprite component auto sprite = SpriteComponent::Create(*this); auto assetCache = game.GetAssetCache(); auto texture = assetCache.Load<Texture>("Textures/Laser.png"); sprite->SetTexture(texture); //Set Movement auto move = MoveComponent::Create(*this, Component::PreTick); move->SetLinearSpeed(600.0f); move->SetLinearAxis(1.0f); //Set SphereCollision auto coll = SphereCollision::Create(*this); coll->RadiusFromTexture(texture); coll->SetScale(0.9f); }
void InputComponent::OnLinearAxis(float value) { SetLinearAxis(value); }