关于游戏创作 [英] about game creation

查看:55
本文介绍了关于游戏创作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计一个游戏,所以我不确定是否将5个随机数存储到一个数组中,并使用随机数我想用颜色来闪烁按钮,请建议我创建游戏及其第一个项目.... ........

i want design a game,so i have doubts in store 5 random numbers into a array and using the random numbers i want to blink the buttons with colors please suggest me to create the game and its my first project............

推荐答案

随机数很简单-有一个随机类:
Random numbers are easy - there is a Random Class:
private Random rand = new Random();
private void FillRandom(int[] numbers, int min, int max)
    {
    for (int i = 0; i < numbers.Length; i++)
        {
        numbers[i] = rand.Next(min, max + 1);
        }
    }

将很高兴用随机数填充任何整数数组.

之后,您可能需要一个Timer(具有适当的间隔)并处理它的Tick事件:

Will happily fill any array of ints with random numbers.

After that, you will probably need a Timer (with a suitable interval) and to handle it''s Tick event:

    ...
    Timer myTimer = new Timer();
    myTimer.Interval = 100;     // 1/10th second
    myTimer.Tick += new EventHandler(myTimer_Tick);
    myTimer.Start();
    }

void myTimer_Tick(object sender, EventArgs e)
    {

    }

您在Tick事件处理程序中添加了什么?好吧,这很难-因为这取决于您的游戏要做什么!由于我一无所知,所以我无法开始为您服务! :laugh:

What do you put in the Tick event handler? Well that''s harder - because it depends on what your game is going to do! Since I have no idea at all, I can''t begin to help you! :laugh:


这篇关于关于游戏创作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆