游戏帮助 [英] game help

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

问题描述

我是C ++的新手,但我想我会尝试制作一款小游戏。它是一张桌子,顶部有A-Z,侧面有1-26。为了这个,我在for循环中使用了数组。现在我需要弄清楚如何获得随机数genorator和用户输入等的坐标(例如,B-14)。我无法解决这个问题,请你帮忙!!?

Hi, iam new to C++, but i thought i''d try making a small game. It is a table, with A-Z across the top and 1-26 down the side. I used arrays in for loops for this. Now i need to work out how to get coordinates (eg, B-14) for random number genorator and user input etc. I cannot work this out, could you please help!!?

推荐答案

每次随机移动使用两次随机数生成器

case:

array [generator()] [generator()];


你是如何构建生成器的?
use your random number generator twice for each random move
case:
array[generator()][generator()];

How is you generator constructed?


谢谢,但它首先得到了我的问题甚至在生成随机问题之前的坐标。这是我的表格代码

Thanks, but its getting the coordinates in the first place that my problem even before generating random ones. this is my code for the table

展开 | 选择 | Wrap | 行号


如果你已经将数组构建为arGame [26] ] [26]然后你有一个矩阵,你可以立即访问没有循环。如果你有一个单维数组,你可以用一点点数学做同样的事情。


所以,对于上面的数组,B-14是一个arGame [1] [13]维度使用以下指南:

Hi, if you have constructed your array as arGame[26][26] then you have a matrix that you can instantly access without loops. If you have a single dimension array you can do the same with a little math.

So, for the above array, B-14 is arGame[1][13] in a single dimension use the following guide:

展开 | 选择 | Wrap | 行号


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

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