Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package shooter.weapons.ammunition;
- import java.awt.Color;
- import java.awt.Graphics2D;
- import java.awt.geom.AffineTransform;
- import shooter.gfx.BulletSpriteManager;
- import shooter.gfx.ObjectSpriteManager;
- import shooter.main.Game;
- public class Bullet9mm extends Ammo {
- public Bullet9mm(double x, double y, BulletSpriteManager bm, Game game) {
- super(x, y, bm, game);
- dmg = 1;
- }
- protected void setVelocity() {
- velX = (-1)*(12 * Math.cos(Math.toRadians(rotation)));
- velY = (-1)*(12 * Math.sin(Math.toRadians(rotation)));
- }
- public void render(Graphics2D g2d) {
- backup = g2d.getTransform();
- trans = new AffineTransform();
- // Apply rotation
- trans.rotate(Math.toRadians(rotation + 270), x + ObjectSpriteManager.SIZE / 2, y + ObjectSpriteManager.SIZE / 2);
- g2d.transform(trans);
- g2d.drawImage(bm.b9mm, (int) x + BulletSpriteManager.SIZE / 2, (int) y - ObjectSpriteManager.SIZE / 2 + BulletSpriteManager.SIZE / 4, BulletSpriteManager.SIZE, BulletSpriteManager.SIZE, null);
- col.setFrame(x + ObjectSpriteManager.SIZE / 2 - BulletSpriteManager.SIZE / 4, y - BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2, BulletSpriteManager.SIZE / 2);
- col2 = trans.createTransformedShape(col);
- // Restore previous transform
- g2d.setTransform(backup);
- // show collision boxes
- g2d.setColor(Color.RED);
- g2d.draw(col2);
- g2d.setColor(Color.WHITE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement