/** Prealoads all images from files. */ private void preLoadAllImagesFromFiles() { HwTypeEnum hwTypes[] = HwTypeEnum.values(); for (HwTypeEnum hwType : hwTypes) { String path = getImagePath(hwType); try { bufferedImageLoader.getImage(path); } catch (IOException ex) { // should never happen } } // PacketType packetType, PacketImageType packageImageType PacketType packetTypes[] = PacketType.values(); PacketImageType packetImageTypes[] = PacketImageType.values(); for (PacketType packetType : packetTypes) { for (PacketImageType packetImageType : packetImageTypes) { String path = getImagePath(packetType, packetImageType); try { bufferedImageLoader.getImage(path); } catch (IOException ex) { // should never happen } } } }
public void set_the_Enemy_Shots_image() { if (type == 0) { try { weapon = loader.loadImage("images/Ship_Shop/Enemy_Shot_1.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (type == 1) { try { weapon = loader.loadImage("images/Ship_Shop/Enemy_Shot_2.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (type == 2) { try { weapon = loader.loadImage("images/Ship_Shop/Enemy_Shot_3.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void set_up_ship() { BufferedImageLoader loader = new BufferedImageLoader(); // Level 1 type Enemy Ship if (type == 0) { try { enemy_ship = loader.loadImage("images/Ship_Shop/Enemy_Ships_1.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } current_max_speed = 25; current_health = 150; current_damage = 100; } else if (type == 1) { try { enemy_ship = loader.loadImage("images/Ship_Shop/Enemy_Ships_2.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } current_max_speed = 45; current_health = 200; current_damage = 150; } // Level 3 type of Enemy Ship else { try { enemy_ship = loader.loadImage("images/Ship_Shop/Enemy_Ships_3.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } current_max_speed = 65; current_health = 250; current_damage = 200; } }
public void init() { requestFocus(); BufferedImageLoader loader = new BufferedImageLoader(); try { spriteSheet = loader.loadImage("/sprite_sheet.png"); background = loader.loadImage("/star_field_-_3.jpg"); } catch (IOException e) { e.printStackTrace(); } tex = new Textures(this); // before player and controller ..grab image p = new Player(200, 200, tex); // origin all c = new Controller(this,tex); c = new Controller(tex); ea = c.getEntityA(); eb = c.getEntityB(); this.addKeyListener(new KeyInput(this)); c.createEnemy(enemy_count); }
/** * Gets image icon from path. * * @param path * @return */ public ImageIcon getImageIcon(String path) { ImageIcon image = bufferedImageLoader.getImageIcon(path); return image; }
/** * Creates scaled image of image at path. Size will be size x size. * * @param path * @param width * @return scaled image * @throws IOException */ private Image getScaledImage(String path, int width) throws IOException { Image tmp = bufferedImageLoader.getImage(path); int height = (int) ((double) (tmp.getHeight(null) / (double) tmp.getWidth(null)) * width); tmp = tmp.getScaledInstance(width, height, Image.SCALE_SMOOTH); return tmp; }