Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tanker;
- public class Tank {
- public int speed;
- private int direction;
- private int x;
- public int y;
- public ActionField actionField;
- public BattleField battleField;
- public Tank() throws Exception {
- setX(0);
- setY(0);
- }
- public Tank(ActionField actionField, BattleField battleField, int x, int y, int direction){
- this.actionField = actionField;
- this.battleField = battleField;
- setX(x);
- setY(y);
- this.direction = direction;
- }
- public void turn(int direction) throws Exception {
- this.direction = direction;
- actionField.processTurn(this);
- }
- public void move() throws Exception {
- actionField.processMove(this);
- }
- public void moveRandom(int x, int y){
- }
- public void moveToQuadrant(){
- }
- void fire() throws Exception {
- Bullet bullet = new Bullet(x+25, y+25,direction);
- int step = 1;
- while ((bullet.getX() >-14 && bullet.getX() <570) && (bullet.getY() >-14 && bullet.getY() <570)) {
- if (direction == 1) {
- bullet.updateY(-step);
- } else if (direction == 2) {
- bullet.updateY(step);
- } else if (direction == 3) {
- bullet.updateX(-step);
- } else {
- bullet.updateX(step);
- }
- actionField.processFire(bullet);
- //repaint();
- }
- }
- public int getDirection() {
- return direction;
- }
- public int getSpeed() {
- return speed;
- }
- public int getY() {
- return y;
- }
- public int getX() {
- return x;
- }
- public ActionField getActionField() {
- return actionField;
- }
- public BattleField getBattleField() {
- return battleField;
- }
- public void setActionField(ActionField actionField) {
- this.actionField = actionField;
- }
- public void setBattleField(BattleField battleField) {
- this.battleField = battleField;
- }
- public void setDirection(int direction) {
- this.direction = direction;
- }
- public void setSpeed(int speed) {
- this.speed = speed;
- }
- public void setX(int x) {
- this.x = x;
- }
- public void setY(int Y){
- this.y = y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement