@Override public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException { this.stateBasedGame = stateBasedGame; center = new Dimension( AsaGame.SOURCE_RESOLUTION.width / 2 - 100, AsaGame.SOURCE_RESOLUTION.height / 2); resetGame(); tandwiel1 = new Image(Resource.getPath(Resource.TANDWIEL5)); tandwiel2 = new Image(Resource.getPath(Resource.TANDWIEL6)); spinner = new Image(Resource.getPath(Resource.SPINNER)); spinneroverlay = new Image(Resource.getPath(Resource.SPINNER_OVERLAY)); background_spinner = new Image(Resource.getPath(Resource.BACKGROUND_SPINNER)); background_spinner_half = new Image(Resource.getPath(Resource.BACKGROUND_SPINNER_HALF)); background_spinner_half.setAlpha(0.7f); background = new Image(Resource.getPath(Resource.GAME_BACKGROUND)); selectImage = new Image(Resource.getPath(Resource.SAVE_SCORE)); choise = new Image(Resource.getPath(Resource.MAKE_YOUR_CHOISE)); fontBlack = Resource.getFont(Resource.FONT_SANCHEZ, 30, Color.BLACK); lens = new Animation(); lens.setLooping(false); for (int i = 0; i < 33; i++) { if ((i + "").length() == 1) { lens.addFrame(new Image(Resource.getPath("LENS/lens1_0000" + i + ".png")), 550 / 33); } else if ((i + "").length() == 2) { lens.addFrame(new Image(Resource.getPath("LENS/lens1_000" + i + ".png")), 550 / 33); } } lens.stop(); }
/** Special render method for the TiledMap foreground layer. */ private void renderFore() { if (playerIsBehindForeground(curPlayerX, curPlayerY) || movedIntoOpen) { // Update the non-rendered tiles if the player // is occupying a new tile this frame if (updateForeground || movedIntoOpen) { updateForeground = false; for (int i = 0; i < foreAlpha.length; i++) { map.setTileId(foreAlpha[i][0], foreAlpha[i][1], foregroundLayerIndex, foreAlpha[i][2]); } foreAlphaIndex = 0; } if (changedPosition && !movedIntoOpen) { for (int y = curPlayerY - foregroundAlphaRadius; y <= curPlayerY + foregroundAlphaRadius; y++) { for (int x = curPlayerX - foregroundAlphaRadius; x <= curPlayerX + foregroundAlphaRadius; x++) { int dX = curPlayerX - x; int dY = curPlayerY - y; float dd = (float) Math.sqrt((dX * dX) + (dY * dY)); if (dd <= foregroundAlphaRadius + 0.5 && x >= 0 && y >= 0 && x < map.getWidth() && y < map.getHeight()) { addToForegroundAlpha( x, y, map.getTileId(x, y, foregroundLayerIndex), map.getTileImage(x, y, foregroundLayerIndex)); map.setTileId(x, y, foregroundLayerIndex, 0); } } } } } renderLayer("FOREGROUND"); if (playerIsBehindForeground(curPlayerX, curPlayerY)) { for (int i = 0; i < foreAlphaImage.length; i++) { try { int x = foreAlpha[i][0]; int y = foreAlpha[i][1]; float dX = (vPlayerX / tileWidth) - x; float dY = (vPlayerY / tileHeight) - y; float dd = (float) Math.sqrt((dX * dX) + (dY * dY)); float alpha = (dd / foregroundAlphaRadius) + 0.25f; Image image = foreAlphaImage[i]; image.setAlpha(alpha); image.draw(x * tileWidth, y * tileHeight); } catch (Exception e) { } } } }
@Override public void attack(Graphics g, float fsX, float fsY) throws SlickException { // g.drawOval(fsX-32, fsY-32, 64+32, 64+32); // Image kunai = new Image("res/ninja/kunai.png"); long time2 = 8 + (System.currentTimeMillis() / 15) % (32 - 8); for (int i = 360; i > 0; i -= 45) { kunai.setCenterOfRotation(0, 0); kunai.setRotation(i); float alp = (32 - (time2)); kunai.setAlpha((float) Math.pow((alp) / 32, 0.1)); g.drawImage( kunai, (float) ((fsX + 16) + (1 * time2 * Math.cos(i * 0.0174532925))), (float) ((fsY + 16) + (1 * time2 * Math.sin(i * 0.0174532925)))); } // g.drawImage(kunai, fsX-time2, fsY+8); // this.setAnim(Ninja.getAttack()); }
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); }
@Override public void sprint(Graphics g, float fsX, float fsY) throws SlickException { kunai.setAlpha(1); if (this.getAnim() == this.getWalkingDown()) { kunai.setCenterOfRotation(0, 0); kunai.setRotation(94 - (System.currentTimeMillis() % 8)); g.drawImage(kunai, fsX + 12, fsY + 24); } if (this.getAnim() == this.getWalkingUp()) { kunai.setCenterOfRotation(0, 0); kunai.setRotation(-(94 - (System.currentTimeMillis() % 8))); g.drawImage(kunai, fsX + 20, fsY + 24); } if (this.getAnim() == this.getWalkingLeft()) { kunai.setCenterOfRotation(0, 0); kunai.setRotation(184 - (System.currentTimeMillis() % 8)); g.drawImage(kunai, fsX + 12, fsY + 32); } if (this.getAnim() == this.getWalkingRight()) { kunai.setCenterOfRotation(0, 0); kunai.setRotation(4 - (System.currentTimeMillis() % 8)); g.drawImage(kunai, fsX + 16, fsY + 18); } }
@Override public void draw(Graphics g, int trackPosition) { int timeDiff = hitObject.getTime() - trackPosition; float scale = timeDiff / (float) game.getApproachTime(); float fadeinScale = (timeDiff - game.getApproachTime() + FADE_IN_TIME) / (float) FADE_IN_TIME; float approachScale = 1 + scale * 3; float alpha = Utils.clamp(1 - fadeinScale, 0, 1); boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber(); float oldAlpha = Utils.COLOR_WHITE_FADE.a; Utils.COLOR_WHITE_FADE.a = color.a = alpha; Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage(); Image hitCircle = GameImage.HITCIRCLE.getImage(); float[] endPos = curve.pointAt(1); curve.draw(color); color.a = alpha; // end circle hitCircle.drawCentered(endPos[0], endPos[1], color); hitCircleOverlay.drawCentered(endPos[0], endPos[1], Utils.COLOR_WHITE_FADE); // start circle hitCircle.drawCentered(x, y, color); if (!overlayAboveNumber) hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE); // ticks if (ticksT != null) { Image tick = GameImage.SLIDER_TICK.getImage(); for (int i = 0; i < ticksT.length; i++) { float[] c = curve.pointAt(ticksT[i]); tick.drawCentered(c[0], c[1], Utils.COLOR_WHITE_FADE); } } if (sliderClickedInitial) ; // don't draw current combo number if already clicked else data.drawSymbolNumber( hitObject.getComboNumber(), x, y, hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha); if (overlayAboveNumber) hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE); // repeats for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) { if (hitObject.getRepeatCount() - 1 > tcurRepeat) { Image arrow = GameImage.REVERSEARROW.getImage(); if (tcurRepeat != currentRepeats) { if (sliderTime == 0) continue; float t = Math.max(getT(trackPosition, true), 0); arrow.setAlpha((float) (t - Math.floor(t))); } else arrow.setAlpha(1f); if (tcurRepeat % 2 == 0) { // last circle arrow.setRotation(curve.getEndAngle()); arrow.drawCentered(endPos[0], endPos[1]); } else { // first circle arrow.setRotation(curve.getStartAngle()); arrow.drawCentered(x, y); } } } if (timeDiff >= 0) { // approach circle GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); } else { // Since update() might not have run before drawing during a replay, the // slider time may not have been calculated, which causes NAN numbers and flicker. if (sliderTime == 0) return; float[] c = curve.pointAt(getT(trackPosition, false)); float[] c2 = curve.pointAt(getT(trackPosition, false) + 0.01f); float t = getT(trackPosition, false); // float dis = hitObject.getPixelLength() * HitObject.getXMultiplier() * (t - (int) t); // Image sliderBallFrame = sliderBallImages[(int) (dis / (diameter * Math.PI) * 30) % // sliderBallImages.length]; Image sliderBallFrame = sliderBallImages[(int) (t * sliderTime * 60 / 1000) % sliderBallImages.length]; float angle = (float) (Math.atan2(c2[1] - c[1], c2[0] - c[0]) * 180 / Math.PI); sliderBallFrame.setRotation(angle); sliderBallFrame.drawCentered(c[0], c[1]); // follow circle if (followCircleActive) { GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c[0], c[1]); // "flashlight" mod: dim the screen if (GameMod.FLASHLIGHT.isActive()) { float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a; Utils.COLOR_BLACK_ALPHA.a = 0.75f; g.setColor(Utils.COLOR_BLACK_ALPHA); g.fillRect(0, 0, containerWidth, containerHeight); Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack; } } } Utils.COLOR_WHITE_FADE.a = oldAlpha; }
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { int width = container.getWidth(); int height = container.getHeight(); // draw background Beatmap beatmap = MusicController.getBeatmap(); if (Options.isDynamicBackgroundEnabled() && beatmap != null && beatmap.drawBG(width, height, bgAlpha, true)) ; else { Image bg = GameImage.MENU_BG.getImage(); bg.setAlpha(bgAlpha); bg.draw(); } // top/bottom horizontal bars float oldAlpha = Utils.COLOR_BLACK_ALPHA.a; Utils.COLOR_BLACK_ALPHA.a = 0.2f; g.setColor(Utils.COLOR_BLACK_ALPHA); g.fillRect(0, 0, width, height / 9f); g.fillRect(0, height * 8 / 9f, width, height / 9f); Utils.COLOR_BLACK_ALPHA.a = oldAlpha; // draw downloads button downloadsButton.draw(); // draw buttons if (logoTimer > 0) { playButton.draw(); exitButton.draw(); optionsButton.draw(); } logo.draw(); // draw music buttons if (MusicController.isPlaying()) musicPause.draw(); else musicPlay.draw(); musicNext.draw(); musicPrevious.draw(); // draw music position bar int mouseX = input.getMouseX(), mouseY = input.getMouseY(); g.setColor((musicPositionBarContains(mouseX, mouseY)) ? BG_HOVER : BG_NORMAL); g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4); g.setColor(Color.white); if (!MusicController.isTrackLoading() && beatmap != null) { float musicBarPosition = Math.min((float) MusicController.getPosition() / MusicController.getDuration(), 1f); g.fillRoundRect(musicBarX, musicBarY, musicBarWidth * musicBarPosition, musicBarHeight, 4); } // draw repository button if (repoButton != null) repoButton.draw(); // draw update button if (Updater.get().showButton()) { Color updateColor = null; switch (Updater.get().getStatus()) { case UPDATE_AVAILABLE: updateColor = Color.red; break; case UPDATE_DOWNLOADED: updateColor = Color.green; break; case UPDATE_DOWNLOADING: updateColor = Color.yellow; break; default: updateColor = Color.white; break; } updateButton.draw(updateColor); } // draw text float marginX = width * 0.015f, topMarginY = height * 0.01f, bottomMarginY = height * 0.015f; g.setFont(Utils.FONT_MEDIUM); float lineHeight = Utils.FONT_MEDIUM.getLineHeight() * 0.925f; g.drawString( String.format( "Loaded %d songs and %d beatmaps.", BeatmapSetList.get().getMapSetCount(), BeatmapSetList.get().getMapCount()), marginX, topMarginY); if (MusicController.isTrackLoading()) g.drawString("Track loading...", marginX, topMarginY + lineHeight); else if (MusicController.trackExists()) { if (Options.useUnicodeMetadata()) // load glyphs Utils.loadGlyphs(Utils.FONT_MEDIUM, beatmap.titleUnicode, beatmap.artistUnicode); g.drawString( (MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, topMarginY + lineHeight); g.drawString( String.format("%s: %s", beatmap.getArtist(), beatmap.getTitle()), marginX + 25, topMarginY + (lineHeight * 2)); } g.drawString( String.format( "opsu! has been running for %s.", Utils.getTimeString((int) (System.currentTimeMillis() - programStartTime) / 1000)), marginX, height - bottomMarginY - (lineHeight * 2)); g.drawString( String.format("It is currently %s.", new SimpleDateFormat("h:mm a").format(new Date())), marginX, height - bottomMarginY - lineHeight); UI.draw(g); }