Skip to main content
Indent by four for a code block
Source Link
doppelgreener
  • 7.3k
  • 7
  • 44
  • 69

in javaIn Java this is the code if you use ArrayList..

public void keyPressed(KeyEvent e) {

int keyCode = e.getKeyCode(); ///get the key code of key pressed

if (keyCode == KeyEvent.VK_SPACE) { if (!fireballs_array.isEmpty()) { /// check if the array list is empty or not int last = fireballs_array.size()-1; // get the last element index if(fireballs_array.get(last).getY() <550) //get y axis of last element { fire(); } } else{ fire(); } }

public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode(); ///get the key code of key pressed

    if (keyCode == KeyEvent.VK_SPACE) {
    if (!fireballs_array.isEmpty()) {  /// check if the array list is empty or not
        int last = fireballs_array.size()-1;  // get the last element index
        if(fireballs_array.get(last).getY() <550) //get y axis of last element
        {
            fire();
        }
    }
    else {
        fire();
    }
}

in java this is the code if you use ArrayList..

public void keyPressed(KeyEvent e) {

int keyCode = e.getKeyCode(); ///get the key code of key pressed

if (keyCode == KeyEvent.VK_SPACE) { if (!fireballs_array.isEmpty()) { /// check if the array list is empty or not int last = fireballs_array.size()-1; // get the last element index if(fireballs_array.get(last).getY() <550) //get y axis of last element { fire(); } } else{ fire(); } }

In Java this is the code if you use ArrayList..

public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode(); ///get the key code of key pressed

    if (keyCode == KeyEvent.VK_SPACE) {
    if (!fireballs_array.isEmpty()) {  /// check if the array list is empty or not
        int last = fireballs_array.size()-1;  // get the last element index
        if(fireballs_array.get(last).getY() <550) //get y axis of last element
        {
            fire();
        }
    }
    else {
        fire();
    }
}
Source Link

in java this is the code if you use ArrayList..

public void keyPressed(KeyEvent e) {

int keyCode = e.getKeyCode(); ///get the key code of key pressed

if (keyCode == KeyEvent.VK_SPACE) { if (!fireballs_array.isEmpty()) { /// check if the array list is empty or not int last = fireballs_array.size()-1; // get the last element index if(fireballs_array.get(last).getY() <550) //get y axis of last element { fire(); } } else{ fire(); } }