public Display(PApplet p, int x, int y, int w, int h) { this.x = x; this.y = y; this.w = w; this.h = h; this.p = p; piece1 = p.loadImage("images/red_ball.png"); piece2 = p.loadImage("images/blue_ball.png"); }
public void setup() { size(setupw, setuph); font = createFont("TAHOMA.TTF", (float) 11.5); controlP5 = new ControlP5(this); // NORA: initialize all people for static reference PApplet p = (PApplet) this; people.add(new Person(67, 108, p, 1, p.loadImage("naj.png"), "Najla E.", null)); people.add(new Person(133, 54, p, 2, p.loadImage("nora.png"), "Nora N.", null)); people.add(new Person(200, 210, p, 3, p.loadImage("risa.png"), "Risa N.", null)); people.add(new Person(267, 162, p, 4, p.loadImage("mak.png"), "Makoto B.", null)); // NORAS INIT: changed these methods to refer to static Person's already created // in class Space ArrayList<Person> people1 = new ArrayList<Person>(); people1.add(people.get(0)); people1.add(people.get(1)); ArrayList<Person> people2 = new ArrayList<Person>(); people2.add(people.get(3)); people2.add(people.get(2)); people2.add(people.get(1)); pspace1 = new PrivateSpace(this, people1, 0, controlP5); pspace2 = new PrivateSpace(this, people2, setupw / 4, controlP5); Tab1 chat = new Chat(this, setupw / 2, controlP5); // HAN WEI // controlP5 = new ControlP5(this); // create a new instance of the PrivateRoomBtn controller. // pspace1 = new PrivateRoomBtn(this, controlP5, "privateRoomBtn1", 0, mainh, (height-mainh)/2, // (height-mainh)); // register the newly created PrivateRoomBtn with controlP5 controlP5.register(pspace1); // create a new instance of the PrivateRoomBtn controller. // pspace2 = new PrivateRoomBtn(this, controlP5, "privateRoomBtn2", width-(height-mainh)/2, // mainh, (height-mainh)/2, (height-mainh)); // register the newly created PrivateRoomBtn with controlP5 controlP5.register(pspace2); controlP5.register(chat); mainSpace = new Space(this, mainh, mainw, 0xFF006699, 255, 0, 0, controlP5, true); controlP5.register(mainSpace); smooth(); }
/** * helper function to load the large pixelinvaders logo * * @return */ public static Image createLargeIcon(PApplet papplet) { PImage img = papplet.loadImage("pics/logoBig.jpg"); if (img != null) { return img.getImage(); } LOG.log(Level.WARNING, "failed to load icon image!"); img = new PImage(400, 400); return img.getImage(); }
public Monster(float a, float c, PApplet p) { x = a; y = c; parent = p; width = parent.width; height = parent.height; img = parent.loadImage("monster.png"); n = 0; }
public void setImg(String link) { // load the image given by the link img = parent.loadImage(link); // width and eight will be specified by image size height = img.height; width = img.width; // intizialize the multiple canvas. pimg = parent.createGraphics(width, height, PConstants.P2D); mask = parent.createGraphics(width, height, PConstants.P2D); stage = parent.createGraphics((int) (width / 2), (int) (height / 2), PConstants.P2D); }
public Home(PApplet p, PVector position) { this.position = position; this.p = p; collisionShapes = new HashMap<String, CollisionCircle>(); initializeCollisionShapes(); try { image = p.loadImage(IMAGE_PATH); } catch (NullPointerException e) { System.out.println("Something wrong witht the home base image in Home.java"); } }
public BFont(PApplet pa, String filename) { this.pa = pa; PImage fontImage = pa.loadImage(filename); int rows = (int) Math.floor(fontImage.height / GameConstants.TILE_H); int columns = (int) Math.floor(fontImage.width / GameConstants.TILE_W); characters = rows * columns; font = new PImage[characters]; for (int j = 0; j < rows; j++) { for (int i = 0; i < columns; i++) { font[(j * columns) + i] = fontImage.get( i * GameConstants.TILE_W, j * GameConstants.TILE_H, GameConstants.TILE_W, GameConstants.TILE_H); } } }
public void NumDisplay() { /** Implementation of the Composite Pattern for the KeyPad Done @ by Pawan */ applet.image(applet.loadImage("/6.png"), 235, 455); // TODO Auto-generated method stub }
/** * Assigns the texture. * * @param pathToModel * @param modelFile * @param scene * @param m * @param sceneMaterialID * @param mesh */ private void assignMaterial( String pathToModel, File modelFile, Scene3ds scene, Mesh3ds m, int sceneMaterialID, MTTriangleMesh mesh) { if (scene.materials() > 0) { if (m.faceMats() > 0) { // Just take the first material in the mesh, it could have more but we dont support more // than 1 material for a mesh // materialIndexForMesh = m.faceMat(0).matIndex(); Material3ds mat = scene.material(sceneMaterialID); String materialName = mat.name(); if (debug) logger.debug( "Material name for mesh \"" + mesh.getName() + ":-> \"" + materialName + "\""); materialName.trim(); materialName.toLowerCase(); // Try to load texture try { PImage cachedImage = textureCache.get(materialName); if (cachedImage != null) { mesh.setTexture(cachedImage); mesh.setTextureEnabled(true); if (debug) logger.debug("->Loaded texture from CACHE : \"" + materialName + "\""); return; } if (modelFile.exists()) { // If model is loaded from local file system String modelFolder = modelFile .getParent(); // pathToModel.substring(), // pathToModel.lastIndexOf(File.pathSeparator) File modelFolderFile = new File(modelFolder); if (modelFolderFile.exists() && modelFolderFile.isDirectory()) modelFolder = modelFolderFile.getAbsolutePath(); else { modelFolder = ""; } String[] suffix = new String[] { "jpg", "JPG", "tga", "TGA", "bmp", "BMP", "png", "PNG", "tiff", "TIFF" }; for (int j = 0; j < suffix.length; j++) { String suffixString = suffix[j]; // Try to load and set texture to mesh String texturePath = modelFolder + MTApplication.separator + materialName + "." + suffixString; File textureFile = new File(texturePath); if (textureFile.exists()) { boolean success = textureFile.renameTo(new File(texturePath)); if (!success) { // File was not successfully renamed logger.debug("failed to RENAME file: " + textureFile.getAbsolutePath()); } PImage texture = null; if (MT4jSettings.getInstance().isOpenGlMode()) { // TODO check if render thread PImage img = pa.loadImage(texturePath); if (Tools3D.isPowerOfTwoDimension(img)) { texture = new GLTexture( pa, img, new GLTextureSettings( TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT)); } else { texture = new GLTexture( pa, img, new GLTextureSettings( TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT)); // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, // EXPANSION_FILTER.Bilinear); } } else { texture = pa.loadImage(texturePath); } mesh.setTexture(texture); mesh.setTextureEnabled(true); textureCache.put(materialName, texture); if (debug) logger.debug("->Loaded material texture: \"" + materialName + "\""); break; } if (j + 1 == suffix.length) { logger.error("Couldnt load material texture: \"" + materialName + "\""); } } } else { // Probably loading from jar file PImage texture = null; String[] suffix = new String[] { "jpg", "JPG", "tga", "TGA", "bmp", "BMP", "png", "PNG", "tiff", "TIFF" }; for (String suffixString : suffix) { String modelFolder = pathToModel.substring(0, pathToModel.lastIndexOf(MTApplication.separator)); String texturePath = modelFolder + MTApplication.separator + materialName + "." + suffixString; if (MT4jSettings.getInstance().isOpenGlMode()) { PImage img = pa.loadImage(texturePath); if (Tools3D.isPowerOfTwoDimension(img)) { texture = new GLTexture( pa, img, new GLTextureSettings( TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT)); } else { texture = new GLTexture( pa, img, new GLTextureSettings( TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT)); // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, // EXPANSION_FILTER.Bilinear); } } else { texture = pa.loadImage(texturePath); } mesh.setTexture(texture); mesh.setTextureEnabled(true); textureCache.put(materialName, texture); if (debug) logger.debug("->Loaded material texture: \"" + materialName + "\""); break; } } } catch (Exception e) { logger.error(e.getMessage()); } } // if (m.faceMats() > 0) } // if (scene.materials() > 0) }
public static PImage getImage(Object imgArg) { if (imgArg instanceof PImage) return (PImage) imgArg; if (imgArg instanceof HImageHolder) return ((HImageHolder) imgArg).image(); if (imgArg instanceof String) return _app.loadImage((String) imgArg); return null; }
SplashScreen(PApplet p) { parent = p; splash1 = loadImage("spaceFury01.png"); splash2 = loadImage("spaceFury02.png"); splash3 = loadImage("spaceFury03.png"); playbutton = loadImage("playbutton.png"); playbutton2 = loadImage("playbutton2.png"); highscorebutton = loadImage("highscore.png"); highscorebutton2 = loadImage("highscore2.png"); settingbutton = loadImage("setting.png"); settingbutton2 = loadImage("setting2.png"); quitbutton = loadImage("quit.png"); quitbutton2 = loadImage("quit2.png"); backbutton = loadImage("back.png"); backbutton2 = loadImage("back2.png"); // control images moverl = parent.loadImage("moverightleft.png"); spaceShoot = parent.loadImage("spaceShoot.png"); pauseimg = parent.loadImage("pauseimg.png"); buttonR = parent.loadImage("buttonR.png"); buttonM = parent.loadImage("buttonM.png"); buttonQ = parent.loadImage("buttonQ.png"); // headers controlsline = parent.loadImage("controlsline.png"); bulletsline = parent.loadImage("bulletsline.png"); difficultyline = parent.loadImage("difficultyline.png"); // firebullet bullet1 = parent.loadImage("fireball1.png"); bullet2 = parent.loadImage("fireball2.png"); bullet3 = parent.loadImage("fireball3.png"); bullet4 = parent.loadImage("fireball4.png"); // waterbullet waterbullet1 = parent.loadImage("waterbullet1.png"); waterbullet2 = parent.loadImage("waterbullet2.png"); waterbullet3 = parent.loadImage("waterbullet3.png"); waterbullet4 = parent.loadImage("waterbullet4.png"); // difficulty image rollover easy = parent.loadImage("easy.png"); easy2 = parent.loadImage("easy2.png"); medium = parent.loadImage("medium.png"); medium2 = parent.loadImage("medium2.png"); hard = parent.loadImage("hard.png"); hard2 = parent.loadImage("hard2.png"); // highscore animation images topShooters = parent.loadImage("topShooters.png"); topShooters2 = parent.loadImage("topShooters2.png"); topShooters3 = parent.loadImage("topShooters3.png"); topShooters4 = parent.loadImage("topShooters4.png"); topShooters5 = parent.loadImage("topShooters5.png"); topShooters6 = parent.loadImage("topShooters6.png"); scoreList.add(0); scoreList.add(0); scoreList.add(0); minim = new Minim(this); menuMusic = minim.loadFile("menuMusic.mp3", 2048); menuMusic.play(); }