Asteroid::Asteroid(Game& game) : Actor(game) { auto meshComponent = MeshComponent::Create(*this); auto mesh = game.GetAssetCache().Load<Mesh>("Meshes/AsteroidMesh.itpmesh2"); auto texture = game.GetAssetCache().Load<Texture>("Textures/Asteroid.png"); meshComponent->SetMesh(mesh); SetRotation(Random::GetFloatRange(0.0f, Math::TwoPi)); auto move = MoveComponent::Create(*this, Component::PreTick); move -> SetLinearSpeed(150.0f); move -> SetLinearAxis(1.0f); auto col = SphereCollision::Create(*this); col->SetScale(0.9f); col->RadiusFromTexture(texture); }
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); }