目前要制作色阶,我要按像素制作带有颜色协调精灵的图像。
int w = image.getWidth();
int h = image.getHeight();
for(int xx = 0; xx < w; xx++){
for(int yy = 0; yy < h; yy++){
int pixel = image.getRGB(xx, yy);
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
if(red == 255){
handler.add_entity(new Box(xx * 32, yy * 32, 32));
}
if(blue == 255){
handler.add_entity(new Box(xx * 32, yy * 32, 32));
}
if(green == 255){
handler.add_entity(new Box(xx * 32, yy * 32, 32));
}
if(red == 0 && blue == 0 && green == 0){
handler.add_entity(new Box(xx * 32, yy * 32, 32));
}
}
}
但是我最终希望使用相同的方法制作地牢生成的Issac风格的绑定,所以最终我制作了一个种子生成器,该种子生成器生成了诸如“ B-184923”之类的所有种子,它们均引用文件名,“ B”是房间的布局,数字是要放置在作为绿色框的布局位置中的房间。
布局图片示例:https://i.stack.imgur.com/hc7mq.png
房间示例:https://i.stack.imgur.com/KUR1c.png
将房间(由颜色确定)以一种指向类似于我尝试过的文件的文件的模式放置的最佳方法是什么。