parent
bc16e1a196
commit
7764e0b07e
@ -0,0 +1,38 @@
|
||||
package com.msb.factorys;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:42
|
||||
* @Description: com.msb.factorys.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.TankFrame;
|
||||
import com.msb.factorys.abstracts.GameFactory;
|
||||
import com.msb.model.CircleExplode;
|
||||
import com.msb.model.Explode;
|
||||
import com.msb.model.abstracts.BaseBullet;
|
||||
import com.msb.model.abstracts.BaseExplode;
|
||||
import com.msb.model.abstracts.BaseTank;
|
||||
|
||||
/**
|
||||
*@ClassName DefautFactory
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:42
|
||||
*@Version 3.0
|
||||
*/
|
||||
public class CircleFactory extends GameFactory {
|
||||
@Override
|
||||
public BaseTank createTank(int x, int y, TankFrame tf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBullet createBullet(int x, int y, TankFrame tf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseExplode createExplode(int x, int y, TankFrame tf) {
|
||||
return new CircleExplode(x, y, tf);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.msb.factorys;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:42
|
||||
* @Description: com.msb.factorys.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.TankFrame;
|
||||
import com.msb.factorys.abstracts.GameFactory;
|
||||
import com.msb.model.Explode;
|
||||
import com.msb.model.abstracts.BaseBullet;
|
||||
import com.msb.model.abstracts.BaseExplode;
|
||||
import com.msb.model.abstracts.BaseTank;
|
||||
|
||||
/**
|
||||
*@ClassName DefautFactory
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:42
|
||||
*@Version 3.0
|
||||
*/
|
||||
public class DefaultFactory extends GameFactory {
|
||||
@Override
|
||||
public BaseTank createTank(int x, int y, TankFrame tf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBullet createBullet(int x, int y, TankFrame tf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseExplode createExplode(int x, int y, TankFrame tf) {
|
||||
return new Explode(x, y, tf);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.msb.factorys.abstracts;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:36
|
||||
* @Description: com.msb.model.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.TankFrame;
|
||||
import com.msb.model.abstracts.BaseBullet;
|
||||
import com.msb.model.abstracts.BaseExplode;
|
||||
import com.msb.model.abstracts.BaseTank;
|
||||
|
||||
/**
|
||||
*@ClassName AbstractFactory
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:36
|
||||
*@Version 3.0
|
||||
*/
|
||||
public abstract class GameFactory {
|
||||
public abstract BaseTank createTank(int x, int y, TankFrame tf);
|
||||
public abstract BaseBullet createBullet(int x, int y, TankFrame tf);
|
||||
public abstract BaseExplode createExplode(int x, int y, TankFrame tf);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.msb.inter;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:31
|
||||
* @Description: com.msb.inter
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface Paintable {
|
||||
public void paint(Graphics g);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.msb.model;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 17:42
|
||||
* @Description: com.msb.model
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.TankFrame;
|
||||
import com.msb.base.ResourcesMgr;
|
||||
import com.msb.model.abstracts.BaseExplode;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
*@ClassName CycleExplode
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 17:42
|
||||
*@Version 3.0
|
||||
*/
|
||||
public class CircleExplode extends BaseExplode {
|
||||
private int x,y;
|
||||
private TankFrame tankFrame;
|
||||
private int step = 0;
|
||||
|
||||
public CircleExplode(int x, int y, TankFrame tankFrame) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.tankFrame = tankFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
|
||||
Color color = g.getColor();
|
||||
g.setColor(Color.RED);
|
||||
g.fillOval(x, y, 10*step, 10*step);
|
||||
step++;
|
||||
if(step >= 10) {
|
||||
step = 0;
|
||||
tankFrame.explodes.remove(this);
|
||||
}
|
||||
g.setColor(color);
|
||||
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.msb.model.abstracts;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:33
|
||||
* @Description: com.msb.model.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.inter.Paintable;
|
||||
|
||||
/**
|
||||
*@ClassName AbstractTank
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:33
|
||||
*@Version 3.0
|
||||
*/
|
||||
public abstract class BaseBullet implements Paintable {
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.msb.model.abstracts;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:33
|
||||
* @Description: com.msb.model.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.inter.Paintable;
|
||||
|
||||
/**
|
||||
*@ClassName AbstractTank
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:33
|
||||
*@Version 3.0
|
||||
*/
|
||||
public abstract class BaseExplode implements Paintable {
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.msb.model.abstracts;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/9 16:33
|
||||
* @Description: com.msb.model.abstracts
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
import com.msb.inter.Paintable;
|
||||
|
||||
/**
|
||||
*@ClassName AbstractTank
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/9 16:33
|
||||
*@Version 3.0
|
||||
*/
|
||||
public abstract class BaseTank implements Paintable {
|
||||
|
||||
}
|
Loading…
Reference in new issue