I am making a Mario game and my Mario shoots straight, but how do I make him shoot the way he does in the game. (the bullets go over ground)


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public class Fireball extends Actor { private int gravity = /*Some Negative Number */ ; private static final int DEF_GRAV = gravity; //Whatever other variables and constructors you have public void act() { if (!onGround() || gravity < 0 ) fall(); else jump(); //Whatever else you have } public void fall() { gravity++; setLocation(getX(), getY() - gravity); } public void jump() { gravity = DEF_GRAV; } public boolean onGround() { int height = getImage().getHeight(); Ground ground = (Ground)getOneObjectAtOffset( 0 , height/ 2 + 1 , Ground. class ); //Basically looks for a ground object beneath it. If nothing there, it will equal null return ground != null ; //If it exists, return true, if not, return false } } |