Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.ol.spaceinvaders.core;
- import java.awt.Graphics2D;
- import java.awt.geom.Rectangle2D;
- import java.awt.image.BufferedImage;
- import java.awt.image.ImageObserver;
- import java.io.IOException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.imageio.ImageIO;
- public abstract class Obj<T extends Game> {
- public T game;
- public boolean visible;
- public double x;
- public double y;
- public Rectangle2D collider;
- public BufferedImage frame;
- public BufferedImage[] frames;
- public Obj(T game) {
- this.game = game;
- }
- public void init() {
- }
- public void update() {
- }
- public void draw(Graphics2D g) {
- if (this.visible) {
- if (this.frame != null) {
- g.drawImage(this.frame, (int)this.x, (int)this.y, (ImageObserver)null);
- }
- if (this.collider != null) {
- this.collider.setRect(this.x, this.y, this.collider.getWidth(), this.collider.getHeight());
- }
- }
- }
- public void updateCollider() {
- if (this.collider != null) {
- this.collider.setRect(this.x, this.y, this.collider.getWidth(), this.collider.getHeight());
- }
- }
- public void loadFrames(String... res) {
- this.frames = new BufferedImage[res.length];
- for(int i = 0; i < this.frames.length; ++i) {
- try {
- this.frames[i] = ImageIO.read(this.getClass().getResourceAsStream("/res/" + res[i]));
- } catch (IOException var4) {
- Logger.getLogger(Obj.class.getName()).log(Level.SEVERE, (String)null, var4);
- System.exit(-1);
- }
- }
- this.frame = this.frames[0];
- }
- static {
- BitmapFontRenderer11.a();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement