Package Ocarina2D.Objects

Source Code of Ocarina2D.Objects.Shield

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Ocarina2D.Objects;

import Ocarina2D.GlobalVariables;
import Ocarina2D.ZeldaKeys;
import puppyeyes.engine.Actor;
import puppyeyes.engine.Settings.Input;
import puppyeyes.engine.Sprite;

/**
*
* @author majora
*/
public class Shield extends Actor {
    // Modes: 0 = behind link, 1 = in front of link
    public int mode = 0;


    public Shield() {
        super("Shield");

        addFrame(new Sprite("Resources/Sprites/player/shield/shieldback.png"));
        addFrame(new Sprite("Resources/Sprites/player/shield/shieldfront.png"));
        addFrame(new Sprite("Resources/Sprites/player/shield/shieldleft.png"));
        addFrame(new Sprite("Resources/Sprites/player/shield/shieldright.png"));

        setAnimationSpeed(0);
        draw.setVisible(true);
    }

    @Override
    public void step() {
        super.step();
        boolean holdR = Input.keyDown(ZeldaKeys.r);


        // Shield is away
        if (holdR==false) {
            if (GlobalVariables.player.facing.equals("Up")) {
                position.x = GlobalVariables.player.position.x +3;
                position.y = GlobalVariables.player.position.y + 10;
                draw.getAnimation().setFrame(1);
                draw.setLayer(GlobalVariables.player.draw.getLayer()+1);
            } else if (GlobalVariables.player.facing.equals("Down")) {

                position.x = GlobalVariables.player.position.x +3;
                position.y = GlobalVariables.player.position.y + 7;
                draw.getAnimation().setFrame(0);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);

            } else if (GlobalVariables.player.facing.equals("Left")) {
                position.x = GlobalVariables.player.position.x +11;
                position.y = GlobalVariables.player.position.y+8;
                draw.getAnimation().setFrame(3);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);
            } else if (GlobalVariables.player.facing.equals("Right")) {
                position.x = GlobalVariables.player.position.x +1;
                position.y = GlobalVariables.player.position.y+8;
                draw.getAnimation().setFrame(2);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);
            }
        // Shield is out
        } else {
            if (GlobalVariables.player.facing.equals("Up")) {
                position.x = GlobalVariables.player.position.x +7;
                position.y = GlobalVariables.player.position.y + 7;
                draw.getAnimation().setFrame(0);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);
            } else if (GlobalVariables.player.facing.equals("Down")) {
                position.x = GlobalVariables.player.position.x;
                position.y = GlobalVariables.player.position.y + 12;
                draw.getAnimation().setFrame(1);
                draw.setLayer(GlobalVariables.player.draw.getLayer()+1);
            } else if (GlobalVariables.player.facing.equals("Left")) {
                position.x = GlobalVariables.player.position.x -3;
                position.y = GlobalVariables.player.position.y+8;
                draw.getAnimation().setFrame(2);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);
            } else if (GlobalVariables.player.facing.equals("Right")) {
                position.x = GlobalVariables.player.position.x +15;
                position.y = GlobalVariables.player.position.y+8;
                draw.getAnimation().setFrame(3);
                draw.setLayer(GlobalVariables.player.draw.getLayer()-1);
            }
        }
    }


}
TOP

Related Classes of Ocarina2D.Objects.Shield

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.