I'm new to java and have NO idea why this won't work :S. I think its the Boolean but I'm not sure why.
public abstract class Core {
public int[] player = null;{
player = new int[5];
player[0] = 1000;
player[1] = 100;
player[2] = 25;
player[3] = 10;
}
public int[] norris = null;{
norris = new int [5];
norris[0] = 1000;
norris[1] = 100;
norris[2] = 25;
norris[3] = 10;
}
public boolean trackanimation = false;
// FIREBALL
public void fballdmg(){
norris[0] = norris[0] - (player[2]*2); //50
}
public void fireball(){
faniloop();
if (trackanimation = true){
fballdmg();
refresh();
s.update();
trackanimation = false;
}
}
private static DisplayMode modes[] = {
new DisplayMode(1440,900,32,0),
new DisplayMode(1440,900,24,0),
new DisplayMode(1440,900,16,0),
};
public void loadimg(){
// PICTURES
playerF = new ImageIcon("E:\\ProjectSTUFF\\PlayerINFOFRAME.jpg") .getImage();
playerN = new ImageIcon("E:\\ProjectSTUFF\\NorrisINFOFRAME.jpg") .getImage();
// BACKGROUND
bg = new ImageIcon ("E:\\ProjectSTUFF\\BG.jpg").getImage();
Image fire1 = new ImageIcon("E:\\ProjectSTUFF\\FIREBALL1.jpg").getIm age();
Image fire2 = new ImageIcon("E:\\ProjectSTUFF\\FIREBALL2.jpg").getIm age();
Image fire3 = new ImageIcon("E:\\ProjectSTUFF\\FIREBALL3.jpg").getIm age();
Image fire4 = new ImageIcon("E:\\ProjectSTUFF\\FIREBALL4.jpg").getIm age();
// ANIMATION
f = new Animation();
f.addScene(fire1, 500);
f.addScene(fire2, 200);
f.addScene(fire1, 200);
f.addScene(fire2, 250);
f.addScene(fire1, 250);
f.addScene(fire2, 250);
f.addScene(fire1, 250);
f.addScene(fire2, 250);
f.addScene(fire3, 500);
f.addScene(fire4, 250);
loaded = true;
}
// ANIMATIONS
private Animation f;
// PICTURES
private Image bg;
private Image playerF;
private Image playerN;
// BOOLEAN
private boolean loaded;
public boolean running;
// SCREEN
protected Screen s;
// stop
public void stop(){
running = false;
}
// call
public void run(){
try{
init();
loadimg();
gameloop();
}finally{
s.restoreScreen();
}
}
// set to full screen
public void init(){
s = new Screen();
DisplayMode dm = s.findFirstCompatibleMode(modes);
s.setFullScreen(dm);
Window w = s.getFullScreenWindow();
w.setFont(new Font("Arial", Font.BOLD,50));
w.setBackground(Color.BLACK);
w.setForeground(Color.BLACK);
running = true;
}
// game loop
public void gameloop(){
long startTime = System.currentTimeMillis();
long runTime = startTime;
refresh();
s.update();
while(running){
}
}
// animation loop
public void faniloop(){
long startingTime = System.currentTimeMillis();
long runTime = startingTime;
while (runTime - startingTime <3150){
long timePassed = System.currentTimeMillis() - runTime;
runTime += timePassed;
Graphics2D g = s.getGraphics();
f.update(timePassed);
refresh();
drawf(g);
s.update();
g.dispose();
trackanimation = true;
try{
Thread.sleep(5);
}catch(Exception ex){}
}
}
// update screen
public void update(long timePassed){}
// paint
public synchronized void paintUI(Graphics g){
if(loaded){
g.drawImage(bg, 0,0,null);
g.drawImage(playerN, 1030,0,null);
g.drawImage(playerF, 0,700,null);
}
}
//refresh
public void refresh(){
Graphics2D g = s.getGraphics();
paintUI(g);
String norrisHP = new Integer(norris[0]).toString();
String playerHP = new Integer(player[0]).toString();
g.drawString(norrisHP, 1097, 116 );
g.drawString(playerHP, 70, 818);
g.dispose();
}
// draw f
public synchronized void drawf(Graphics2D g){
g.drawImage(f.getImage(), 50,280,null);
}
}
THIS IS TH EKEYPRESS i have the whole keypress working just not the ESCAPE
// Key pressed
public void keyPressed(KeyEvent e){
int keyCode = e.getKeyCode();
if(keyCode == KeyEvent.VK_ESCAPE){
System.out.println("KEYPREZ ESC");
stop();
}
// FIREBALL
if(keyCode == KeyEvent.VK_1){
fireball();
e.consume();
}
else{
e.consume();
}
}