public void render(GameContainer arg0, StateBasedGame arg1, Graphics g) throws SlickException { g.drawString("Choose your Vehicle", 240, 30); try { base = new Image("sideView/base.png"); turret = new Image("sideView/turret.png"); gun = new Image("sideView/gun.png"); plane = new Image("sideView/plan.png"); boat = new Image("sideView/boat.png"); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (base != null) { base = base.getScaledCopy(3); turret = turret.getScaledCopy(3); gun = gun.getScaledCopy(3); plane = plane.getScaledCopy(3); boat = boat.getScaledCopy(3); g.drawImage(base, 50, 50); g.drawImage(turret, 150, 50); g.drawImage(gun, 250, 50); g.drawImage(plane, 350, 50); g.drawImage(boat, 450, 50); } }
public Level(int id, GameFactory factory) throws SlickException { super(id, EntityType.LEVEL); this.currentPlayerId = -1; this.factory = factory; AssetMgr assets = factory.getAssetMgr(); // Load Images Image tmp = assets.storeImage(Assets.LevelBackgroundImageId, "backgrounds/background.png"); assets.storeImage(Assets.LevelBackgroundImageId, tmp.getScaledCopy(1350, 800)); tmp = assets.storeImage(Assets.LevelMiddlegroundImageId, "backgrounds/middleground.png"); assets.storeImage(Assets.LevelMiddlegroundImageId, tmp.getScaledCopy(1850, 800)); this.groundMap = assets.storeTiledMap(Assets.LevelTileMapId, "tiles/blocks.tmx"); // gfx this.backgroundImage = factory.createImageEntity(Assets.LevelBackgroundImageId, Assets.LevelBackgroundImageId); this.backgroundImage.setVisible(true); add(this.backgroundImage); this.middlegroundImage = factory.createImageEntity(Assets.LevelMiddlegroundImageId, Assets.LevelMiddlegroundImageId); this.middlegroundImage.setVisible(true); add(this.middlegroundImage); this.ground = factory.createTiledMapEntity(Assets.LevelTileMapId, Assets.LevelTileMapId); this.ground.setVisible(true); this.ground.setActive(true); add(this.ground); // physics setData(new float[] {0, 0, 0, 0, 1, 1, 0}); // network setUpdateStrategy(EntityUpdateStrategy.Local); // order setOrder(EntityOrder.Level); // Shader Setup if (textureBuffer == null && Constants.Debug.shadersActive) { textureBuffer = new Image(JumpNRun.SCREENWIDTH, JumpNRun.SCREENHEIGHT); fbGraphics = textureBuffer.getGraphics(); blur1D = new BlurShader(); glowshader = new Shader("content/jumpnrun/shader/simple.vert", "content/jumpnrun/shader/glow.frag"); glowshader2 = new Shader("content/jumpnrun/shader/simple.vert", "content/jumpnrun/shader/glow.frag"); // For testing params = new ShaderParams(); params.showEditor("Shader-Einstellungen!!!"); } // setup setActive(true); setVisible(true); }
@Override public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { // Images backgroundImage = Global.setImage("papyrus_page.png"); backgroundImage.rotate(90); mapImage = Global.setImage("scroll_background_page_horizontal.png"); mapLvlDefaultImage = Global.setImage("bloque_niveau.png"); mapLvlUnlockedImage = Global.setImage("debut_niveau.png"); mapLvlUnlockedFinishedImage = Global.setImage("fin_niveau.png"); mapLvlFinishedImage = Global.setImage("fin_niveau.png"); // Labels newGameImage = Global.setImage("main_menu_nouvelle_partie.png"); newGameImage = newGameImage.getScaledCopy( (int) (newGameImage.getWidth() * SCALE_DOWN_W), newGameImage.getHeight()); loadGameImage = Global.setImage("main_menu_charger_partie.png"); loadGameImage = loadGameImage.getScaledCopy( (int) (loadGameImage.getWidth() * SCALE_DOWN_W), loadGameImage.getHeight()); if (optionsActivated) { optionsImage = Global.setImage("main_menu_options.png"); optionsImage = optionsImage.getScaledCopy( (int) (optionsImage.getWidth() * SCALE_DOWN_W), optionsImage.getHeight()); } titleImage = Global.setImage("main_menu_title.png"); titleImage = titleImage.getScaledCopy( (int) (titleImage.getWidth() * SCALE_DOWN_W * 1.5), titleImage.getHeight()); display = new Display(gc); Image labelImage = Global.setImage(Global.BUTTON_STANDARD_IMAGE); Image playerImage = labelImage.getScaledCopy(150, 25); mapErrorLabel = new Label(playerImage, ""); mapErrorLabel.setForeground(Color.red); mapErrorLabel.setBounds(800 - ERROR_X - ERROR_W, ERROR_Y, ERROR_W, ERROR_H); mapErrorLabel.pack(); this.display.add(mapErrorLabel); mapErrorLabel.setImage(null); }
@Override public void init(GameContainer container, StateBasedGame game) throws SlickException { this.container = container; this.game = game; this.input = container.getInput(); // initialize buttons Image button = GameImage.MENU_BUTTON_MID.getImage(); button = button.getScaledCopy(container.getWidth() / 2, button.getHeight()); Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage(); Image buttonR = GameImage.MENU_BUTTON_RIGHT.getImage(); for (MenuState ms : MenuState.values()) ms.init(container, game, button, buttonL, buttonR); }
@Override public void initResources() { // TODO Auto-generated method stub RessourceManager.addImage("intro", "intro2.png"); background = RessourceManager.getImage("intro"); background = background.getScaledCopy(container.getWidth(), container.getHeight()); // Init Music and Sounds if (Configuration.isMusicOn()) { GameMusic.initMainTheme(); GameMusic.setMusicVolume(Configuration.getMusicVolume()); GameMusic.loopMainTheme(); } }
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { // throws=nicht um Exception kümmern Image unscaledBackground = new Image("res/Pics/background.jpg"); background = unscaledBackground.getScaledCopy(0.6f); schriftSchwarz = new AngelCodeFont( "res/Fonts/TakeCoverSchwarz.fnt", new Image("res/Fonts/TakeCoverSchwarz.png")); schriftRot = new AngelCodeFont("res/Fonts/TakeCover.fnt", new Image("res/Fonts/TakeCover.png")); menüSchriftStart = schriftSchwarz; menüSchriftOptionen = schriftSchwarz; menüSchriftCredits = schriftSchwarz; this.titelPosition(); // Achtung Image = null!!! startKnopf = new MouseOverArea( gc, null, xtitle1, ytitle1, menüSchriftStart.getWidth("START"), menüSchriftStart.getHeight("START")); optionenKnopf = new MouseOverArea( gc, null, xtitle2, ytitle2, menüSchriftStart.getWidth("OPTIONEN"), menüSchriftStart.getHeight("OPTIONEN")); creditsKnopf = new MouseOverArea( gc, null, xtitle3, ytitle3, menüSchriftStart.getWidth("CREDITS"), menüSchriftStart.getHeight("CREDITS")); knopfGedrueckt = new Sound("res/Sounds/button-29.ogg"); }
public void render(Graphics g) { // g.drawOval(x, y, 30, 30); life--; angle += (rotation + 360) % 360; x += dX; y += dY; // set alpha if (life < 20) { alpha -= 0.05f; } else if (alpha < 1) { alpha += 0.05f; } Image snow = ERM.getImage("menu_snow"); Image temp = snow.getScaledCopy(scale); temp.setRotation(angle); temp.setAlpha(alpha); g.drawImage(temp, x, y - snowLife * 2); }
public void loadEntityFromMap(List<String> types, WorldOverworld world) throws SlickException { if (map == null) { Log.error("Unable to load map information"); return; } if (types == null || types.isEmpty()) { Log.error("No types defined to load"); return; } // layer have property type, so check it for (String type : types) { // try to find a layer with property type set to entity int layerIndex = -1; for (int l = 0; l < map.getLayerCount(); l++) { String value = map.getLayerProperty(l, "type", null); if (value != null && value.equalsIgnoreCase(type)) { layerIndex = l; break; } } if (layerIndex != -1) { Log.debug("Entity layer found on map"); int loaded = 0; for (int w = 0; w < map.getWidth(); w++) { for (int h = 0; h < map.getHeight(); h++) { Image img = map.getTileImage(w, h, layerIndex); if (img != null && map.getLayerProperty(layerIndex, "type", null).equalsIgnoreCase("ground")) { // load entity from Tiled map position and set Image // for static actor using image reference stored // into tiled map GroundTile te = new GroundTile( (float) w * img.getScaledCopy(4).getWidth(), (float) h * img.getScaledCopy(4).getHeight(), img.getScaledCopy(4)); world.add(te); loaded++; } else if (img != null && map.getLayerProperty(layerIndex, "type", null).equalsIgnoreCase("tree")) { // load entity from Tiled map position and set Image // for static actor using image reference stored // into tiled map Tile te = new Tile( (float) w * img.getScaledCopy(4).getWidth(), (float) h * img.getScaledCopy(4).getHeight(), img.getScaledCopy(4)); world.add(te); loaded++; } else if (img != null && map.getLayerProperty(layerIndex, "type", null).equalsIgnoreCase("playerspawn")) { // load entity from Tiled map position and set Image // for static actor using image reference stored // into tiled map // world.player.setPosition(new Vector2f(w * 64, h * 64)); world.player.x = w * 64; world.player.y = h * 64; // world.player = new Player(w * 64, h * 64); world.add(world.player); loaded++; } } } world.setHeight((map.getHeight() - 1) * 16 * 4); world.setWidth((map.getWidth() - 1) * 16 * 4); Log.debug("Loaded " + loaded + " entities"); } else { Log.info("Entity layer not found on map"); } } }
public void decreaseSize() throws SlickException { width -= 40; if (width < MIN_SIZE) width = MIN_SIZE; image = image.getScaledCopy((int) width, (int) height); }
public void increaseSize() throws SlickException { width += 40; if (width > MAX_SIZE) width = MAX_SIZE; image = image.getScaledCopy((int) width, (int) height); }
/** Renderiza el juego, uso interno */ @Override public void render(GameContainer gc, Graphics g) throws SlickException { double escalaTemporal = 0; if (autoescala) { escalaTemporal = escala; if (!noAutoEscalar) { escala = Math.min(escala, escalaAjustada); if (partido.getIteracion() < 50) { escalaGradual = escalaGradual + (escala - escalaGradual) * 0.01; } else { escalaGradual = escalaGradual + (escala - escalaGradual) * 0.2; } } escala = escalaGradual; } Position p = new Position(px, py); if (entorno) { pc.pintaEntorno(g, p, escala); } pc.pintaCancha(g, p, escala); Position[][] pos = partido.getPosiciones(); if (!partido.esGol() && partido.estanSacando()) { double zoom = 1 * escala * (1 + 0.02 * (double) iterSaca); rel = Transforma.transform( pos[2][0], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); g.drawImage( xImage.getScaledCopy((int) zoom, (int) zoom), rel[0] - (int) (zoom / 2), rel[1] - (int) (zoom / 2)); } Position ball = partido.getPosVisibleBalon(); for (int i = 0; i < 11; i++) { rel = Transforma.transform( pos[0][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); pjLocal.pintaSombra(i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1], g); rel = Transforma.transform( pos[1][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); pjVisita.pintaSombra(i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1], g); } z = partido.getAlturaBalon(); // 16*Math.sin(Math.abs(ang % Math.PI)); if (partido.estaRebotando() || z == 0) { ang = -balon0.angle(ball); velgiro = balon0.distance(ball) * 1.5; } if (partido.estanRematando()) { ang = rand.nextDouble() * Math.PI * 2; velgiro = rand.nextDouble(); } balon0 = ball; giro = giro + velgiro * 1.5; if (giro < 0) { giro = 6 + giro; } rel = Transforma.transform( ball, Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); pb.pintaSombra(escala, rel[0], rel[1], z, g); if (partido.getAlturaBalon() <= 2) { pb.pintaBalon((int) (giro), ang, escala, rel[0], rel[1], z * 2, g); } pp.pintaPublicidad(g, p, escala); if (jugador3d) { lista.clear(); for (int i = 0; i < 11; i++) { rel = Transforma.transform( pos[0][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); lista.add( new Object[] {pjLocal, i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1]}); rel = Transforma.transform( pos[1][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); lista.add( new Object[] { pjVisita, i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1] }); } Object[] tmp1, tmp2; for (int i = 0; i < lista.size() - 1; i++) { for (int j = i + 1; j < lista.size(); j++) { tmp1 = lista.get(i); tmp2 = lista.get(j); if ((Integer) tmp1[6] > (Integer) tmp2[6]) { lista.set(i, tmp2); lista.set(j, tmp1); } } } for (Object obj[] : lista) { PintaJugador pj = (PintaJugador) obj[0]; pj.pintaJugador( (Integer) obj[1], (Integer) obj[2], (Double) obj[3], (Double) obj[4], (Integer) obj[5], (Integer) obj[6], g); } for (int i = 0; i < 11; i++) { rel = Transforma.transform( pos[0][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); if (tipoTexto == 3 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) { pjLocal.pintaNumero(i, rel[0], rel[1], g); } if (tipoTexto == 4 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) { pjLocal.pintaNombre(i, rel[0], rel[1], g); } rel = Transforma.transform( pos[1][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); if (tipoTexto == 3 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) { pjVisita.pintaNumero(i, rel[0], rel[1], g); } if (tipoTexto == 4 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) { pjVisita.pintaNombre(i, rel[0], rel[1], g); } } } else { for (int i = 0; i < 11; i++) { rel = Transforma.transform( pos[0][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); pjLocal.pintaJugador(i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1], g); if (tipoTexto == 3 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) { pjLocal.pintaNumero(i, rel[0], rel[1], g); } if (tipoTexto == 4 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) { pjLocal.pintaNombre(i, rel[0], rel[1], g); } rel = Transforma.transform( pos[1][i], Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); pjVisita.pintaJugador(i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1], g); if (tipoTexto == 3 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) { pjVisita.pintaNumero(i, rel[0], rel[1], g); } if (tipoTexto == 4 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) { pjVisita.pintaNombre(i, rel[0], rel[1], g); } } } rel = Transforma.transform( ball, Constants.centroCampoJuego, -Transforma.transform(px, escala) + sx2, -Transforma.transform(py, escala) + sy2, escala); if (partido.getAlturaBalon() > 2) { pb.pintaBalon((int) (giro), ang, escala, rel[0], rel[1], z * 2, g); } pc.pintaArcos(g, p, escala); if (estadio) { pc.pintaEstadio(g, p, escala); } if (marcador) { pm.pintaMarcador( partido.getGolesLocal(), partido.getGolesVisita(), partido.getIteracion(), partido.getPosesionBalonLocal(), g); } if (golIter > 0) { double zoom = 1 + 0.05 * (golIter % 3); g.drawImage( golImage.getScaledCopy((int) (361d * zoom), (int) (81d * zoom)), sx2 - (int) (180d * zoom), sy2 - (int) (40d * zoom)); } if (offSideIter > 0) { g.drawImage(offSideImage, sx2 - 70, sy2 - 20); // g.drawImage(offSideImage, offSideIter - 300, sy2 - 20); } if (saqueIter > 0) { g.drawImage(cambioImage, saqueIter - 300, sy2 - 20); } if (autoescala) { escala = escalaTemporal; } if (guardado && iteracionControl > 0) { Image img = paImage; if (incremento > 0) { img = avImage; } if (incremento < 0) { img = reImage; } g.drawImage(img, sx2 - 10, sy2 - 10); g.setColor(Color.white); g.drawString("" + incremento + "x", sx2 + 20, sy2 - 10); } if (guardado && progreso) { g.setColor(Color.black); g.drawRect(sx - 20, 20, 10, sy - 40); g.setColor(Color.darkGray); g.fillRect(sx - 19, 21, 8, sy - 42); int valor = (int) (((double) sy - 41.0) * ((double) pg.getTiempo() / (double) pg.getIterciones())); int valorInicio = (int) (((double) sy - 42.0) * ((double) inicio / (double) pg.getIterciones())); int valorFin = (int) (((double) sy - 42.0) * ((double) fin / (double) pg.getIterciones())); g.setColor(Color.red); g.fillRect(sx - 19, sy - 21 - valor, 8, valor); g.setColor(Color.white); g.drawLine(sx - 19, sy - 22 - valorFin, sx - 12, sy - 22 - valorFin); g.drawLine(sx - 19, sy - 21 - valorFin, sx - 18, sy - 21 - valorFin); g.drawLine(sx - 13, sy - 21 - valorFin, sx - 12, sy - 21 - valorFin); g.drawLine(sx - 19, sy - 22 - valorInicio, sx - 12, sy - 22 - valorInicio); g.drawLine(sx - 19, sy - 23 - valorInicio, sx - 18, sy - 23 - valorInicio); g.drawLine(sx - 13, sy - 23 - valorInicio, sx - 12, sy - 23 - valorInicio); } if (showTexto) { if (partido.getIteracion() < 50) { g.setColor(Color.black); g.drawString(partido.getDetalleVisita().getTacticName() + " (Visita)", sx2 + 11, sy2 + 11); g.drawString("vs", sx2 + 41, sy2 + 41); g.drawString(partido.getDetalleLocal().getTacticName() + " (Local)", sx2 + 71, sy2 + 71); g.setColor(Color.white); g.drawString(partido.getDetalleVisita().getTacticName() + " (Visita)", sx2 + 10, sy2 + 10); g.drawString("vs", sx2 + 40, sy2 + 40); g.drawString(partido.getDetalleLocal().getTacticName() + " (Local)", sx2 + 70, sy2 + 70); } } if (showTexto) { if (partido.getIteracion() > Constants.ITERACIONES) { g.setColor(Color.black); g.drawString("Gana", sx2 + 11, sy2 + 11); if ((partido.getGolesLocal() > partido.getGolesVisita()) || (partido.getGolesLocal() == partido.getGolesVisita() && partido.getPosesionBalonLocal() >= .5d)) { g.drawString(partido.getDetalleLocal().getTacticName(), sx2 + 41, sy2 + 41); } else { g.drawString(partido.getDetalleVisita().getTacticName(), sx2 + 41, sy2 + 41); } g.setColor(Color.white); g.drawString("Gana", sx2 + 10, sy2 + 10); if ((partido.getGolesLocal() > partido.getGolesVisita()) || (partido.getGolesLocal() == partido.getGolesVisita() && partido.getPosesionBalonLocal() >= .5d)) { g.drawString(partido.getDetalleLocal().getTacticName(), sx2 + 40, sy2 + 40); } else { g.drawString(partido.getDetalleVisita().getTacticName(), sx2 + 40, sy2 + 40); } } } /*if (isRain) { g.setColor(lluvia); for (int i = 0; i < 200; i++) { double an = rand.nextDouble() * Math.PI * 2d; double rad = rand.nextDouble() * 1024; int x0 = (int) (sx2 + Math.sin(an) * rad); int y0 = (int) (sy2 + Math.cos(an) * rad); int x1 = (int) (sx2 + Math.sin(an) * rad * 1.1d); int y1 = (int) (sy2 + Math.cos(an) * rad * 1.1d); g.drawLine(x0, y0, x1, y1); } if (rand.nextDouble() < 0.05) { g.setColor(relampago); g.fillRect(0, 0, sx, sy); } isRain = rand.nextDouble() < 0.995; } else { isRain = rand.nextDouble() < 0.005; }*/ }