danpost wrote...
Change line 53 to:
else if (start == false)
else if (start == false)
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Sakuya here. * * @author (your name) * @version (a version number or a date) */ public class Sakuya extends Actor { private int timer = 0; int health = 2000; private Counter counter; private BulletSpawner bulSpawn, bulSpawn2, bulSpawn3, bulSpawn4; private Powerup[] pw = new Powerup[5]; private Bullet[] bul = new Bullet[50]; private SPortrait portrait; private GreenfootSound sakuyaSnd = new GreenfootSound("sakuyaBattle.mp3"); private GreenfootSound stageSnd = new GreenfootSound("scarletMansion.mp3"); private GreenfootSound winSnd = new GreenfootSound("winSound.mp3"); private GreenfootSound bulfire = new GreenfootSound("enemybullet.wav"); private GreenfootSound timerSnd = new GreenfootSound("countdown.wav"); private GreenfootSound spellActSnd = new GreenfootSound("spellactivate.wav"); private GreenfootSound spellCapSnd = new GreenfootSound("spellcapture.wav"); private GreenfootSound bossDeathSnd = new GreenfootSound("bossDefeat.wav"); private GreenfootSound deathSnd = new GreenfootSound("bossDefeat.wav"); private boolean dead = false; private int steps = 20; private int invulnTimer = 0; private int destinX, destinY, distX, distY; private int patternTog = 1; private int spawnTog = 1; private int bossState = 1; private int animTimer = 0; private boolean start = false; private boolean shotsFired = false; private boolean spellActive = false; /** * Act - do whatever the Sakuya wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { Actor Shot = getOneIntersectingObject(Shot.class); if (Shot != null) { health = health - 1; getWorld().removeObject(Shot); } if(getY() < 150) { setLocation(getX(), getY() + 2); return; } if (invulnTimer <= 150) { invulnTimer++; return; } else if(start == false) { SakuyasWorld sk =(SakuyasWorld)getWorld(); timer = 0; invulnTimer = 0; counter = new Counter(); sk.addObject(counter, 510, 40); counter.setValue(30); stageSnd.stop(); sakuyaSnd.playLoop(); start = true; } if (start == true && dead == false) { if (bossState == 1) { if (timer%25 == 0) { //Switch between 2 bullet patterns if (patternTog == 1) { bulfire.play(); spawnBul(); } if (patternTog == 2) { bulfire.play(); spawnBul2(); } } //Generates new destination target if (timer == 150) { gen(); if (patternTog == 1) { patternTog = 2; } else { patternTog = 1; } timer = 0; } //Shifts to a new location in 16 moves if (steps < 16) { setLocation(getX() + advX(), getY() + advY()); } hitCheck(); hpCheck(); steps++; if (counter.getValue() == 0) { health = 1000; } if (health <= 1000) { bossState = 2; counter.setValue(40); } if(bossState == 2) { if (invulnTimer < 151){ if (invulnTimer == 0){ SakuyasWorld sk =(SakuyasWorld)getWorld(); portrait = new SPortrait(); portrait.getImage().setTransparency(0); sk.addObject(portrait, 378, 340); spellActSnd.play(); sk.addScore(20000); for (int i = 0; i < 5; i++){ pw[i] = new Powerup(); } sk.addObject(pw[0], getX(), getY()); sk.addObject(pw[1], getX() + 10, getY()); sk.addObject(pw[2], getX() - 10, getY()); sk.addObject(pw[3], getX(), getY() + 10); sk.addObject(pw[4], getX(), getY() - 10); spellLoc(); } invulnTimer++; if (steps < 16){ setLocation(getX() + advX(), getY() + advY()); } } //Get all values ready if (invulnTimer == 151){ SakuyasWorld sk =(SakuyasWorld)getWorld(); bulSpawn = new BulletSpawner(); sk.addObject(bulSpawn, getX(), getY()); timer = 100; invulnTimer = 152; } //Spell is active if (invulnTimer == 152){ bulSpawn.setLocation(getX(), getY()); if (timer%45 == 0){ bulSpawn.spawnBul(); } if (steps < 65 && spellActive == true){ bul[1].move(-1); bul[2].move(-2); bul[3].move(-3); bul[4].move(-4); } if (steps > 65 && steps < 75 && spellActive == true){ Actor reimu = (Actor)getWorld().getObjects(Reimu.class).get(0); for (int i = 0; i < 8; i++){ bul[i].turnTowards(reimu.getX(), reimu.getY()); } } if (steps > 75 && spellActive == true){ for (int i = 0; i < 8; i++){ bul[i].move(3); } } hitCheck(); hpCheck(); steps++; } if (counter.getValue() == 0) { health = 0; dead = true; } } timer++; if (timer%50 == 0){ counter.setValue(counter.getValue() - 1); if (counter.getValue() <= 10){ timerSnd.play(); } } if (dead == true){ if (animTimer == 1){ bulfire.stop(); deathSnd.play(); setImage("explode1.png"); } if (animTimer == 6){ setImage("explode2.png"); } if (animTimer == 11){ setImage("explode3.png"); } if (animTimer == 15){ setImage("explode4.png"); } if (animTimer == 19){ SakuyasWorld sk =(SakuyasWorld)getWorld(); sk.removeObject(counter); sk.removeObject(this); sk.addScore(20000); bossDeathSnd.play(); WinScreen win = new WinScreen(); sk.addObject(win, 277, 258); sakuyaSnd.stop(); winSnd.play(); Greenfoot.stop(); } animTimer++; } } } } public void hpCheck() { if (health <= 0){ SakuyasWorld sk =(SakuyasWorld)getWorld(); sk.setScore(sk.getScore() + 99999); dead = true; } } public int getHealth() { return health; } public void spellLoc(){ destinX = 277; destinY = 166; steps = 0; } public void spawnBul() { Actor reimu = (Actor)getWorld().getObjects(Reimu.class).get(0); SakuyasWorld sk =(SakuyasWorld)getWorld(); for (int i = 0; i < 7; i++) { bul[i] = new Bullet(); sk.addObject(bul[i], getX(), getY()); bul[i].setImage("cherryknife.png"); bul[i].turnTowards(reimu.getX(), reimu.getY()); } bul[0].turn(45); bul[1].turn(30); bul[2].turn(15); bul[4].turn(-15); bul[5].turn(-30); bul[6].turn(-45); } public void spawnBul2() { SakuyasWorld sk =(SakuyasWorld)getWorld(); for (int i = 0; i < 10; i++){ bul[i] = new Bullet(); sk.addObject(bul[i], getX(), getY()); bul[i].setImage("cherryknife.png"); } bul[0].setRotation(40); bul[1].setRotation(80); bul[2].setRotation(120); bul[3].setRotation(160); bul[4].setRotation(200); bul[5].setRotation(240); bul[6].setRotation(280); bul[7].setRotation(320); bul[8].setRotation(360); } public void gen(){ destinX = Greenfoot.getRandomNumber(250) + 50; destinY = Greenfoot.getRandomNumber(100) + 50; steps = 0; } public int advX() { distX = destinX - getX(); return distX/15; } public int advY() { distY = destinY - getY(); return distY/15; } public void hitCheck() { Actor Shot = getOneIntersectingObject(Shot.class); if (Shot != null) { health = health - 1; getWorld().removeObject(Shot); } } }