Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package shooter.weapons.ammunition;
- import java.awt.Graphics2D;
- import java.awt.Shape;
- import java.awt.geom.AffineTransform;
- import java.awt.geom.Rectangle2D;
- import java.awt.geom.RectangularShape;
- import shooter.gfx.BulletSpriteManager;
- import shooter.gfx.ObjectSpriteManager;
- import shooter.main.Game;
- public abstract class Ammo {
- // Bullet x-position
- protected double x;
- // Bullet y-position
- protected double y;
- // Bullet x-velocity
- protected double velX;
- // Bullet y-velocity
- protected double velY;
- // Bullet rotation
- protected double rotation;
- // Bullet damage
- protected double dmg;
- // Collision Shape
- protected RectangularShape col;
- // Rotated collision Shape
- protected Shape col2;
- // Handles the Bullet Sprites
- protected BulletSpriteManager bm;
- // Transformation for the rotation of the bullet
- protected AffineTransform trans, backup;
- // Game instance
- protected Game game;
- public Ammo(double x, double y, BulletSpriteManager bm, Game game) {
- this.x = x;
- this.y = y;
- this.bm = bm;
- this.game = game;
- rotation = game.getHandler().getPlayer().getRotation();
- col = new Rectangle2D.Double(x + ObjectSpriteManager.SIZE / 2 - BulletSpriteManager.SIZE / 4, y - BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2);
- setVelocity();
- }
- protected abstract void setVelocity();
- public void tick() {
- x += velX;
- y += velY;
- }
- public abstract void render(Graphics2D g2d);
- public double getX() {
- return x;
- }
- public void setX(double x) {
- this.x = x;
- }
- public double getY() {
- return y;
- }
- public void setY(double y) {
- this.y = y;
- }
- public Shape getCol() {
- return col2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement