1b: inline static fields and reuse fields of super class

This commit is contained in:
Daniel Langbein 2024-11-19 09:47:00 +01:00
parent ab04dc1fd8
commit 266283c49c
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
4 changed files with 10 additions and 76 deletions

View File

@ -13,13 +13,6 @@ import java.util.ArrayList;
* @since 2015-06-19
*/
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 int currentFrame;
@ -29,22 +22,10 @@ public class DiamondModel extends DisplayableElementModel {
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() {
super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, false, collideSound);
super(true, true, "diamond",
0, false, true,
false, "coin");
this.initSprites();
}

View File

@ -24,7 +24,7 @@ public abstract class DisplayableElementModel {
private boolean moving;
private boolean animate;
private boolean impactExplosive;
private String spriteName;
protected final String spriteName;
private int priority;
private BufferedImage sprite;
private boolean falling;

View File

@ -13,15 +13,6 @@ import java.util.ArrayList;
* @since 2015-06-19
*/
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
* Used for the sprites
@ -32,26 +23,10 @@ public class MagicWallModel extends DisplayableElementModel {
private int currentFrame;
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() {
super(isDestructible, canMove, spriteName, priority, impactExplosive, animate, falling, collideSound);
super(false, false, "magicwall",
3, false, false,
false, "touch");
this.currentFrame = 0;
this.speed = 100;
this.initSprites();

View File

@ -13,15 +13,6 @@ import java.util.ArrayList;
* @since 2015-06-19
*/
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
*/
@ -55,23 +46,10 @@ public class RockfordModel extends DisplayableElementModel {
private int currentFrame;
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() {
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
this.setSpeed(100);
// Init the sprites in arrays