Пример #1
0
        private void drawWalls()
        {
            vector2 topRow = new vector2(0, 0);

            for (int x = 1; x < d.xMax; x++)
            {
                topRow.x = x;

                if (!d.trySetChar(topRow, '='))
                {
                    Log.e("Failed to SetChar");
                }
            }

            vector2 leftRow  = new vector2(0, 0);
            vector2 rightRow = new vector2(d.xMax, 0);

            for (int y = 0; y < d.yMax; y++)
            {
                leftRow.y = y;

                if (!d.trySetChar(leftRow, '|'))
                {
                    Log.e("Failed to SetChar");
                }

                rightRow.y = y;

                if (!d.trySetChar(rightRow, '|'))
                {
                    Log.e("Failed to SetChar");
                }
            }
        }
Пример #2
0
        public gameState update()
        {
            lastMoveOutcome outcome = lastMoveOutcome.neutral;

            if (counter % skipCounter == 0)
            {
                d.clear(pos);
                vector2 newPos = vector2.add(pos, velocity);

                if (d.screenBuffer.ContainsKey(newPos))
                {
                    outcome = bounce(newPos);
                    if (outcome == lastMoveOutcome.neutral)
                    {
                        Program.bounces++;
                    }
                }
                else
                {
                    if (newPos.y >= d.yMax)
                    {
                        randomizeBall();
                        outcome = lastMoveOutcome.bad;
                    }
                    else
                    {
                        pos = newPos;
                    }
                }

                d.trySetChar(pos, 'o');
            }

            counter++;

            switch (outcome)
            {
            case lastMoveOutcome.good:
                Program.hits++;
                break;

            case lastMoveOutcome.neutral:
                break;

            case lastMoveOutcome.bad:
                Program.misses++;
                break;
            }

            return(new gameState(pos, velocity, outcome, pd.posCache));
        }
Пример #3
0
        public void update(vector2 move)
        {
            if (counter % skipAmount == 0)
            {
                if (width > 1)
                {
                    clearPaddle();
                    tryMove(pos + move.x);
                    setPaddle();
                }
                else
                {
                    d.clear(posCache);
                    tryMove(pos + move.x);
                    d.trySetChar(posCache, '=');
                }
            }
            else
            {
            }

            counter++;
        }