游戏:我的游戏是一个简单的游戏,它从txt文件中获取单词列表,并将它们放到网格中。然后对单词进行混洗(在3*3网格上显示9个单词,其中一个替换为未使用的备用单词),然后用户必须猜测被替换的单词是什么,以及替换它的单词是什么。如果用户是正确的,他们就会移动到一个更难的级别,这是一个4*4的网格。
问题:我一直在尝试通过检查列表中被洗牌的单词的位置来验证用户的输入,所以我试图检查列表中的第十个单词,因为这是被替换的单词。
代码脚本:"Global_Variables“-
> globalvar WordCount; globalvar WordColumn; globalvar WordRow;
> globalvar WordList; globalvar GridList; globalvar LineGap; globalvar
> WildCard; globalvar BoxSize; globalvar BoxIndent; globalvar BoxHeader;
> globalvar TimerIndent;"Readfile“-
> filop = file_text_open_read(working_directory + "Words.txt");
> wordgridlist = ds_list_create(); gridcreate = ds_list_create();
> while(!file_text_eof(filop)){
> line = string_upper(file_text_readln(filop));
> ds_list_add(wordgridlist, line);
> } file_text_close(filop); wordgridlistshuffled =
> ds_list_shuffle(wordgridlist) "Output" - draw_set_colour(c_red)
> draw_set_font(Text_Font) Text_Grid = 0 for (X=0; X<3; X+=1){
> for (Y=0; Y<3; Y+=1){
> draw_text((X*710)+250,
> (Y*244)+300,ds_list_find_value(wordgridlist,Text_Grid));
> Text_Grid +=1
>
> }
> }"Word_Question“-
> WordChangedEasy = get_string("What word changed?", "");
> WordChangedEasyAnswer = ds_list_shuffle(10); WordReplacedEasy =
> get_string("What word has been replaced?", "");发布于 2016-06-21 19:28:18
我从GameMaker:用户手册中找到了这篇文章。
ds_list_find_value
查找保存在列表中给定位置的值。语法: ds_list_find_value(id,pos);
id:要使用的列表的id。
pos:要查看的位置,其中0对应于列表的最开始位置,最终位置是ds_list_size(id)-1。
您应该使用ds_list_find_value(wordgridlist,9)来查找第十个值。
https://stackoverflow.com/questions/35842613
复制相似问题