代码拉取完成,页面将自动刷新
同步操作将从 吕焱飞/asteroids 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import greenfoot.*;
/**
* A proton wave that expands and destroys asteroids in its path.
*
* @author Michael Kölling
* @version 0.1
*/
public class ProtonWave extends Actor
{
/** The damage this wave will deal */
private static final int DAMAGE = 30;
/** How many images should be used in the animation of the wave */
private static final int NUMBER_IMAGES= 15;
/**
* The images of the wave. This is static so the images are not
* recreated for every object (improves performance significantly).
*/
private static GreenfootImage[] images;
/** Current size of the explosion */
private int imageNo = 0;
/** How much do we increment the index in the explosion animation. */
private int increment=1;
/**
* Create a new proton wave.
*/
public ProtonWave()
{
initializeImages();
setImage(images[0]);
Greenfoot.playSound("proton.wav");
}
/**
* Create the images for expanding the wave.
*/
public static void initializeImages()
{
if(images == null)
{
GreenfootImage baseImage = new GreenfootImage("wave.png");
images = new GreenfootImage[NUMBER_IMAGES];
int i = 0;
while (i < NUMBER_IMAGES)
{
int size = (i+1) * ( baseImage.getWidth() / NUMBER_IMAGES );
images[i] = new GreenfootImage(baseImage);
images[i].scale(size, size);
i++;
}
}
}
/**
* Act for the proton wave is: grow and check whether we hit anything.
*/
public void act()
{
checkAsteroidHit();
setImage(images[imageNo]);
imageNo += increment;
if(imageNo >= NUMBER_IMAGES)
{
increment = -increment;
imageNo += increment;
}
if(imageNo < 0)
{
getWorld().removeObject(this);
}
}
private void checkAsteroidHit()
{
Asteroid asteroid = (Asteroid) getOneIntersectingObject(Asteroid.class);
if (asteroid != null)
{
getWorld().removeObject(this);
asteroid.hit(DAMAGE);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。