我对 GameMaker 1.4 非常陌生,但我对 Python 和 C++ 有一些经验。我创建了一个介于 1 到 5 之间的随机整数矩阵,以表示地图上每个建筑物的楼层数。我想用它来绘制一组 10x10 的正方形,其中较浅的灰色正方形代表较高的建筑物。不幸的是,我无法让方块保持相同的颜色。它们不断在颜色之间闪烁。
我怎样才能让它们停止闪烁并适当地表示它们的相关值?
这是我的脚本:
// Random 2D Map Height Generator
/*
Generates a matrix which is used for determining
the amount of stories per building in the game.
Then draws squares of different colors to represent
the number of stories of each building.
*/
ct = irandom(1);
// create array
for (i = 0; i <= global.height; i += 1) {
for (j = 0; j <= global.width; j += 1) {
mapArray[i, j] = irandom_range(1, 5);
if (ct % 2 != 0 && mapArray[i, j] < 5) {
mapArray[i, j] += 1;
}
ct += 1;
}
}
// make colors
one = make_color_rgb(0, 0, 0);
two = make_color_rgb(51, 51, 51);
three = make_color_rgb(102, 102, 102);
four = make_color_rgb(153, 153, 153);
five = make_color_rgb(204, 204, 204);
// initialize coordinates
ex = 300;
wy = 100;
// count columns
// draw map
for (i = 0; i <= global.height; i += 1) {
for (j = 0; j <= global.width; j += 1) {
ex2 = ex + 30;
wy2 = wy + 30;
switch (mapArray[i, j])
{
case 1:
draw_set_color(one);
break;
case 2:
draw_set_color(two);
break;
case 3:
draw_set_color(three);
break;
case 4:
draw_set_color(four);
break;
case 5:
draw_set_color(five);
break;
default:
draw_text(200, 200,
"ERROR: scr_mapGeneration, case not met");
break;
}
draw_rectangle(ex, wy, ex2, wy2, false);
ex += 33;
if (j == global.width) {
wy += 33;
ex = 300;
}
}
}
我用draw事件在一个对象中调用它并用它执行这段代码:
script_execute(scr_mapGeneration);
我调用randomize();
了我的初始房间的创建代码。问题发生在另一个房间。
如果您需要更多信息,请告诉我。