private QuadTree<IGameObject> quadtree; //со оваа структура може да се подели рамнината на делови #endregion Fields #region Constructors public ArkanoidGamePlayState(IGame game) { this.ballIncreaseSpeedPeriodCounter = 0; this.multiBallPeriodsCounter = 0; Score = 0; lockCollisionDetection = new object(); debugMode = false; quadtree = null; ButtonDWaitNFrames = 0; this.Game = game; this.Game.GameObjects.Clear(); //бриши ги сите објекти (ако има такви) RendererCache.RemoveAllBitmapsFromMainMemory(); //исчисти го баферот од претходната состојба Game.ReloadResources(); this.InitBrickTextures(); BitmapsToRender = new List<IList<GameBitmap>>(); bitmapsToRenderCopy = new List<IList<GameBitmap>>(); background = new List<GameBitmap>(); background.Add(new GameBitmap("\\Resources\\Images\\background.jpg", 0, 0, game.VirtualGameWidth, game.VirtualGameHeight)); ballsInPlay = new HashSet<IGameObject>(); //додади го играчот на позиција (1750, 2010). PlayerPaddle player = new PlayerPaddle(new Vector2D(1750, 2010), Game.VirtualGameWidth, Game.VirtualGameHeight); Game.GameObjects.Add(player); this.LocalPlayer = player; //додади ја топката BlueBall ball = new BlueBall(new Vector2D((player.Position.X * 2 + player.ObjectWidth) / 2, player.Position.Y - 45), 50, player); Game.GameObjects.Add(ball); ballsInPlay.Add(ball); CreateBricks(); /* //proba da dodadam golema crvena cigla BigRedBrick grb = new BigRedBrick(new Vector2D(20, 100), Game.VirtualGameWidth, Game.VirtualGameHeight); //proba da dodadam mala crvena cigla //proba da dodadam golema zolta cigla */ ElapsedTime = 0; }
/// <summary> /// Креира нови топки секоја минута /// </summary> void CreateNewBalls() { multiBallPeriodsCounter++; if (multiBallPeriodsCounter < multiballPeriod) { return; } //направи нови топки на секои 3750 периоди (1 минута) this.multiBallPeriodsCounter = 0; //направи две нови топки за секоја што е во игра IEnumerator<IGameObject> it = ballsInPlay.GetEnumerator(); if (it.MoveNext()) { BlueBall ball = (BlueBall)it.Current; BlueBall ball2 = new BlueBall(ball.Position + new Vector2D(ball.Radius, ball.Radius), ball.Radius, LocalPlayer); ball2.Velocity.X = ball.Velocity.X; ball2.Velocity.Y = ball.Velocity.Y; ball2.Velocity.RotateDeg(-30); BlueBall ball3 = new BlueBall(ball.Position + new Vector2D(-ball.Radius, -ball.Radius), ball.Radius, LocalPlayer); ball3.Velocity.X = ball.Velocity.X; ball3.Velocity.Y = ball.Velocity.Y; ball3.Velocity.RotateDeg(30); Game.GameObjects.Add(ball2); Game.GameObjects.Add(ball3); ballsInPlay.Add(ball2); ballsInPlay.Add(ball3); } }