Пример #1
0
 public void Update(float elapsed)
 {
     reccoin  = new Rectangle((int)this.poscoin.X, (int)this.poscoin.Y, 50, 50);
     poscoin -= cameraPos;
     cointex.UpdateFrame(elapsed);
     cameraPos = new Vector2(1, 0);
 }
Пример #2
0
        public void Update(float elapsed)
        {
            velocity.Y = 0;
            playerX.UpdateFrame(elapsed);
            posplayer    += velocity;
            old_posplayer = posplayer;
            hp.DecreaseHp(true);


            /*if (jumpplayer == false)
             * {
             *  velocity.Y = 3;
             * }
             * if (posplayer.Y>380)
             * {
             *  posplayer.Y = 380;
             * }
             * if (jumpplayer == true)
             * {
             *  velocity.Y = -6;
             * }*/

            for (int i = 0; i < platfroms.Count; i++)
            {
                platfroms[i].Update(elapsed);
            }
            for (int i = 0; i < coinss.Count; i++)
            {
                coinss[i].Update(elapsed);
                // Rectangle reccoin = new Rectangle((int)coinss[i].poscoin.X, (int)coinss[i].poscoin.Y, 50, 50);
            }



            for (int i = 0; i < coinss.Count; i++)
            {
                if (playercol.Intersects(coinss[i].reccoin))
                {
                    check = true;
                    coinss.RemoveAt(i);
                    score += 5;
                }
            }

            foreach (Platform platform in platfroms)
            {
                if (playercol.Intersects(platform.rectangle))
                {
                    jumpplayer = false;
                    posplayer  = old_posplayer;

                    //foce = 7;
                }
                else
                {
                    posplayer.Y += gravity.Y;
                }
            }



            playercol = new Rectangle((int)posplayer.X, (int)posplayer.Y, 85, 125);
            lasorcol  = new Rectangle((int)lazer.poslazer.X, (int)lazer.poslazer.Y, 30, 30);

            /*if (playercol.Intersects(monster.moncol) == true)
             * {
             *
             *  hp.DecreaseHp(playercol.Intersects(monster.moncol));
             *  check = true;
             *
             *
             * }*/
            /* if (lasorcol.Intersects(monster.moncol) == true)
             * {
             *
             *   hitmonster();
             *
             *   checktime = true;
             *
             *
             * }*/



            bg.getposplayer(posplayer);

            if (jumpplayer == false)
            {
                //posplayer.Y += gravity.Y;
            }

            /*if(posplayer.Y> 380)
             * {
             *  posplayer.Y = 380;
             *  foce = 10;
             *
             *
             * }*/

            if (jumpplayer == true)
            {
                count++;
                posplayer.Y -= foce;
                if (count == 15)
                {
                    foce -= 2;
                    count = 0;
                }
                if (foce == 0)
                {
                    jumpplayer = false;
                }
            }


            /*if(velocity.X == 0)
             * {
             *   jumpplayer = true;
             * }*/

            lazer.Update(elapsed);
            bg.Update(elapsed);
            hp.Update(elapsed);
        }