本文介绍了帮助代码(解析错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我刚刚开始制作游戏。到目前为止它是一个数组

25乘20并尝试在其中创建五个房间。

在scr_make_room()中有解析错误:

20 C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ; first_square_x"

35 C:\\\\\\\\\\\\\\\\\\\\\\\\ ?


int room_square [25] [20],selected = 1,squares = 1,first_square_x

= -1,first_square_y = 1;

void scr_make_room(void)//建一个房间

{

int top_x,roomx,top_y,宽敞,xplus,yplus;


top_x = 8; // floor(random(21))+ 1 //稍后当

roomx = 5时这样做; // floor(random(8))+ 1 //我可以随机使用()

top_y = 12; // floor(random(16))+ 1 //和floor()

roomy = 5; //楼层(随机(8))+ 1


//将房间内的所有墙面方块转到地板上

for(xplus = 0; xplus < roomx; xplus ++)

{

for(yplus = 0; yplus< roomy; xplus ++)

{


//确保它在房间里

20:如果top_x + xplus< 24&& top_y + yplus< 19 // *** PARSE

错误

{

如果room_square [top_x + xplus] [top_y + yplus] == 0 //如果

有墙

{

room_square [top_x + xplus] [top_y + yplus] = 1; //制作

它的地板

square + = 1; //增加制作的正方形数量


//记录第一个正方形(永远)

28:如果first_square_x == -1 // ** * PARSE ERROR

{

first_square_x = top_x + xplus;

first_square_y = top_y + yplus;

} / / endi

} // endi wall

} //在房间里结束

35:} //结束为y // *** PARSE ERROR

} //结束x

} //结束scr_make_room()


int main()

{

int i,j;


for(i = 0; i< 25; i ++)

{

for(j = 0; j< 20; i ++)

{

room_square [i] [j] = 0 ;

}

}


for(i = 0; i< 5; i + = 1)//制作5个房间

{

scr_make_room();

}


返回0;

}

Basically I''ve just started making a game. So far it makes an array
25 by 20 and tries to make five rooms within it.
In scr_make_room() there''s parse errors:
20 C:\c\Rooms\Untitled1.c parse error before "top_x"
28 C:\c\Rooms\Untitled1.c parse error before "first_square_x"
35 C:\c\Rooms\Untitled1.c parse error before ''}'' token

Why are these happening?

int room_square[25][20], selected = 1, squares = 1, first_square_x
= -1, first_square_y = 1;
void scr_make_room(void) //Make a room
{
int top_x, roomx, top_y, roomy, xplus, yplus;

top_x = 8; //floor(random(21))+1 //Do this later when
roomx = 5; //floor(random(8))+1 //I can use random()
top_y = 12; //floor(random(16))+1 // and floor()
roomy = 5; //floor(random(8))+1

//Turn all the wall squares within the room to floor
for (xplus = 0; xplus < roomx; xplus++)
{
for (yplus = 0; yplus < roomy; xplus++)
{

// make sure it''s in the room
20: if top_x + xplus < 24 && top_y + yplus < 19 //***PARSE
ERROR
{
if room_square[top_x+xplus][top_y+yplus] == 0 //if
there is wall
{
room_square[top_x+xplus][top_y+yplus] = 1; //make
it floor
squares+=1; //increase the number of squares made

//record the first square made(ever)
28: if first_square_x == -1 //***PARSE ERROR
{
first_square_x = top_x+xplus;
first_square_y = top_y+yplus;
}//endi
}//endi wall
}//endi in room
35: }//end for y //***PARSE ERROR
}//end for x
}//end scr_make_room()

int main()
{
int i, j;

for (i = 0; i < 25; i++)
{
for (j = 0; j < 20; i++)
{
room_square[i][j]=0;
}
}

for (i=0; i<5; i+=1) //make 5 rooms
{
scr_make_room();
}

return 0;
}

推荐答案



因为你省略了if(...)

结构中的括号。它们不是可选的。


if(x< y)/ * pass" Go,"收集

Because you have omitted the parentheses in the if(...)
construct. They are not optional.

if (x < y) /* pass "Go," collect





if(top_x + xplus< 24&& top_y + yplus< 19 )/ *你需要

括号* /


Robert Gamble

if (top_x + xplus < 24 && top_y + yplus < 19) /* You need the
parenthesis */

Robert Gamble


这篇关于帮助代码(解析错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 11:32