C#实现消消乐:从零到一
C#课程设计作业,花了两天时间,其中抠图找图都花了大半天(后悔以前没去学PS,后悔莫及,所以最后做出来自己都看不下去的粗糙,不过只能这样了)
第一天上午:构思整个的大体框架,要实现的功能
第一天下午:找图,抠图,找资源,地图的绘制
第二天上午:被搜索联通块以及方块的消除难住了,后面参考了一些才解决主要核心的,包括判断相邻,执行交换,消除,执行下落,利用了3个Timer组件
第二天下午:技能体系,充值体系,修修改改,勉强做出来了
(一)课程作业:C#消消乐完整实现
利用 C#winform 实现了消消乐游戏的制作 开发环境 VS2015,SQL sever 2008,
实现功能:
1.登录,注册窗口
2.主界面消消乐的实现
3.技能体系:3个技能
4.充值体系
5.背包功能的实现
6.闯关功能的实现
(二)主要窗体
1.登录,注册
2.主界面
3.充值界面,教学界面
(三)各窗体核心代码
1.登录,注册
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Media; namespace KillGame { public partial class Login : Form { public Login() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e)//登录 { if(checkBox1 .Checked ==true) { if (textBox1.Text.Trim() == "123456" && textBox2.Text.Trim() == "123456") { string sname = "老师"; startProgress(progressBar1); this.Hide(); Game game = new KillGame.Game(sname); game.Show(); } else { MessageBox.Show("登录失败,超级用户账号密码都是123456,再试试"); } } else { string id = textBox1.Text.Trim().ToString(); string pwd = textBox2.Text.Trim().ToString(); if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "") { MessageBox.Show("请输入账号或密码!"); return; } SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog=MBook;Persist Security Info=True;User ID=sa;Password='zdllxf211215'"); string strselect = "select Name from TUser where id='" + textBox1.Text.Trim().ToString() + "'and pwd='" + textBox2.Text.Trim().ToString() + "'"; SqlCommand cmd = new SqlCommand(strselect, conn); conn.Open(); string name = cmd.ExecuteScalar().ToString(); if (name != null) { startProgress(progressBar1); this.Hide(); Game game = new KillGame.Game(name); game.Show(); } else { MessageBox.Show("登录失败!"); } } } private void button2_Click(object sender, EventArgs e)//取消 { this.Close(); } private void button3_Click(object sender, EventArgs e)//注册 { Logon logon = new Logon(); logon.Show(); } public void SetCursor(Bitmap cursor, Point hotPoint)//自定义光标 { int hotX = hotPoint.X; int hotY = hotPoint.Y; Bitmap myNewCursor = new Bitmap(cursor.Width * 2 - hotX, cursor.Height * 2 - hotY); Graphics g = Graphics.FromImage(myNewCursor); g.Clear(Color.FromArgb(0, 0, 0, 0)); g.DrawImage(cursor, cursor.Width - hotX, cursor.Height - hotY, cursor.Width, cursor.Height); this.Cursor = new Cursor(myNewCursor.GetHicon()); g.Dispose(); myNewCursor.Dispose(); } private void startProgress(ProgressBar pBar1) { pBar1.Visible = true;// 显示进度条控件. pBar1.Minimum = 1;// 设置进度条最小值. pBar1.Maximum = 15;// 设置进度条最大值. pBar1.Value = 1;// 设置进度条初始值 pBar1.Step = 1;// 设置每次增加的步长 //创建Graphics对象 Graphics g = pBar1.CreateGraphics(); for (int x = 1; x <= 15; x++) { //执行PerformStep()函数 pBar1.PerformStep(); string str = Math.Round((100 * x / 15.0), 2).ToString("#0.00 ") + "%"; Font font = new Font("Times New Roman", (float)10, FontStyle.Regular); PointF pt = new PointF(pBar1.Width / 2 - 17, pBar1.Height / 2 - 7); g.DrawString(str, font, Brushes.Black , pt); //每次循环让程序休眠300毫秒 System.Threading.Thread.Sleep(300); } pBar1.Visible = false; //MessageBox.Show("success!"); } private void Login_Load(object sender, EventArgs e)//窗体加载 { SoundPlayer bm = new SoundPlayer("Musicbj.wav");//背景音乐 bm.PlayLooping(); Bitmap a = (Bitmap)Bitmap.FromFile("Imagemouse.png"); SetCursor(a, new Point(0, 0)); } } }
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace KillGame { public partial class Logon : Form { public Logon() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e)//注册 { if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" || textBox3.Text.Trim() == "" || textBox4.Text.Trim()=="") { MessageBox.Show("请输入完整信息!"); return; } if(textBox2 .Text .Trim ()==textBox3 .Text .Trim()) { SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog=MBook;Persist Security Info=True;User ID=sa;Password='zdllxf211215'"); string strselect = "insert into TUser values('" + textBox1.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox2.Text.Trim() + "')"; SqlCommand cmd = new SqlCommand(strselect, conn); conn.Open(); int a = cmd.
123456789101112131415161718192021222324252627282930313233343536373839相关知识
花朵消消乐游戏
乐元素徐辉:《开心消消乐》4亿用户背后的故事
花儿消消乐
花朵消消乐游戏规则、技巧、策略及特殊情况应对。
为什么消消乐能让8亿人上瘾?
种花消消乐
消消乐
鲜花消消乐游戏下载
花儿消消乐传奇3APP下载安装
百合花消消乐游戏
网址: C#实现消消乐:从零到一 https://www.huajiangbk.com/newsview1753651.html
上一篇: 花了个花红包版游戏下载 |
下一篇: 花田小院 |
推荐分享

- 1君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039