Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package shooter.weapons.ammunition;
  2.  
  3. import java.awt.Graphics2D;
  4. import java.awt.Shape;
  5. import java.awt.geom.AffineTransform;
  6. import java.awt.geom.Rectangle2D;
  7. import java.awt.geom.RectangularShape;
  8.  
  9. import shooter.gfx.BulletSpriteManager;
  10. import shooter.gfx.ObjectSpriteManager;
  11. import shooter.main.Game;
  12.  
  13. public abstract class Ammo {
  14.  
  15.     // Bullet x-position
  16.     protected double  x;
  17.     // Bullet y-position
  18.     protected double  y;
  19.     // Bullet x-velocity
  20.     protected double velX;
  21.     // Bullet y-velocity
  22.     protected double velY;
  23.     // Bullet rotation
  24.     protected double rotation;
  25.     // Bullet damage
  26.     protected double dmg;
  27.     // Collision Shape
  28.     protected RectangularShape col;
  29.     // Rotated collision Shape
  30.     protected Shape col2;
  31.     // Handles the Bullet Sprites
  32.     protected BulletSpriteManager bm;
  33.     // Transformation for the rotation of the bullet
  34.     protected AffineTransform trans, backup;
  35.     // Game instance
  36.     protected Game game;
  37.    
  38.     public Ammo(double x, double y, BulletSpriteManager bm, Game game) {
  39.         this.x = x;
  40.         this.y = y;
  41.         this.bm = bm;
  42.         this.game = game;
  43.         rotation = game.getHandler().getPlayer().getRotation();
  44.         col = new Rectangle2D.Double(x + ObjectSpriteManager.SIZE / 2 - BulletSpriteManager.SIZE / 4, y - BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2);
  45.         setVelocity();
  46.     }
  47.    
  48.     protected abstract void setVelocity();
  49.  
  50.     public void tick() {
  51.         x += velX;
  52.         y += velY;
  53.     }
  54.  
  55.     public abstract void render(Graphics2D g2d);
  56.    
  57.     public double getX() {
  58.         return x;
  59.     }
  60.  
  61.     public void setX(double x) {
  62.         this.x = x;
  63.     }
  64.  
  65.     public double getY() {
  66.         return y;
  67.     }
  68.  
  69.     public void setY(double y) {
  70.         this.y = y;
  71.     }
  72.  
  73.     public Shape getCol() {
  74.         return col2;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement