简单的飞行棋案例

游戏规则:

  1. 两个人轮流掷骰子红人和绿人

  2. 投掷出2,4,6点出门,投掷出6点可以在出门后再次投掷行走

  3. 地图长度共100步

  4. 地图中除过普通地板之外,另设六种特殊功能地板

    1. 踩到香蕉皮,退6步

    2. 踩到时空,前进6步

    3. 踩到陷阱,暂停一回合

    4. 踩到星星,可以再投掷一次

    5. 踩到移魂大法,可以做出选择与对方互换位置

    6. 踩到手枪,可以击退对方3步

    7. 踩到大炮,可以直接将对方轰炸回家(需要重新出门)

  5. 如果踩到对方,则对方直接回到起点,

游戏策划

  1. 地图面积30*13

  2. 每个格子30像素

  3. 地面的代号=0,普通地板=1,香蕉皮=2,时空=3,陷阱=4,星星=5,大挪移=6,手枪=7

    红人=8,绿人=9

    起点=10,终点=11

    两人在同一位置=12

 

 

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 Mep = new Panel();
        //玩家棋外圈
        Panel redplayHome = new Panel();
        Panel greenplayHome = new Panel();
        //这个数组是所有的地板的一个数组,游戏逻辑全部取决于数字数组
        int[] mapList = new int[390];
        const int size = 30;
        //这个数组是所有的图片,根据maplist决定每个元素的内容
        PictureBox[] mapImg = new PictureBox[390];
        //这个数组用来记录所有的路的索引位置
        int[] road = new int[100];
        //机关位置
        int[] back = { 7, 27, 42, 62, 73, 96 };
        int[] forword = { 10, 25, 33, 65, 80, 88 };
        int[] stop = { 3, 20, 35, 50, 60, 70, 90 };
        int[] star = { 5, 28, 45, 71, 85 };
        int[] change = { 4, 55, 75, 98 };
        int[] gun = { 11, 32, 66, 83 };
        //记录框
        RichTextBox msg = new RichTextBox();
        //随机数
        Random r = new Random();
        //色子
        PictureBox dice = new PictureBox();
        //记录谁可以投掷
        //索引为0代表红方,索引为1代表绿方
        bool[] whoCan = new bool[2] { true, false };
        //双方投掷出的点数
        int[] startNum = new int[2];
        string[] playName = new string[2] { "红方", "绿方" };
        //记录双方当前的位置
        int[] playPostion = new int[2] { -1, -1 };
        int[] playStand = new int[2] { -1, -1 };
        private void Form1_Load(object sender, EventArgs e)
        {
            //边框不可调整
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            //背景色
            this.BackColor = Color.FloralWhite;
            //界面框大小
            this.Size = new Size(1300,700);
            //居中
            this.Location = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2,Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2);
            //游戏说明设置
            listBox1.Size = new Size(400,200);
            listBox1.Location = new Point(400,30);
            游戏区设置
            //游戏区大小
            Mep.Size = new Size(30 * size,13 * size);
            //游戏区位置
            Mep.Location = new Point(50, 250);
            //边框
            Mep.BorderStyle = BorderStyle.FixedSingle;
            this.Controls.Add(Mep);

            //游戏地图覆盖图片函数
            game();

            //玩家棋外圈
            //Panel redplayHome = new Panel();
            redplayHome.Size = new Size(100, 100);
            redplayHome.BackgroundImage = Image.FromFile("../../img/select_circle.png");
            redplayHome.Location = new Point(50, Mep.Top - 120);
            redplayHome.BackgroundImageLayout = ImageLayout.Stretch;
            this.Controls.Add(redplayHome);
            //玩家棋外圈
            //Panel greenplayHome = new Panel();
            greenplayHome.Size = new Size(100, 100);
            greenplayHome.BackgroundImage = Image.FromFile("../../img/select_circle.png");
            greenplayHome.Location = new Point(170, Mep.Top - 120);
            greenplayHome.BackgroundImageLayout = ImageLayout.Stretch;
            this.Controls.Add(greenplayHome);
            //红玩家棋
            PictureBox redPlayer = new PictureBox();
            redPlayer.Size = new Size(80, 80);
            redPlayer.Image = Image.FromFile("../../img/red.png");
            redPlayer.Location = new Point(10, 10);
            redPlayer.SizeMode = PictureBoxSizeMode.StretchImage;
            redplayHome.Controls.Add(redPlayer);
            //绿玩家棋
            PictureBox greenPlayer = new PictureBox();
            greenPlayer.Size = new Size(80, 80);
            greenPlayer.Image = Image.FromFile("../../img/green.png");
            greenPlayer.Location = new Point(10, 10);
            greenPlayer.SizeMode = PictureBoxSizeMode.StretchImage;
            greenplayHome.Controls.Add(greenPlayer);
            //记录框
            msg.Size = new Size(260, 600);
            msg.Location = new Point(Mep.Right + 20, 50);
            msg.ReadOnly = t
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值