예제 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            MousePosition = Mouse.GetState().Position;
            GraphicsDevice.Clear(Color.Chocolate);
            Camera.Pos = Player.GetPosition();
            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend,
                              null, null, null, null,
                              Camera.GetTransformation());

            movePointer.Draw(spriteBatch);

            Noms.ForEach(nom => nom.Draw(spriteBatch));

            #if DEBUG
            DebugDraw();
            #endif

            var pos = Mouse.GetState().Position.ToVector2() + Camera.TopLeftPos;
            cursor.SetPos(pos);
            cursor.Draw(spriteBatch);
            spriteBatch.End();

            #if DEBUG
            var transform = Matrix.CreateOrthographicOffCenter(
                ConvertUnits.ToSimUnits(Camera.TopLeftPos.X),
                ConvertUnits.ToSimUnits(Camera.TopLeftPos.X + GraphicsDevice.Viewport.Width),
                ConvertUnits.ToSimUnits(Camera.TopLeftPos.Y + GraphicsDevice.Viewport.Height),
                ConvertUnits.ToSimUnits(Camera.TopLeftPos.Y),
                0f, 1f);
            DebugView.RenderDebugData(ref transform);
            #endif

            base.Draw(gameTime);
        }
예제 #2
0
파일: Physics.cs 프로젝트: anthrich/nomnom
        public void RegisterNom(Nom nom)
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);
            float   width   = ConvertUnits.ToSimUnits(nom.Width);
            float   height  = ConvertUnits.ToSimUnits(nom.Height);
            Vector2 pos     = ConvertUnits.ToSimUnits(nom.GetPosition());
            Body    nomBody = BodyFactory.CreateEllipse(World, width, height * 0.16f, 8, 1, pos, nom);

            //Body nomBody = BodyFactory.CreateRectangle(World, width, height, 1, pos, nom);
            nomBody.UserData       = nom;
            nomBody.BodyType       = BodyType.Dynamic;
            nomBody.AngularDamping = 3f;
            nom.RegisterBody(nomBody);
        }
예제 #3
0
        /// <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
            Camera  = new Camera2d(GraphicsDevice);
            Player  = new Nom(Content);
            Physics = new Physics();
            AddNomToGame(Player);

            for (int i = 0; i < 10; i++)
            {
                Nom newNom = new Nom(Content);
                newNom.SetPosition(i * 50, i * 50);
                newNom.MoveToPosition(newNom.GetPosition());
                AddNomToGame(newNom);
                AiNoms.Add(newNom);
            }

            this.IsMouseVisible = false;
            base.Initialize();
        }