コード例 #1
0
ファイル: Collisions.cs プロジェクト: NikolaosISL/LinkGame
        public void CheckGround_Player(Player myPlayer, Ground myGround)
        {
            myPlayer.isFalling = true;

            foreach (Rectangle rec in myGround.rectangleList)
            {
                if (myPlayer.position.X > rec.X && (myPlayer.position.X < rec.X + rec.Width))
                {
                    if (rec == myGround.rectangleList[1])
                    {

                    }
                    if (myPlayer.position.Y > rec.Top)
                    {
                        myPlayer.isFalling = false;
                        myPlayer.direction.Y = 0;
                    }
                }
            }
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: NikolaosISL/LinkGame
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Tools.Content = this.Content;
            Tools.spriteBatch = this.spriteBatch;

            myCollisionCheck = new CollisionCheck();

            List<Animation> animations = new List<Animation>();
            List<string> names = new List<string>();
            animations.Add(new Animation("PlayerSprites", "Contra_stand", new Rectangle(200, 100, 25, 40), new Rectangle(0, 0, 0, 0), 0.0f, new Vector2(0, 0), SpriteEffects.None, 10));
            animations.Add(new Animation("PlayerSprites", "Contra_run", new Rectangle(200, 100, 25, 40), new Rectangle(0, 0, 0, 0), 0.0f, new Vector2(0, 0), SpriteEffects.None, 10));
            animations.Add(new Animation("PlayerSprites", "Contra_jump", new Rectangle(200, 100, 23, 23), new Rectangle(0, 0, 0, 0), 0.0f, new Vector2(0, 0), SpriteEffects.None, 10));
            names.Add("stand");
            names.Add("run");
            names.Add("jump");

            myPlayer = new Player(animations, names);
            myGround = new Ground();
        }