public Ground(Game game, Camera cam) : base(game) { cube = new GameObject(game, "cube", game.Content, cam); game.Components.Add(cube); translation = rotation = scaling = Matrix.Identity; cube.translation = Matrix.CreateTranslation(0, -10, -10); cube.scale = Matrix.CreateScale(20); }
public virtual void Draw(GraphicsDevice device, Camera camera) { boneTransforms = new Matrix[model.Bones.Count]; model.CopyBoneTransformsTo(boneTransforms); foreach (ModelMesh modelmesh in model.Meshes) { foreach (BasicEffect effect in modelmesh.Effects) { effect.World = modelmesh.ParentBone.Transform * rotation * scale * world * translation; effect.View = camera.view; effect.Projection = camera.projection; effect.TextureEnabled = true; effect.Texture = texture; effect.EnableDefaultLighting(); } modelmesh.Draw(); } }
public GameWorld(Game game, ContentManager cm, Camera cam) : base(game) { content = cm; camera = cam; components = game.Components; physworld = new PhysicsWorld(game); modelmgr = new ModelManager(game, cam); level = new Level(); components.Add(physworld); components.Add(modelmgr); sfx = game.Content.Load<SoundEffect>(@"Audio/punch"); punch = sfx.CreateInstance(); punch.IsLooped = false; sfx = game.Content.Load<SoundEffect>(@"Audio/bgm"); bgm = sfx.CreateInstance(); bgm.IsLooped = true; bgm.Play(); }
public Player(Game game, GameObject body, GameObject fist, Vector3 pos, Camera cam) : base(game) { this.body = body; this.fist = fist; damage = 2; health = 10; forward = back = left = right = 0; fistX = 0; fistY = 0; fistZ = radius; camX = 0; camY = 0; camZ = radius * 10; isAttacking = false; canAttack = true; fistDefaultAngle = 0.5f; angle = fistDefaultAngle; speed = (2 * MathHelper.Pi) * 2; //Set body GameObject parameters setPosition(pos); body.physobj.coltype = PhysicsObject.ColliderType.player; //Set fist GameObject parameters fist.setScale(0.5f); new Vector3(fistX + body.physobj.position.X, fistY + body.physobj.position.Y, fistZ + body.physobj.position.Z); fist.setPosition(fistPosition); fist.physobj.coltype = PhysicsObject.ColliderType.player; prevFistPos = fistPosition; fist.physobj.isStatic = true; camera = cam; setCamera(); }
// Check the boundries of the landscape and move back the camera if it was out in any direction. private void checkCameraBoundries(Vector3 oldPosition, Camera camera) { if (XoutOfBounds(camera.position.X / scale)) { camera.position.X = oldPosition.X; } if (ZoutOfBounds(camera.position.Z / scale)) { camera.position.Z = oldPosition.Z; } if (heightAtPoint(camera.position.X / scale, camera.position.Z / scale) * scale > camera.position.Y - camera.height) { camera.position.Y = heightAtPoint(camera.position.X / scale, camera.position.Z / scale) * scale + camera.height; } }
protected override void Initialize() { Window.Title = "Lab 4"; camera = new Camera(this); base.Initialize(); }
protected override void Initialize() { Window.Title = "Lab 4"; camera = new Camera(this); mazeLandscape = new MazeLandscape(this,mazeDimension,mazeSeed); player = new Player(this); sphere = new Sphere(Content.Load<Model>("sphere"), this); camera.setStartingPosView(); //testModel = Content.Load<Model>("woodsphere_obj"); base.Initialize(); }
protected override void LoadContent() { // Create the camera camera = new Camera(this); sun = new Sun(this); landscape = new Landscape(this); // must init first. landscape.shader_option = 0; player = new Player(this); enemyController = new EnemyController(this); allBalls.Add(player); foreach(Enemy e in enemyController.enemies){ allBalls.Add(e); } camera.position = player.pos; this.score = 0; this.music = 100; this.target_score = 30; // Create an input layout from the vertices base.LoadContent(); }
private void Start() { m_mainCamera = Camera.main; m_enemyWaveManager.OnWaveNumberChanged += EnemyWaveManager_OnWaveNumberChanged; SetWaveNumberText($"{UtilsClass.FirstLetterToUpper(GameManager.Instance.WaveDisplayName)} {m_enemyWaveManager.GetWaveNumber()}"); }
public ModelManager(Game game, Camera cam) : base(game) { camera = cam; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here camPos = new Vector3(20, 20, 20); camView = -Vector3.UnitZ - Vector3.UnitX - Vector3.UnitY; camUp = Vector3.UnitY; camera = new Camera(this, camPos, camView, camUp); Components.Add(camera); world = new GameWorld(this, Content, camera); Components.Add(world); base.Initialize(); }
protected override void Initialize() { AABB aabb = new AABB(); aabb.LowerBound = new Vec2(-10000, -10000); aabb.UpperBound = new Vec2(10000, 10000); world = new World(aabb, new Vec2(0, 0), false); basicEffect = new BasicEffect(this.GraphicsDevice); basicEffect.DiffuseColor = new Vector3(1, 1, 1); Components.Add(new Map(this, "MainMap")); CarData cd = Json.GetCar("BMW"); car = new Car(this, cd.Position, cd.CollisionBody, cd.ModelName, cd.Density, cd.Friction, cd.Scale, cd.Angle); Components.Add(car); camera = new Camera(car, this); Font = Content.Load<SpriteFont>("SpriteFont1"); base.Initialize(); }