标题:初学C#,遇到问题,有哪位前辈指教下
取消只看楼主
Gin清
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-8-5
 问题点数:0 回复次数:0 
初学C#,遇到问题,有哪位前辈指教下
程序代码:
{
    public partial class Form5 : Form
    {
        Image img;
        Graphics g;
        Pen p;
        Brush bu, bu1;
        PointF pt;



        Form1 f1;
        public Form5(Form1 f)

       
        {
            InitializeComponent();
            f1=f;
            timer1.Interval = 50;
            g = this.CreateGraphics();
            p = new Pen(Color.Black, 1.0f);
            bu = new SolidBrush(Color.White);
            bu1 = new SolidBrush(Color.Black);
            img = Image.FromFile("FlagMeterLevelProgress.png");
            pt = new PointF();
            pt.X = 0;
            pt.Y = 0;
            Font = new Font("unicode", 9.0f);






        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
            f1.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled =true;
        }
       
        float x = 0, y = 100;
        int a = 5, b = 5;
        int sx;
        int score;


        private void timer1_Tick(object sender, EventArgs e)

        {

            g.DrawRectangle(p,0,0,300,400);
            x+=a;y+=b;
            if (x < 0) a = 5;
            if (x > 275) a = -5;
            if (y < 0) b = 5;
            if (y > 355 && x > sx && x < sx + 86 && y < 375)
            {
                b = -5;
                score += 10;
            }
            g.FillRectangle(bu, 0, 0, 300, 400);
            g.DrawRectangle(p, x, y, 20, 20);
            g.DrawImage(img, sx, 375);
            g.DrawString("Hide score;" + Convert.ToString(score), Font.Italic, bu1, pt);
        }
    }
}



请问哪里有错误,运行不起来!请高手指教


[ 本帖最后由 Gin清 于 2011-8-5 20:20 编辑 ]
2011-08-05 20:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-346888-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053123 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved