首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 屌丝的游戏,是男人就坚持20秒,该怎么解决

2012-06-01 
c# 屌丝的游戏,是男人就坚持20秒昨晚花了2个小时,今天花了4个小时完成的.就是自娱自乐,还有很多问题.自己

c# 屌丝的游戏,是男人就坚持20秒
昨晚花了2个小时,今天花了4个小时完成的.就是自娱自乐,还有很多问题.自己看吧.
链接:http://download.csdn.net/detail/hlxcoo2007/4314240

C# code
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Collections;namespace ManGame{    public partial class FMain : Form    {        public int[,] ballarray = new int[40, 40];        public FMain()        {            InitializeComponent();        }        private bool _isStart = false;        private bool isStart        {            get { return _isStart; }            set { _isStart = value; }        }        private void tsmExit_Click(object sender, EventArgs e)        {            this.Close();        }        private void tsmChoose_Click(object sender, EventArgs e)        {            FrmDiffcultChoose _fchoose = new FrmDiffcultChoose(this);            _fchoose.ShowDialog();        }        private void tsmAbout_Click(object sender, EventArgs e)        {            FrmAbout _about = new FrmAbout();            _about.ShowDialog();        }        Timer _startTime;        private void tsmNewGame_Click(object sender, EventArgs e)        {            setEnable(false);            ts = 1;            Graphics g = this.CreateGraphics();            drawString(g, "1");            _startTime = new Timer();            _startTime.Interval = 1000;            _startTime.Tick += new EventHandler(OnTick);            _startTime.Start();        }        private void drawString(Graphics _g, string _s)        {            float px = this.ClientSize.Width / 2;            float py = (this.ClientSize.Height / 2) - 40;            StringFormat drawFormat = new StringFormat();            drawFormat.Alignment = StringAlignment.Center;            _g.DrawString(_s, new Font(this.Font.FontFamily, 72), new SolidBrush(Color.Red), px, py, drawFormat);        }        double OverTime = 0;        int ts = 1;        void OnTick(object sender, EventArgs e)        {            this.Refresh();            Graphics g = this.CreateGraphics();            ts += 1;            drawString(g, ts.ToString());            if (ts == 4)            {                this.Refresh();                drawString(g, "翻滚吧,屌丝..");            }            if (ts == 5)            {                isStart = true;                this.timer1.Start();                Random r = new Random();                for (int i = 1; i <= SaveParam.BallNum; i++)                {                    ballarray[i, 1] = +r.Next(10) + 5;                    ballarray[i, 2] = +r.Next(10) + 5;                    ballarray[i, 3] = +r.Next(10) + 5;                    ballarray[i, 4] = +r.Next(10) + 5;                }                _startTime.Stop();            }        }        private int x1;        private int y1;        protected override void OnMouseMove(MouseEventArgs m)        {            x1 = m.X;            if (x1 + 40 >= this.Width)            {                x1 = this.Width - 25;            }            else if (x1 - 15 <= 0)            {                x1 = 15;            }            y1 = m.Y;            if (y1 + 60 >= this.Height)            {                y1 = this.Height - 45;            }            else if (y1 - 60 <= 0)            {                y1 = 40;            }        }        private void setEnable(bool _enable)        {            this.tsmAbout.Enabled = _enable;            this.tsmChoose.Enabled = _enable;            this.tsmNewGame.Enabled = _enable;        }        Rectangle _rect;        bool ifOver = false;        protected override void OnPaint(PaintEventArgs e)        {            Graphics g = e.Graphics;            if (isStart)            {                _rect = new Rectangle();                _rect.X = x1;                _rect.Y = y1;                _rect.Width = 30;                _rect.Height = 30;                int strX = 0;                int strY = 0;                for (int i = 1; i <= SaveParam.BallNum; i++)                {                    strX = ballarray[i, 1];                    strY = ballarray[i, 2];                    g.FillEllipse(new SolidBrush(Color.White), strX, strY, 15, 15);                    if (_rect.Contains(strX, strY) || _rect.Contains(strX + 15, strY + 15))                    {                        timer1.Stop();                        ifOver = true;                        isStart = false;                        break;                    }                }                g.FillRectangle(new SolidBrush(Color.Yellow), x1 - 15, y1 - 15, 30, 30);                if (ifOver)                {                    MessageBox.Show("能不能坚持久点,是男人就重来,才坚持了" + Convert.ToDouble(OverTime / 1000) + "s", "提示");                    g.Clear(Color.Black);                    setEnable(true);                    ifOver = false;                }            }        }        private void timer1_Tick(object sender, EventArgs e)        {            OverTime += timer1.Interval;            for (int i = 1; i <= SaveParam.BallNum; i++)            {                ballarray[i, 1] = ballarray[i, 1] + ballarray[i, 3];                ballarray[i, 2] = ballarray[i, 2] + ballarray[i, 4];                if ((ballarray[i, 1] + 10) >= this.ClientSize.Width)                {                    ballarray[i, 1] = ballarray[i, 1] - ballarray[i, 3];                    ballarray[i, 3] = -ballarray[i, 3];                }                else if ((ballarray[i, 2] + 10) >= this.ClientSize.Height)                {                    ballarray[i, 2] = ballarray[i, 2] - ballarray[i, 4];                    ballarray[i, 4] = -ballarray[i, 4];                }                else if (ballarray[i, 1] <= 1)                {                    ballarray[i, 1] = ballarray[i, 1] - ballarray[i, 3];                    ballarray[i, 3] = -ballarray[i, 3];                }                else if (ballarray[i, 2] <= 1)                {                    ballarray[i, 2] = ballarray[i, 2] - ballarray[i, 4];                    ballarray[i, 4] = -ballarray[i, 4];                }            }            this.Refresh();        }    }} 



只发关键代码.
下面上图





[解决办法]
试试看……
[解决办法]
大家现在都4.0了……
[解决办法]
可以哈。让我想起了以前日本人那个坚持20秒。

楼主做个.net复刻版吧,让大家乐呵乐呵
[解决办法]
另外,能不能不用4.0,搞的我XP都玩不了,还得用2.0重新编译一遍
[解决办法]
怎么玩法?
[解决办法]
翻滚吧,屌丝们
[解决办法]
屌丝默泪~
[解决办法]
屌丝只能悄悄旁观……
[解决办法]
貌似很强大

热点排行