c#简易的金山打字游戏

这篇博客介绍了如何使用c#制作一个简单的金山打字游戏,该项目同时也是飞机大战游戏的基础。主要内容包括创建游戏区,随机生成字母,字母下落效果,飞机跟随字母移动以及子弹与字母碰撞消失等实现细节。还特别提到了通过字母跟随小动画增加游戏趣味性。
摘要由CSDN通过智能技术生成

c#简单的金山打字游戏,也是飞机大战的雏形,是c#练习基础的项目

效果图如下

大致思路:

创建游戏区 :设置所需属性

创建字母生成:随机大小和字母

字母下落

创建飞机:添加事件,飞机跟随字母移动

创建子弹:子弹上升,碰到字母消失

其余小细节自己需要处理

注意:为了不使项目那么突兀,加了一个小的移动动画:

字母跟随鸟的移动创建字母

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 金山打字
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Panel lb = new Panel();
        Random r = new Random();
        //字母生成
        Timer zm = new Timer();
        //字母下落
        Timer xq = new Timer();
        //动画移动
        Timer move = new Timer();
        //创建鸟盒子
        PictureBox bird = new PictureBox();
        //创建飞机
        PictureBox plan = new PictureBox();
       //创建动画计时器
        Timer fly = new Timer();
        //创建的得分的label
        Label df = new Label();  int x = 0;
        //实例化血条
        Label xt = new Label();
        Label xt1 = new Label();
        int dl = 0;
        private void Form1_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            this.Text = "金山打字";
            this.BackgroundImage = Image.FromFile(@"../../img/2.jpg");
            this.BackgroundImageLayout = ImageLayout.Stretch;
           //游戏区域
           
            lb.Width = 1300;
            lb.Height = 780;
            lb.BackColor = Color.Brown;
            this.Controls.Add(lb);
            //开始游戏
            Label ks = new Label();
            ks.Size = new Size(120, 20);
            ks.BackColor = Color.White;
            ks.Location = new Point(1380, 100);
            ks.Tag = "ksyx";
            ks.T
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值