Пример #1
0
        public override void OnRender(DrawContext ctx)
        {
            ctx.Push();
            ctx.ScaleAroundPoint(backgroundScale, backgroundScale, 400.0f, 300.0f);
            ctx.BindTexture(backgroundTexture);
            ctx.DrawTexturedRectangle(800, 600, backgroundTexture);
            ctx.Pop();

            ctx.Push();
            ctx.Translate(50.0f, 50.0f);
            ctx.RotateAroundPoint(logoAngle, 200.0f, 200.0f);
            ctx.BindTexture(logo);
            ctx.DrawTexturedRectangle(400.0f, 400.0f, logo);
            ctx.Pop();

            ctx.Push();
            ctx.RotateAroundPoint(menuAngle, 400.0f, 450.0f);
            ctx.BindTexture(menuTexture);
            int i = 0;
            foreach (MainMenuItem item in menuItems) {
                bool active = i++ == activeItem;
                ctx.Push();
                ctx.Translate(item.Position);
                if (active) {
                    ctx.Translate(0.0f, itemJump);
                    ctx.RotateAroundPoint(itemAngle, item.Width / 2.0f, item.Height / 2.0f);
                }
                ctx.DrawTexturedRectangle(item.Width, item.Height, item.Texture);
                ctx.Pop();
            }
            ctx.Pop();
        }
Пример #2
0
 public void Draw(DrawContext ctx, GamePane pane, float alpha)
 {
     Color4 blockColor = color;
     blockColor.A = alpha;
     ctx.BindTexture(texture);
     ctx.SetColor(blockColor);
     ctx.DrawTexturedRectangle(pane.BlockSize, pane.BlockSize, texture);
 }
Пример #3
0
        public Game()
            : base(800, 600, new GraphicsMode(32, 24, 0, 4),
                             "BlockPuzzle", GameWindowFlags.Default)
        {
            drawContext = new DrawContext();
            inputManager = new InputManager(this);
            inputManager.LoadDefaults();
            random = new Random();

            objectsToDispose = new List<GraphicsObject>();
            lock (activeGames)
                activeGames[Context] = this;
        }
Пример #4
0
        public void Draw(DrawContext ctx)
        {
            List<GameBlockState> deferredBlocks = new List<GameBlockState>();
            float scale = 1.0f + (float)Math.Sin(jitter * 0.5f) * 0.003f;
            float angle = (float)Math.Sin(jitter * 0.5) * 0.15f;

            ctx.Push();
            ctx.Translate(position.X, position.Y);
            ctx.ScaleAroundPoint(scale, scale, Columns * BlockSize / 2, Rows * BlockSize / 2);
            ctx.RotateAroundPoint(angle, Columns * BlockSize / 3, Rows * BlockSize / 3);

            // cursor
            if (!gameOver) {
                ctx.Push();
                ctx.Translate(GetBlockX(cursorColumn) - 4, GetBlockY(cursorRow) - 4);
                ctx.BindTexture(cursorTexture);
                ctx.SetColor(new Color4(100, 100, 100, 255));
                ctx.DrawTexturedRectangle(BlockSize * 2.0f + 8, BlockSize + 8, cursorTexture);
                ctx.Pop();
            // game over logo
            } else {
                ctx.Push();
                ctx.Translate(40.0f, 240.0f);
                ctx.BindTexture(session.GameOverTexture);
                ctx.DrawTexturedRectangle(240.0f, 45.0f, session.GameOverTexture);
                ctx.Pop();
            }

            // regular blocks
            for (int column = 0; column < Columns; column++) {
                for (int row = 0; row < Rows; row++) {
                    GameBlockState blockState = this[column, row];
                    if (blockState.Empty)
                        continue;
                    if (blockState.DrawDeferred)
                        deferredBlocks.Add(blockState);
                    else
                        blockState.Draw(ctx);
                }
            }

            // block independent block animations
            foreach (GameBlockAnimation animation in activeAnimations)
                animation.Draw(ctx);

            // top and bottom bars that hide partial rows
            if (!gameOver) {
                ctx.Push();
                ctx.BindTexture(session.BarTexture);
                ctx.SetColor(new Color4(40, 40, 40, 255));
                ctx.Translate(-BlockSize / 2, -35.0f);
                ctx.DrawTexturedRectangle(BlockSize * (Columns + 1), 40.0f, session.BarTexture);
                ctx.Translate(0.0f, BlockSize * Rows - BlockSize / 2);
                ctx.DrawTexturedRectangle(BlockSize * (Columns + 1), 50.0f, session.BarTexture);
                ctx.Pop();
            }

            // selected blocks and other things we want to have on top
            foreach (GameBlockState blockState in deferredBlocks)
                blockState.Draw(ctx);

            ctx.Pop();
        }
Пример #5
0
 public override void OnRender(DrawContext ctx)
 {
     float scale = 1.1f + (float)Math.Sin(backgroundJitter) * 0.05f;
     float angle = (float)Math.Cos(backgroundJitter) * 2.0f;
     ctx.Push();
     ctx.ScaleAroundPoint(scale, scale, 400.0f, 300.0f);
     ctx.RotateAroundPoint(angle, 400.0f, 300.0f);
     ctx.BindTexture(backgroundTexture);
     ctx.DrawTexturedRectangle(800.0f, 600.0f, backgroundTexture);
     ctx.Pop();
     leftPane.Draw(ctx);
     rightPane.Draw(ctx);
 }
Пример #6
0
        public void Draw(DrawContext ctx)
        {
            if (Empty)
                return;
            float xOff = 0.0f;
            float x, y;
            bool underCursor = false;
            if (!Hard && row == pane.CursorRow) {
                if (column == pane.CursorColumn) {
                    underCursor = true;
                    xOff = -3.0f;
                } else if (column == pane.CursorColumn + 1) {
                    underCursor = true;
                    xOff = 3.0f;
                }
            }

            float angle = underCursor
                ? pane.Jitter * 30.0f
                : (float)Math.Sin(pane.Jitter * jiggle) * 3.0f;

            ctx.Push();
            if (animationStep >= 0.0f) {
                x = animationSourceX + (BlockX - animationSourceX) * animationStep;
                y = animationSourceY + (BlockY - animationSourceY) * animationStep;
            } else {
                x = BlockX;
                y = BlockY;
            }
            ctx.Translate(x + xOff, y);
            ctx.RotateAroundPoint(angle, pane.BlockSize / 2, pane.BlockSize / 2);
            if (underCursor) {
                float scale = 1.35f * (1.0f - (float)Math.Sin(pane.Jitter * 3.0f) * 0.06f);
                ctx.ScaleAroundPoint(scale, scale, pane.BlockSize / 2, pane.BlockSize / 2);
            }
            block.Draw(ctx, pane, 1.0f);
            ctx.Pop();
        }
Пример #7
0
 public override void Draw(DrawContext ctx)
 {
     float center = Pane.BlockSize / 2.0f;
     ctx.Push();
     ctx.Translate(Pane.GetBlockX(Column), Pane.GetBlockY(Row) + yOff);
     ctx.ScaleAroundPoint(scale, scale, center, center);
     ctx.RotateAroundPoint(rotation, center, center);
     Block.Draw(ctx, Pane, alpha);
     ctx.Pop();
 }
Пример #8
0
 public abstract void Draw(DrawContext ctx);
Пример #9
0
 public virtual void OnRender(DrawContext ctx)
 {
 }
Пример #10
0
 public abstract void Draw(DrawContext ctx);