这是我的代码段。Filled_Func ()
是按升序对我的“非蛇形”位置进行排序。换句话说,我使用Filled[]
来保存未填充的正方形。 :-)Create_Cookie ()
用于选择cookie的位置,通过time()
获取随机值,并通过调用Draw_Square ()
绘制cookie。
void Filled_Func (void)
{
int Cnt_X, Cnt_Y, Cnt_2, Cnt_3 = 0, Flag = 1;
for (Cnt_X = 0; Cnt_X < 25; Cnt_X++)
{
for (Cnt_Y = 0, Flag = 1; Cnt_Y < 25; Cnt_Y++)
{
for (Cnt_2 = 0 ; Cnt_2 < Move.Snake_Length; Cnt_2++)
{
if (Move.Position[Cnt_2].X == Cnt_X && Move.Position[Cnt_2].Y == Cnt_Y)
{
Flag = 0;
break;
}
}
if (Flag == 1)
{
Filled[Cnt_3].X = Cnt_X;
Filled[Cnt_3].Y = Cnt_Y;
Cnt_3++;
}
}
}
}
void Create_Cookie (HDC DeviceContext)
{
Filled_Func ();
int Rand = clock()%(625-Move.Snake_Length);
Cookie.X = Filled[Rand].X;
Cookie.Y = Filled[Rand].Y;
Draw_Square (Cookie.X, Cookie.Y, UP, RGB( 0 ,255, 0 ), -1, -1, UP, RGB(255,255,255), 0, DeviceContext);
}
我在Github上的存储库。
我在plain text (v1.00)中的完整C代码。
我在plain text (v1.01)中的完整C代码。 (我已将
Filled[]
更改为Unfilled[]
)下载executable and code。
任何帮助,建议和忠告将不胜感激。 :-)
添加于11月30日上午11:00(格林尼治标准时间上午3:00)
我通过输出日志文件来跟踪蛇坐标:
格式:蛇形坐标
-->
cookie坐标(12,12) (12,13) --> [17,06]
(17,06) (17,07) (17,08) --> [23,18]
(23,15) (23,16) (23,17) (23,18) --> [18,00]
(14,00) (15,00) (16,00) (17,00) (18,00) --> [22,14]
(17,14) (18,14) (19,14) (20,14) (21,14) (22,14) --> [04,06]
(04,06) (04,07) (05,07) (06,07) (07,07) (08,07) (09,07) --> [19,11]
(19,11) (20,11) (21,11) (22,11) (23,10) (23,11) (24,10) (24,11) --> [20,04]
(18,10) (19,10) (20,04) (20,05) (20,06) (20,07) (20,08) (20,09) (20,10) --> [16,18]
(09,19) (09,20) (10,19) (11,19) (12,19) (13,19) (14,19) (15,19) (16,18) (16,19) --> [19,07]
(19,07) (19,08) (19,09) (19,10) (19,11) (19,12) (20,08) (20,09) (20,10) (20,11) (20,12) --> [21,18]
(20,13) (20,14) (20,15) (20,16) (20,17) (20,18) (21,13) (21,14) (21,15) (21,16) (21,17) (21,18) --> [24,06]
(22,06) (22,07) (22,08) (22,09) (22,10) (22,11) (22,12) (22,13) (22,14) (22,15) (22,16) (23,06) (24,06) --> [18,15]
(17,04) (17,05) (17,06) (17,07) (17,08) (17,09) (17,10) (17,11) (17,12) (17,13) (17,14) (17,15) (18,04) (18,15) --> [00,18]
(00,15) (00,16) (00,17) (00,18) (17,12) (17,13) (17,14) (17,15) (18,15) (19,15) (20,15) (21,15) (22,15) (23,15) (24,15) --> [13,06]
(04,00) (05,00) (06,00) (07,00) (08,00) (09,00) (10,00) (11,00) (12,00) (13,00) (13,01) (13,02) (13,03) (13,04) (13,05) (13,06) --> [15,21]
(13,07) (13,08) (13,09) (13,10) (13,11) (13,12) (13,13) (13,14) (13,15) (13,16) (13,17) (13,18) (13,19) (13,20) (13,21) (14,21) (15,21) --> [18,13]
(13,21) (14,21) (15,21) (16,21) (17,21) (18,13) (18,21) (19,13) (19,21) (20,13) (20,14) (20,15) (20,16) (20,17) (20,18) (20,19) (20,20) (20,21) --> [24,18]
(12,16) (12,17) (12,18) (12,19) (12,20) (13,20) (14,20) (15,20) (16,20) (17,20) (18,20) (19,20) (20,20) (21,20) (22,20) (23,20) (24,18) (24,19) (24,20) --> [21,17]
(03,18) (04,18) (05,18) (06,18) (07,18) (08,18) (09,18) (10,18) (11,18) (12,18) (13,18) (14,18) (15,17) (15,18) (16,17) (17,17) (18,17) (19,17) (20,17) (21,17) --> [04,02]
(04,02) (05,02) (06,02) (07,02) (08,02) (09,02) (10,02) (11,02) (12,02) (13,02) (14,02) (15,02) (15,03) (15,04) (15,05) (15,06) (15,07) (15,08) (15,09) (15,10) (15,11) --> [19,01]
(17,01) (17,02) (17,03) (17,04) (17,05) (17,06) (17,07) (17,08) (17,09) (17,10) (17,11) (17,12) (17,13) (17,14) (17,15) (17,16) (17,17) (17,18) (17,19) (17,20) (18,01) (19,01) --> [08,17]
(02,01) (03,01) (04,01) (05,01) (06,01) (06,02) (06,03) (06,04) (06,05) (06,06) (06,07) (06,08) (06,09) (06,10) (06,11) (06,12) (06,13) (06,14) (06,15) (06,16) (06,17) (07,17) (08,17) --> [23,14]
(01,15) (02,15) (03,15) (04,15) (05,15) (06,15) (07,15) (08,15) (09,15) (10,15) (11,15) (12,15) (13,15) (14,15) (15,15) (16,15) (17,15) (18,15) (19,15) (20,15) (21,15) (22,15) (23,14) (23,15) --> [24,09]
(01,08) (02,08) (03,08) (04,08) (05,08) (06,08) (07,08) (08,08) (09,08) (10,08) (11,08) (12,08) (13,08) (14,08) (15,08) (16,08) (17,08) (18,08) (19,08) (20,08) (21,08) (22,08) (23,08) (24,08) (24,09) --> [24,10]
(01,08) (02,08) (03,08) (04,08) (05,08) (06,08) (07,08) (08,08) (09,08) (10,08) (11,08) (12,08) (13,08) (14,08) (15,08) (16,08) (17,08) (18,08) (19,08) (20,08) (21,08) (22,08) (23,08) (24,08) (24,09) (24,10) --> [00,01]
(00,01) (00,02) (01,02) (02,02) (03,02) (04,02) (05,02) (06,02) (07,02) (08,02) (09,02) (10,02) (11,02) (12,02) (13,02) (14,02) (15,02) (16,02) (17,02) (18,02) (19,02) (20,02) (21,02) (22,02) (23,02) (24,01) (24,02) --> [08,03]
(00,04) (00,05) (00,06) (00,07) (00,08) (00,09) (00,10) (01,04) (02,04) (03,04) (04,04) (05,04) (06,04) (07,04) (08,00) (08,01) (08,02) (08,03) (08,04) (08,23) (08,24) (09,00) (09,01) (09,02) (09,03) (09,04) (09,23) (09,24) --> [19,04]
(08,00) (08,01) (08,02) (08,03) (08,04) (08,05) (08,06) (08,07) (08,08) (08,09) (08,23) (08,24) (09,09) (09,23) (10,09) (11,09) (12,09) (13,09) (14,09) (15,09) (16,09) (17,09) (18,09) (19,04) (19,05) (19,06) (19,07) (19,08) (19,09) --> [24,09]
(13,09) (14,09) (15,09) (16,09) (17,09) (18,09) (19,00) (19,01) (19,02) (19,03) (19,04) (19,05) (19,06) (19,07) (19,08) (19,09) (20,00) (21,00) (22,00) (23,00) (24,00) (24,01) (24,02) (24,03) (24,04) (24,05) (24,06) (24,07) (24,08) (24,09) --> [16,01]
(14,01) (14,02) (14,03) (14,04) (14,05) (14,06) (14,07) (14,08) (14,09) (14,10) (14,11) (14,12) (14,13) (14,14) (15,01) (15,14) (16,01) (16,14) (17,14) (18,14) (19,14) (20,14) (21,14) (22,14) (23,14) (24,09) (24,10) (24,11) (24,12) (24,13) (24,14) --> [02,12]
(02,02) (02,03) (02,04) (02,05) (02,06) (02,07) (02,08) (02,09) (02,10) (02,11) (02,12) (03,02) (03,11) (03,12) (04,11) (04,12) (05,11) (05,12) (06,11) (06,12) (07,11) (07,12) (08,11) (08,12) (09,11) (09,12) (10,11) (10,12) (11,11) (11,12) (12,11) (12,12) --> [08,04]
(08,00) (08,01) (08,02) (08,03) (08,04) (08,23) (08,24) (09,23) (10,23) (11,23) (12,23) (13,23) (14,00) (14,01) (14,02) (14,03) (14,04) (14,05) (14,06) (14,07) (14,08) (14,09) (14,10) (14,11) (14,12) (14,23) (14,24) (15,12) (16,12) (17,12) (18,12) (19,12) (20,12) --> [24,17]
(08,00) (08,01) (08,02) (08,03) (08,04) (08,05) (08,06) (08,07) (08,08) (08,09) (08,10) (08,11) (08,12) (08,13) (08,14) (09,14) (10,14) (11,14) (12,14) (13,14) (14,14) (15,14) (16,14) (17,14) (18,14) (19,14) (20,14) (21,14) (22,14) (23,14) (24,14) (24,15) (24,16) (24,17) --> [12,05]
(10,04) (10,05) (10,06) (10,07) (10,08) (10,09) (11,04) (11,09) (12,04) (12,05) (12,09) (13,04) (13,05) (13,09) (14,04) (14,05) (14,09) (15,04) (15,05) (15,09) (16,04) (16,05) (16,09) (17,04) (17,05) (17,09) (18,09) (19,09) (19,10) (19,11) (19,12) (19,13) (19,14) (19,15) (19,16) --> [03,04]
(02,00) (02,01) (02,02) (02,03) (02,04) (02,05) (02,23) (02,24) (03,04) (03,05) (03,23) (04,00) (04,01) (04,02) (04,03) (04,04) (04,05) (04,23) (04,24) (05,04) (05,05) (06,04) (06,05) (07,04) (07,05) (08,04) (08,05) (09,05) (10,05) (11,05) --> [22,16]
(00,04) (01,04) (02,04) (03,04) (04,04) (05,04) (06,04) (06,05) (07,04) (07,05) (08,04) (08,05) (17,04) (17,05) (17,06) (17,07) (17,08) (17,09) (17,10) (17,11) (17,12) (17,13) (17,14) (17,15) (17,16) (18,04) (18,16) (19,04) (19,16) (20,04) (20,16) (21,04) (21,16) (22,04) (22,16) (23,04) (24,04) --> [24,17]
(04,16) (05,16) (06,16) (07,16) (08,16) (09,16) (10,16) (11,16) (12,16) (13,16) (14,16) (15,16) (16,16) (17,16) (18,16) (19,16) (20,16) (21,16) (22,16) (23,00) (23,16) (23,17) (23,18) (23,19) (23,20) (23,21) (23,22) (23,23) (23,24) (24,00) (24,17) (24,18) (24,19) (24,20) (24,21) (24,22) (24,23) (24,24) --> [18,09]
(05,09) (05,10) (06,09) (06,10) (07,09) (07,10) (08,09) (08,10) (09,09) (09,10) (10,09) (10,10) (11,09) (11,10) (12,09) (12,10) (13,09) (13,10) (14,09) (14,10) (15,09) (15,10) (16,09) (16,10) (17,09) (17,10) (18,09) (18,10) (19,10) (20,10) (20,11) (21,10) (21,11) (22,10) (22,11) (23,10) (23,11) (24,10) (24,11) --> [01,11]
(01,11) (01,12) (01,13) (01,14) (01,15) (01,16) (01,17) (01,18) (01,19) (01,20) (02,08) (02,09) (02,10) (02,11) (02,12) (02,13) (02,14) (02,15) (02,16) (02,17) (02,18) (02,19) (02,20) (03,08) (04,08) (05,08) (06,08) (07,08) (08,08) (09,08) (10,08) (11,08) (12,08) (13,08) (14,08) (15,08) (16,08) (17,08) (18,08) (19,08) --> [14,01]
(01,09) (01,10) (02,09) (03,09) (04,09) (05,09) (06,09) (07,09) (08,09) (09,09) (10,09) (11,09) (12,09) (13,00) (13,01) (13,02) (13,03) (13,04) (13,05) (13,06) (13,07) (13,08) (13,09) (14,00) (14,01) (15,00) (15,01) (16,00) (16,01) (17,00) (17,01) (18,00) (18,01) (19,00) (19,01) (20,00) (20,01) (21,00) (21,01) (22,00) (22,01) --> [24,01]
(07,01) (07,02) (07,03) (08,01) (08,03) (09,01) (09,03) (10,01) (10,03) (11,01) (11,03) (12,01) (12,03) (13,01) (13,03) (14,01) (14,03) (15,01) (15,03) (16,01) (16,03) (17,01) (17,03) (18,00) (18,01) (18,03) (19,00) (19,01) (19,03) (20,00) (20,01) (20,03) (21,00) (21,01) (21,03) (22,00) (22,01) (22,03) (23,03) (24,01) (24,02) (24,03) --> [23,18]
(09,03) (10,03) (11,03) (12,03) (13,03) (14,03) (15,03) (15,20) (15,21) (16,03) (16,20) (16,21) (17,03) (17,20) (17,21) (18,03) (18,20) (18,21) (19,03) (19,20) (19,21) (20,03) (20,20) (20,21) (21,03) (21,20) (21,21) (22,03) (22,20) (22,21) (23,03) (23,18) (23,19) (23,20) (23,21) (24,00) (24,01) (24,02) (24,03) (24,21) (24,22) (24,23) (24,24) --> [05,18]
(05,12) (05,13) (05,14) (05,15) (05,16) (05,17) (05,18) (06,12) (07,12) (08,12) (09,12) (10,12) (11,12) (12,12) (13,12) (14,12) (15,12) (15,20) (15,21) (16,12) (16,20) (16,21) (17,12) (17,20) (17,21) (18,12) (18,20) (19,12) (19,20) (20,12) (20,20) (21,12) (21,20) (22,12) (22,20) (23,12) (23,13) (23,14) (23,15) (23,16) (23,17) (23,18) (23,19) (23,20) --> [23,06]
(00,05) (00,06) (01,05) (01,06) (10,19) (11,19) (12,19) (13,19) (14,19) (15,19) (16,19) (17,19) (18,10) (18,11) (18,12) (18,13) (18,14) (18,15) (18,16) (18,17) (18,18) (18,19) (19,10) (20,04) (20,05) (20,10) (21,04) (21,05) (21,10) (22,04) (22,05) (22,10) (23,04) (23,05) (23,06) (23,10) (24,04) (24,05) (24,06) (24,07) (24,08) (24,09) (24,10) --> [06,07]
(00,06) (01,06) (06,07) (06,08) (06,09) (06,10) (06,11) (06,12) (06,13) (06,14) (06,15) (06,16) (06,17) (06,18) (06,19) (07,06) (07,07) (07,08) (07,09) (07,10) (07,11) (07,12) (07,13) (07,14) (07,15) (07,16) (07,17) (07,18) (07,19) (08,06) (09,06) (10,06) (11,06) (12,06) (13,06) (14,06) (15,06) (16,06) (17,06) (18,06) (19,06) (20,06) (21,06) (22,06) (23,06) (24,06) --> [14,07]
(06,05) (06,06) (06,07) (06,08) (06,09) (06,10) (06,11) (06,12) (06,13) (06,14) (06,15) (06,16) (06,17) (06,18) (06,19) (07,05) (07,06) (07,07) (07,08) (07,09) (07,10) (07,11) (07,12) (07,13) (07,14) (07,15) (07,16) (07,17) (07,18) (07,19) (08,05) (08,06) (09,05) (09,06) (10,05) (10,06) (11,05) (11,06) (12,05) (12,06) (13,05) (13,06) (14,05) (14,06) (14,07) (15,06) --> [18,20]
(06,05) (06,06) (06,07) (07,05) (08,05) (09,05) (10,05) (11,05) (12,05) (13,05) (14,05) (14,06) (14,07) (14,08) (14,09) (14,10) (14,11) (14,12) (14,13) (14,14) (14,15) (14,16) (14,17) (14,18) (14,19) (15,19) (16,19) (17,19) (18,19) (18,20) (18,21) (18,22) (18,23) (19,19) (19,23) (20,19) (20,23) (21,19) (21,23) (22,19) (22,23) (23,19) (23,23) (24,19) (24,20) (24,21) (24,22) (24,23) --> [23,20]
(14,17) (14,18) (14,19) (15,19) (16,19) (17,19) (18,14) (18,15) (18,16) (18,17) (18,18) (18,19) (18,20) (18,21) (18,22) (18,23) (19,14) (19,19) (19,23) (20,14) (20,19) (20,23) (21,14) (21,19) (21,23) (22,14) (22,19) (22,23) (23,14) (23,19) (23,20) (23,21) (23,22) (23,23) (24,14) (24,15) (24,16) (24,17) (24,18) (24,19) (24,20) (24,21) (24,22) (24,23) --> [08,24]
(07,12) (07,13) (07,14) (07,15) (07,16) (07,17) (07,18) (07,19) (07,20) (07,21) (07,22) (07,23) (07,24) (08,12) (08,24) (09,12) (10,12) (11,12) (12,12) (13,12) (14,12) (15,12) (16,12) (17,12) (18,12) (19,12) (20,12) (21,12) (22,12) (23,12) (23,13) (23,14) (23,15) (23,16) (23,17) (23,18) (23,19) (23,20) (23,21) (23,22) (24,14) (24,15) (24,16) (24,17) (24,18) (24,19) (24,20) (24,21) (24,22) --> [01,03]
(01,03) (01,04) (02,04) (03,04) (04,04) (05,04) (06,04) (07,04) (07,12) (07,13) (07,14) (07,15) (07,16) (07,17) (07,18) (07,19) (07,20) (07,21) (07,22) (07,23) (07,24) (08,04) (08,12) (08,24) (09,04) (09,12) (09,24) (10,04) (10,12) (10,24) (11,04) (11,12) (11,24) (12,04) (12,24) (13,04) (13,24) (14,04) (14,24) (15,04) (15,24) (16,04) (16,24) (17,04) (17,24) (18,00) (18,01) (18,02) (18,03) (18,04) (18,24) --> [15,03]
(01,00) (01,01) (01,02) (01,03) (01,04) (01,11) (01,12) (01,13) (01,14) (01,15) (01,16) (01,17) (01,18) (01,19) (01,20) (01,21) (01,22) (01,23) (01,24) (02,04) (02,11) (03,04) (03,11) (04,04) (04,11) (05,04) (05,11) (06,04) (06,11) (07,04) (07,11) (08,04) (08,11) (09,04) (09,11) (10,04) (10,11) (11,04) (11,11) (12,04) (12,11) (13,11) (14,11) (15,03) (15,04) (15,05) (15,06) (15,07) (15,08) (15,09) (15,10) (15,11) --> [13,10]
(01,11) (01,12) (01,13) (01,14) (01,15) (01,16) (01,17) (01,18) (01,19) (01,20) (01,21) (02,11) (03,11) (04,11) (05,11) (06,11) (07,11) (08,11) (09,11) (10,11) (11,11) (12,11) (13,10) (13,11) (14,10) (14,11) (15,00) (15,01) (15,02) (15,03) (15,04) (15,05) (15,06) (15,07) (15,08) (15,09) (15,10) (15,11) (15,12) (15,13) (15,14) (15,15) (15,16) (15,17) (15,18) (15,19) (15,20) (15,21) (15,22) (15,23) (15,24) --> [17,09]
(06,09) (06,10) (07,09) (07,10) (08,09) (08,10) (09,09) (09,10) (09,11) (10,09) (10,10) (10,11) (11,09) (11,10) (11,11) (12,09) (12,10) (12,11) (13,09) (13,10) (13,11) (14,09) (14,10) (14,11) (15,00) (15,01) (15,02) (15,03) (15,04) (15,05) (15,06) (15,07) (15,08) (15,09) (15,10) (15,11) (15,12) (15,13) (15,14) (15,15) (15,16) (15,17) (15,18) (15,19) (15,20) (15,21) (15,22) (15,23) (15,24) (16,09) (17,09) --> [18,19]
(12,13) (12,14) (12,15) (12,16) (12,17) (12,18) (13,13) (13,18) (14,10) (14,11) (14,12) (14,13) (14,14) (14,15) (14,16) (14,17) (14,18) (14,19) (14,20) (15,10) (15,13) (15,18) (15,20) (16,10) (16,13) (16,18) (16,20) (17,10) (17,13) (17,18) (17,20) (18,10) (18,13) (18,18) (18,19) (18,20) (19,10) (19,13) (19,14) (19,15) (19,16) (19,17) (19,18) (19,19) (19,20) (20,09) (20,10) (21,09) (21,10) (22,09) (22,10) --> [04,09]
(04,09) (04,10) (04,11) (04,12) (04,13) (04,14) (04,15) (04,16) (04,17) (04,18) (04,19) (05,19) (06,19) (07,19) (08,19) (09,19) (10,19) (11,19) (12,13) (12,14) (12,15) (12,16) (12,17) (12,18) (12,19) (13,13) (13,18) (13,19) (14,13) (14,18) (14,19) (15,13) (15,18) (15,19) (16,13) (16,18) (16,19) (16,20) (17,13) (17,18) (17,19) (17,20) (18,13) (18,18) (18,19) (18,20) (19,13) (19,14) (19,15) (19,16) (19,17) (19,18) (19,19) (19,20) --> [01,13]
(01,11) (01,12) (01,13) (02,11) (03,11) (04,09) (04,10) (04,11) (04,12) (04,13) (04,14) (04,15) (04,16) (04,17) (04,18) (04,19) (05,09) (05,11) (05,19) (06,09) (06,11) (06,19) (07,09) (07,11) (07,19) (08,09) (08,11) (08,19) (09,09) (09,11) (09,19) (10,09) (10,10) (10,11) (10,19) (11,19) (12,14) (12,15) (12,16) (12,17) (12,18) (12,19) (13,18) (13,19) (14,18) (14,19) (15,18) (15,19) (16,18) (16,19) (17,18) (17,19) (18,18) (18,19) (19,18) (19,19) --> [11,06]
(01,11) (01,12) (01,13) (01,14) (01,15) (01,16) (01,17) (01,18) (01,19) (02,11) (02,19) (03,11) (03,19) (04,11) (04,19) (05,11) (05,19) (06,11) (06,19) (07,11) (07,19) (08,11) (08,19) (09,09) (09,11) (09,19) (10,05) (10,06) (10,07) (10,08) (10,09) (10,10) (10,11) (10,12) (10,13) (10,14) (10,15) (10,16) (10,17) (10,18) (10,19) (11,05) (11,06) (12,05) (12,06) (13,05) (13,06) (14,05) (14,06) (15,05) (15,06) (16,05) (16,06) (17,05) (17,06) --> [24,11]
(06,19) (07,06) (07,07) (07,19) (08,06) (08,07) (08,19) (09,06) (09,07) (09,19) (10,05) (10,06) (10,07) (10,08) (10,09) (10,10) (10,11) (10,12) (10,13) (10,14) (10,15) (10,16) (10,17) (10,18) (10,19) (11,05) (11,06) (11,07) (12,05) (12,06) (12,07) (13,05) (13,06) (13,07) (14,05) (14,06) (14,07) (15,05) (15,06) (15,07) (16,05) (16,06) (16,07) (17,05) (17,06) (17,07) (18,07) (19,07) (20,07) (21,07) (22,07) (23,07) (24,07) (24,08) (24,09) (24,10) (24,11) --> [04,01]
(00,00) (00,01) (01,00) (01,01) (02,00) (02,01) (03,00) (03,01) (04,00) (04,01) (05,00) (05,01) (05,02) (05,03) (05,04) (05,05) (05,06) (05,07) (05,08) (05,09) (05,10) (05,11) (05,12) (05,13) (05,14) (05,15) (05,16) (05,17) (05,18) (05,19) (05,20) (05,21) (05,22) (05,23) (05,24) (06,05) (07,05) (08,05) (09,05) (10,05) (11,05) (12,05) (13,05) (14,05) (15,05) (16,05) (16,06) (16,07) (16,08) (16,09) (23,00) (23,01) (24,00) (24,01) --> [24,12]
(00,00) (00,01) (00,11) (00,13) (01,00) (01,01) (01,11) (01,13) (02,00) (02,01) (02,11) (02,13) (03,01) (03,11) (03,13) (04,01) (04,11) (04,13) (05,01) (05,11) (05,13) (06,01) (06,11) (06,13) (07,01) (07,11) (07,12) (07,13) (08,01) (09,01) (10,01) (11,01) (12,01) (13,01) (14,01) (15,01) (16,01) (17,01) (18,01) (19,01) (20,01) (21,01) (22,01) ****(23,00)**** (23,01) (23,02) (23,03) (23,04) (23,05) (23,06) (23,07) (23,08) (23,09) (23,10) (23,11) (24,00) (24,01) (24,11) (24,12) (24,13) --> [23,00]
看到发生错误的最后一行:在(23,00)创建零食(cookie),但是(23,00)已经被蛇占据了!!!
为什么?有人可以帮我吗?任何帮助,建议和忠告将不胜感激。 :-)
最佳答案
无需详细阅读代码:您似乎只用未填充的坐标填充了Filled [index]标签。然后,您随机选择其中之一。
在那种情况下,我希望在测试蛇是否占据坐标的地方看到一些比仅具有“ Flag = 0”的指令更长的指令。您需要确保“移动”剩余的Filled [index],以便仅未填充的坐标保留在该数组中! (想想:链接列表,并删除一条,因为它现在被蛇“填充”了)
关于c - 蛇游戏:为什么“(有时低于10%)”的零食( cookies )会在蛇身上产生?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20289944/