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();
}
}