1b: inline static fields and reuse fields of super class
This commit is contained in:
parent
ab04dc1fd8
commit
266283c49c
@ -13,13 +13,6 @@ import java.util.ArrayList;
|
|||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class DiamondModel extends DisplayableElementModel {
|
public class DiamondModel extends DisplayableElementModel {
|
||||||
private static String spriteName;
|
|
||||||
private static boolean isDestructible;
|
|
||||||
private static boolean canMove;
|
|
||||||
private static boolean impactExplosive;
|
|
||||||
private static boolean animate;
|
|
||||||
private static int priority;
|
|
||||||
private static String collideSound;
|
|
||||||
private long previousTime;
|
private long previousTime;
|
||||||
private int currentFrame;
|
private int currentFrame;
|
||||||
|
|
||||||
@ -29,22 +22,10 @@ public class DiamondModel extends DisplayableElementModel {
|
|||||||
|
|
||||||
private ArrayList<BufferedImage> framesDiamond;
|
private ArrayList<BufferedImage> framesDiamond;
|
||||||
|
|
||||||
/**
|
|
||||||
* Static dataset
|
|
||||||
* Specifies the physical parameters of the object
|
|
||||||
*/
|
|
||||||
static {
|
|
||||||
spriteName = "diamond";
|
|
||||||
isDestructible = true;
|
|
||||||
canMove = true;
|
|
||||||
impactExplosive = false;
|
|
||||||
animate = true;
|
|
||||||
priority = 0;
|
|
||||||
collideSound = "coin";
|
|
||||||
}
|
|
||||||
|
|
||||||
DiamondModel() {
|
DiamondModel() {
|
||||||
super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound);
|
super(true, true, "diamond",
|
||||||
|
0, false, true,
|
||||||
|
false, "coin");
|
||||||
|
|
||||||
this.initSprites();
|
this.initSprites();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public abstract class DisplayableElementModel {
|
|||||||
private boolean moving;
|
private boolean moving;
|
||||||
private boolean animate;
|
private boolean animate;
|
||||||
private boolean impactExplosive;
|
private boolean impactExplosive;
|
||||||
private String spriteName;
|
protected final String spriteName;
|
||||||
private int priority;
|
private int priority;
|
||||||
private BufferedImage sprite;
|
private BufferedImage sprite;
|
||||||
private boolean falling;
|
private boolean falling;
|
||||||
|
@ -13,15 +13,6 @@ import java.util.ArrayList;
|
|||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class MagicWallModel extends DisplayableElementModel {
|
public class MagicWallModel extends DisplayableElementModel {
|
||||||
private static String spriteName;
|
|
||||||
private static boolean isDestructible;
|
|
||||||
private static boolean canMove;
|
|
||||||
private static boolean impactExplosive;
|
|
||||||
private static boolean animate;
|
|
||||||
private static int priority;
|
|
||||||
private static boolean falling;
|
|
||||||
private static String collideSound;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the frames
|
* Stores the frames
|
||||||
* Used for the sprites
|
* Used for the sprites
|
||||||
@ -32,26 +23,10 @@ public class MagicWallModel extends DisplayableElementModel {
|
|||||||
private int currentFrame;
|
private int currentFrame;
|
||||||
private long speed;
|
private long speed;
|
||||||
|
|
||||||
/**
|
|
||||||
* Static dataset
|
|
||||||
* Specifies the physical parameters of the object
|
|
||||||
*/
|
|
||||||
static {
|
|
||||||
spriteName = "magicwall";
|
|
||||||
isDestructible = false;
|
|
||||||
canMove = false;
|
|
||||||
impactExplosive = false;
|
|
||||||
animate = false;
|
|
||||||
priority = 3;
|
|
||||||
falling = false;
|
|
||||||
collideSound = "touch";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class constructor
|
|
||||||
*/
|
|
||||||
MagicWallModel() {
|
MagicWallModel() {
|
||||||
super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
|
super(false, false, "magicwall",
|
||||||
|
3, false, false,
|
||||||
|
false, "touch");
|
||||||
this.currentFrame = 0;
|
this.currentFrame = 0;
|
||||||
this.speed = 100;
|
this.speed = 100;
|
||||||
this.initSprites();
|
this.initSprites();
|
||||||
|
@ -13,15 +13,6 @@ import java.util.ArrayList;
|
|||||||
* @since 2015-06-19
|
* @since 2015-06-19
|
||||||
*/
|
*/
|
||||||
public class RockfordModel extends DisplayableElementModel {
|
public class RockfordModel extends DisplayableElementModel {
|
||||||
private static String spriteName;
|
|
||||||
private static boolean isDestructible;
|
|
||||||
private static boolean canMove;
|
|
||||||
private static boolean impactExplosive;
|
|
||||||
private static boolean animate;
|
|
||||||
private static int priority;
|
|
||||||
private static boolean falling;
|
|
||||||
private static String collideSound;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the sub images of the sprite file
|
* Maps the sub images of the sprite file
|
||||||
*/
|
*/
|
||||||
@ -55,23 +46,10 @@ public class RockfordModel extends DisplayableElementModel {
|
|||||||
private int currentFrame;
|
private int currentFrame;
|
||||||
private boolean hasExploded;
|
private boolean hasExploded;
|
||||||
|
|
||||||
/**
|
|
||||||
* Static dataset
|
|
||||||
* Specifies the physical parameters of the object
|
|
||||||
*/
|
|
||||||
static {
|
|
||||||
spriteName = "rockford";
|
|
||||||
isDestructible = true;
|
|
||||||
canMove = true;
|
|
||||||
impactExplosive = true;
|
|
||||||
animate = true;
|
|
||||||
priority = 1;
|
|
||||||
falling = false;
|
|
||||||
collideSound = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
RockfordModel() {
|
RockfordModel() {
|
||||||
super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
|
super(true, true, "rockford",
|
||||||
|
1, true, true,
|
||||||
|
false, null);
|
||||||
// Speed of the animation of the sprite
|
// Speed of the animation of the sprite
|
||||||
this.setSpeed(100);
|
this.setSpeed(100);
|
||||||
// Init the sprites in arrays
|
// Init the sprites in arrays
|
||||||
|
Loading…
x
Reference in New Issue
Block a user