Example #1
0
        private void MouseTimer_Tick(object sender, EventArgs e)
        {
            Point curPos;

            if (_canvas.GetLastMouseLeftClick(out curPos) && _drawFlag == false)
            {
                _drawFlag = true;
                _lineStack.Push(new LinkedList <LineSeg>());
                lastMousePos = curPos;
            }

            if (_canvas.GetLastMousePosition(out curPos) && _drawFlag == true)
            {
                LineSeg line = new LineSeg(lastMousePos, curPos, TrB_LineThick.Value, _color);
                totalLines += 1;
                _lineStack.Peek().AddLast(line);
                lastMousePos = curPos;

                line.Render(_canvas);
            }

            if (_canvas.GetLastMouseRightClick(out curPos) && _drawFlag == true)
            {
                _drawFlag = false;
            }

            UpdateInfo();
        }
Example #2
0
        private void BallTick_Tick(object sender, EventArgs e)
        {
            Point    rightClick = new Point(-1, -1);
            Point    leftClick  = new Point(-1, -1);
            PropBall ball;

            canvas.Clear();

            if (canvas.GetLastMouseRightClick(out rightClick))
            {
                ball = new PropBall(rightClick, PropBall.BallColor.Purple);
                ballList.Add(ball);
            }

            if (canvas.GetLastMouseLeftClick(out leftClick))
            {
                ball = new PropBall(leftClick, PropBall.BallColor.Orange);
                ballList.Add(ball);
            }

            for (int ballCount = 0; ballCount < ballList.Count(); ++ballCount)
            {
                foreach (PropBall ball2 in ballList)
                {
                    if (!ball2.Equals(ballList[ballCount]))
                    {
                        if (ball2.GetColor != ballList[ballCount].GetColor)
                        {
                            ballList[ballCount].Love = ball2;
                        }
                        else
                        {
                            ballList[ballCount].Hate = ball2;
                        }
                    }
                }
                if (ballList[ballCount].Pos.X < 0 ||
                    ballList[ballCount].Pos.X > 800 ||
                    ballList[ballCount].Pos.Y < 0 ||
                    ballList[ballCount].Pos.Y > 600)
                {
                    outBound.Add(ballList[ballCount]);
                }
            }

            foreach (PropBall outBall in outBound)
            {
                ballList.Remove(outBall);
            }


            foreach (PropBall mBall in ballList)
            {
                mBall.Render(canvas);
            }
            canvas.Render();
        }
Example #3
0
        static void Main(string[] args)
        {
            //program information
            Console.WriteLine("Instruction:");
            Console.WriteLine("Left click to create a RED BLOCK");
            Console.WriteLine("Right click to create a YELLOW BLOCK");
            Console.WriteLine("Right click on exist BLOCK to DELETE it\n");
            Console.WriteLine("RED BLOCK will fall to the bottom");
            Console.WriteLine("YELLOW BLOCK will stay solid in the click location");

            //initial constant variables
            const int blockSize = 50;

            const int windowX = 1000;
            const int windowY = 1000;

            const int blockX = windowX / blockSize;
            const int blockY = windowY / blockSize;

            //initial point for clicking left or right
            Point currentPos = new Point();

            CDrawer canvas = new CDrawer(windowX, windowY, false);

            if (blockSize >= 10)
            {
                GridManager gm = new GridManager(blockX, blockY, blockSize, canvas);

                do
                {
                    //add grid if left click or right click
                    if (canvas.GetLastMouseLeftClick(out currentPos))
                    {
                        gm.AddLeft(currentPos);
                    }
                    if (canvas.GetLastMouseRightClick(out currentPos))
                    {
                        gm.AddRight(currentPos);
                    }

                    gm.Render(canvas);
                    gm.Falling();

                    //for TESTING ONLY
                    //gm.ShowAll(canvas);
                    Thread.Sleep(10);
                } while (true);
            }
            else
            {
                Console.WriteLine("Block size must be greater than or equal 10");
            }
            Console.ReadKey();
        }
        private void _Timer_Tick(object sender, EventArgs e)
        {
            Point p;

            if (canvas.GetLastMouseLeftClick(out p))
            {
                BallList.Add(new Ball(p));
            }
            else if (canvas.GetLastMouseRightClick(out p))
            {
                BallList.Clear();
            }
            canvas.Clear();
            for (int i = 0; i < BallList.Count; i++)
            {
                BallList[i].MoveBall(canvas);
                BallList[i].ShowBall(canvas);
                this.Text = BallList[i].ToString();
            }
            canvas.Render();
        }
Example #5
0
        /// <summary>
        /// balls will move with this
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _timer_Tick(object sender, EventArgs e)
        {
            //left click add ball sing point val
            if (_cDrawer.GetLastMouseLeftClick(out ctr))
            {
                _balls.Add(new ball(ctr));
            }

            //right click clear
            //clear collections and render gdi to show no shapes
            if (_cDrawer.GetLastMouseRightClick(out ctr))
            {
                _balls.Clear();
                _cDrawer.Clear();
                _cDrawer.Render();
            }

            //clear and call methods in respective loop
            _cDrawer.Clear();
            //move balls in collection
            for (int i = 0; i < _balls.Count; i++)
            {
                _balls[i].MoveBall(_cDrawer);
            }

            //display every ball in lisy collection
            foreach (var item in _balls)
            {
                item.ShowBall(_cDrawer);
            }
            _cDrawer.Render();

            //ball position in list
            //does for all balls
            for (int i = 0; i < _balls.Count; i++)
            {
                this.Text = _balls[i].ToString();
            }
        }
Example #6
0
        private void casio_Tick(object sender, EventArgs e)
        {
            //Tick all FBalls in list
            foreach (FBall fb in LBalls)
            {
                fb.Tick();
            }

            //IF user clicks mouse, create newpoint and random number
            Point vertex = new Point();

            if (Canvas.GetLastMouseLeftClick(out vertex))
            {
                Draw(vertex, Color.FromArgb(rand.Next(50, 255), rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)));
            }
            else if (Canvas.GetLastMouseRightClick(out vertex))
            {
                //create black circles from top left
                Draw(new Point(0, 0), Color.Black);
            }

            //clear then render all FBalls
            Canvas.Clear();
            foreach (FBall fb in LBalls)
            {
                fb.Render();
            }

            //show all FBalls on CDrawer canvas
            Canvas.Render();

            //check if canvas is closed
            if (Canvas.DrawerWindowSize.IsEmpty)
            {
                Application.Exit();
            }
        }