Beispiel #1
0
 public void Draw(SpriteRenderer renderer)
 {
     for (int i = 0; i < this.Bricks.Count; i++)
     {
         if (this.Bricks[i].IsDestroyed)
         {
             //Prune destroyed bricks
             this.Bricks.RemoveAt(i--);
             continue;
         }
         this.Bricks[i].Draw(renderer);
     }
 }
Beispiel #2
0
 public virtual void Draw(SpriteRenderer renderer)
 {
     renderer.DrawSprite(this.Sprite, this.Position, this.Size, this.Rotation, this.Color);
 }
Beispiel #3
0
        public void Init()
        {
            //Initialize game timer
            this.gameTime = new GameTime();

            //OpenGL Config
            GL.ClearColor(Color.Black);
            //GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            //GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);

            //Initialize our game state
            this.activeState = GameStates.Active;

            //Load Shaders
            Shader shader = new Shader(@"Shaders/vertex.glsl", @"Shaders/fragment.glsl");

            //Configure Shaders
            Matrix4 projection = Matrix4.CreateOrthographic(gameWindow.Width, gameWindow.Height, -1.0f, 1.0f) * Matrix4.CreateTranslation(-1f, -1f, 0f) * Matrix4.CreateScale(1f, -1f, 1f);

            shader.Use();
            shader.SetInteger("image", 0);
            shader.SetMatrix4("proj", projection);

            this.renderer = new SpriteRenderer(shader);

            //Init Game Logic
            this.gameLevels = new List<GameLevel>();
            this.gameLevels.Add(new GameLevel(@"Levels/level_01.level"));
            this.currentLevelIndex = 0;

            Texture2D playerTexture = new Texture2D(@"Textures/paddle.png");
            Vector2 playerSize = new Vector2(100, 20);
            Vector2 playerPos = new Vector2(gameWindow.Width / 2 - playerSize.X / 2, gameWindow.Height - playerSize.Y);

            //Player
            this.player = new GameObject(playerPos, playerSize, playerTexture, Color.White, Vector2.Zero);

            //Ball
            float ballRadius = 12.5f;
            this.ball = new BallObject(
                new Vector2(player.Position.X + (playerSize.X / 2 - ballRadius), player.Position.Y - ballRadius * 2f - 1),
                ballRadius, new Vector2(RNG.NextFloat(-250.0f, 250.0f), -350f), new Texture2D(@"Textures/ball.png"));
        }