我的‘’第一次‘’。。

额,,博客生涯不会就这样啥也不会的开始吧,哎,,有啥用呢?目前不知道,可能是因为本人是一个电脑小白中的电脑大白吧,哈哈,不过没关系,有大神的帮助,以及对着计算机有着一种特殊的兴趣相信我这个电脑大白会一步步的走向电脑小白的,,,慢慢的填空脑中的那种一片茫然的感觉特爽也,哈哈,不错,继续前进,有学就行。
好吧。是该记录点有用点的东西了。不要再bibi了。

以下是本人做的第一个程序,额 好吧。是弄明白的程序。。。
如何控制能让一个标志性的物体在一个窗口里弹来弹去,

namespace WindowsFormsApplication1.number3
{
    public partial class Form1 : Form
    {
        int ox, oy;

        public Form1()
        {
            InitializeComponent();

            button1.Text = "我就点";
            label1.Text = "别点";
            ox = oy = 1;           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (timer1. Enabled)
                timer1. Stop();
            else 
                timer1 .Start() ;


        }

        private void timer1_Tick(object sender, EventArgs e)
        {
             Random a  = new Random ();

            if (oy == -1 &&
                label1 .Location .Y < 0)
                oy = 1;

            if ((label1.Location.X + label1 .Width > this .ClientRectangle.Width) && ox == 1)
                ox = -1;

            if ((label1 .Location .Y +this .label1 .Height > this .ClientRectangle.Height) && oy == 1)
                oy = -1;

            if  (label1 .Location .X < 0 && ox ==-1)
                ox = 1;

           label1.Location = new Point(label1.Location .X + ox * a .Next(10) , label1.Location.Y + oy * a .Next(10) );
        }


        }
}
    就这样,,一个简单而对我这小白哦不是大白就困难的程序就这样诞生了,,哈哈哈哈,。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值