package game;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.util.Random;
public class Column {
//图片
BufferedImage image;
//位置
int x,y;
//宽高
int width,height;
//柱子之间的缝隙
int gap;
//柱子之间的距离
int distance;
//随机数工具
Random random=new Random();
/**
* 初始化第N个柱子
*/
public Column(int n) throws Exception{
image=ImageIO.read(getClass().getResource("/resources/column.png"));
width=image.getWidth();
height=image.getHeight();
gap=144;
distance=245;
x=550+(n-1)*distance;//第一个柱子(550),第二个柱子(550+245=795)
y=random.nextInt(218)+123;//random.nextInt(218)自动生成0到217的数(123,340)
}
//向左移动一步
public void step() {
x--;
if(x==-width/2) {
y=distance*2-width/2;
y=random.nextInt(218)+132;
x=550;
}
}
}
最近下载更多
微信网友_7556339099734016 LV3
6月16日
微信网友_6191697646571520 LV6
2022年10月27日
迷迭香 LV10
2022年9月22日
zxy135201 LV5
2022年9月16日
agjbvfhjbg LV6
2022年9月9日
jackzhang123 LV2
2022年9月3日
cuijunjie LV3
2022年7月2日
java代写 LV7
2022年6月4日
Yj1009 LV2
2022年6月2日
牛牛最棒哈哈 LV3
2022年5月31日

最近浏览