Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch         = new SpriteBatch(GraphicsDevice);
            Background1         = Content.Load <Texture2D>("Background");
            Background2         = Content.Load <Texture2D>("Background");
            Background1Position = new Rectangle(0, 0, Background1.Width, Background1.Height);
            Background2Position = new Rectangle(Background1.Width, 0, Background2.Width, Background2.Height);
            Tx_Nisan            = Content.Load <Texture2D>("nisan");
            Rec_Nisan           = new Rectangle(0, 0, 64, 64);
            ses              = Content.Load <SoundEffect>("Magnum");
            SkorFont         = Content.Load <SpriteFont>("Skor");
            SkorPosition     = new Vector2(3, 3);
            GameOverFont     = Content.Load <SpriteFont>("gameover");
            GameOverPosition = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2);


            if (Hedefler.Count != 0)
            {
                foreach (var item in Hedefler)
                {
                    item.Load(Content);
                }
            }
            else
            {
                Random r    = new Random();
                int    temp = r.Next(0, 4);
                Adam   a    = new Adam(0, Rastgele.R(300).Y, Rastgele.R(300).Hiz, ((resim)temp).ToString());
                a.Load(Content);
                Hedefler.Add(a);
            }
            // TODO: use this.Content to load your game content here
        }
Esempio n. 2
0
        public static Rastgele R(int max)
        {
            Random   r  = new Random();
            Rastgele ra = new Rastgele();

            ra.X   = r.Next(max);
            ra.Y   = r.Next(max);
            ra.Hiz = r.Next(1, 5);
            return(ra);
        }
Esempio n. 3
0
        protected override void Update(GameTime gameTime)
        {
            Rec_Nisan = new Rectangle(Mouse.GetState().X - (32 / 2), Mouse.GetState().Y - (32 / 2), 32, 32);
            total    += gameTime.ElapsedGameTime.TotalSeconds;
            if (total > Sure)
            {
                Random r    = new Random();
                int    temp = r.Next(0, 4);
                Adam   a    = new Adam(0, Rastgele.R(300).Y, Rastgele.R(300).Hiz, ((resim)temp).ToString());
                a.Load(Content);
                Hedefler.Add(a);
                total = 0;
            }
            //Hedef yonlendirir;
            foreach (var item in Hedefler)
            {
                item.Update(graphics);
            }

            ms = Mouse.GetState();

            if (ms.LeftButton == ButtonState.Pressed && pms.LeftButton == ButtonState.Released)
            {
                ses.Play();
                vurulan = new List <AHedef>();

                foreach (var item in Hedefler)
                {
                    if (item.Rec.Intersects(Rec_Nisan))
                    {
                        Skor++;
                        vurulan.Add(item);
                    }
                }
                foreach (var item in vurulan)
                {
                    Hedefler.Remove(item);
                }
            }

            pms = ms;
            base.Update(gameTime);
        }