Java Code Examples for org.newdawn.slick.Color#white()
The following examples show how to use
org.newdawn.slick.Color#white() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LightTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Randomly generate a tile map */ private void generateMap() { // cycle through the map placing a random tile in each location for (int y=0;y<HEIGHT;y++) { for (int x=0;x<WIDTH;x++) { map[x][y] = 0; // 20% of tiles have features if (Math.random() > 0.8) { map[x][y] = 1 + (int) (Math.random() * 7); } } } // create and add our lights lights.clear(); mainLight = new Light(8f,7f,4f,Color.white); lights.add(mainLight); lights.add(new Light(2,2,2f,Color.red)); lights.add(new Light(2,11,1.5f,Color.yellow)); lights.add(new Light(12,2,3f,Color.green)); // finally update the lighting map for the first time updateLightMap(); }
Example 2
Source File: CursorColorManager.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
public static void setComboColors(Color[] colors) { if (colors.length == 0) { comboCols = new Color[] { Color.white }; comboColors = new int[] { -1 }; } else { comboCols = colors; comboColors = new int[colors.length]; int i = colors.length; do { --i; comboColors[i] = col(colors[i]); } while (i > 0); } for (CursorColor impl : impls) { impl.onComboColorsChanged(); } }
Example 3
Source File: GeomAccuracyTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Used to set the colors for overlay and geometry * */ private void setColors() { switch(colorIndex) { case 0: overlayColor = Color.white; geomColor = Color.magenta; break; case 1: overlayColor = Color.magenta; geomColor = Color.white; break; case 2: overlayColor = Color.red; geomColor = Color.green; break; case 3: overlayColor = Color.red; geomColor = Color.white; break; } }
Example 4
Source File: UI.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Draws a tab image and text centered at a location. * @param x the center x coordinate * @param y the center y coordinate * @param text the text to draw inside the tab * @param selected whether the tab is selected (white) or not (red) * @param isHover whether to include a hover effect (unselected only) */ public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) { Image tabImage = GameImage.MENU_TAB.getImage(); float tabTextX = x - (Fonts.MEDIUM.getWidth(text) / 2); float tabTextY = y - (tabImage.getHeight() / 2); Color filter, textColor; if (selected) { filter = Color.white; textColor = Color.black; } else { filter = (isHover) ? Colors.RED_HOVER : Color.red; textColor = Color.white; } tabImage.drawCentered(x, y, filter); Fonts.MEDIUM.drawString(tabTextX, tabTextY, text, textColor); }
Example 5
Source File: ButtonMenu.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
@Override public void render(Graphics g) { // score multiplier (TODO: fade in color changes) float mult = GameMod.getScoreMultiplier(); String multString = String.format("Score Multiplier: %.2fx", mult); Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red; float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f; final float multX = width2 - Fonts.LARGE.getWidth(multString) / 2f; Fonts.LARGE.drawString(multX, multY, multString, multColor); // category text for (GameMod.Category category : GameMod.Category.values()) { Fonts.LARGE.drawString(category.getX(), category.getY() - Fonts.LARGE.getLineHeight() / 2f, category.getName(), category.getColor()); } // buttons for (GameMod mod : GameMod.values()) mod.draw(); super.render(g); }
Example 6
Source File: GradientTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; rect = new Rectangle(400,100,200,150); round = new RoundedRectangle(150,100,200,150,50); round2 = new RoundedRectangle(150,300,200,150,50); center = new Rectangle(350,250,100,100); poly = new Polygon(); poly.addPoint(400,350); poly.addPoint(550,320); poly.addPoint(600,380); poly.addPoint(620,450); poly.addPoint(500,450); gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true); gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true); gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true); }
Example 7
Source File: RendererSlick.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static Color getMeterColorAsColor(int meterColor) { switch(meterColor) { case GameEngine.METER_COLOR_PINK: return new Color(255, 0,255); case GameEngine.METER_COLOR_PURPLE: return new Color(128, 0,255); case GameEngine.METER_COLOR_DARKBLUE: return new Color( 0, 0,128); case GameEngine.METER_COLOR_BLUE: return Color.blue; case GameEngine.METER_COLOR_CYAN: return Color.cyan; case GameEngine.METER_COLOR_DARKGREEN: return new Color( 0,128, 0); case GameEngine.METER_COLOR_GREEN: return Color.green; case GameEngine.METER_COLOR_YELLOW: return Color.yellow; case GameEngine.METER_COLOR_ORANGE: return Color.orange; case GameEngine.METER_COLOR_RED: return Color.red; } return Color.white; }
Example 8
Source File: MultiBeatmapNode.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
@Override void draw(Graphics g, Node focusNode, Node selectedNode) { final boolean isFocused = focusNode == this; Color textColor = SkinService.skin.getSongSelectInactiveTextColor(); final Color buttonColor; if (isFocused) { buttonColor = Color.white; textColor = SkinService.skin.getSongSelectActiveTextColor(); } else if (this.beatmaps[0].beatmapSet.isPlayed()) { buttonColor = BUTTON_ORANGE; } else { buttonColor = BUTTON_PINK; } final float oldalpha = buttonColor.a; buttonColor.a = 0.9f; super.drawButton(buttonColor, selectedNode == this); buttonColor.a = oldalpha; float cx = x + Node.cx; final Beatmap bm = this.beatmaps[0]; // draw text if (OPTION_SHOW_UNICODE.state) { Fonts.loadGlyphs(titlefont, bm.titleUnicode); Fonts.loadGlyphs(artistfont, bm.artistUnicode); } titlefont.drawString(cx, y + titleYoffset, bm.getTitle(), textColor); final String author = bm.getArtist() + " // " + bm.creator; artistfont.drawString(cx, y + authorYoffset, author, textColor); }
Example 9
Source File: NotificationManager.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Creates a new bubble notification. * @param s the notification string * @param c the border color * @param listener the listener * @param width the element width */ public BubbleNotification(String s, Color c, NotificationListener listener, int width) { this.message = s; this.lines = Fonts.wrap(font, s, (int) (width * 0.96f), true); this.borderColor = new Color(c); this.borderFocusColor = (borderColor.equals(Color.white)) ? new Color(Colors.GREEN) : new Color(Color.white); this.listener = listener; this.width = width; this.height = (int) (font.getLineHeight() * (lines.size() + 0.5f)); }
Example 10
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void draw(GameContainer container, StateBasedGame game, Graphics g) { int width = container.getWidth(); int height = container.getHeight(); // score multiplier (TODO: fade in color changes) float mult = GameMod.getScoreMultiplier(); String multString = String.format("Score Multiplier: %.2fx", mult); Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red; float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f; Fonts.LARGE.drawString( (width - Fonts.LARGE.getWidth(multString)) / 2f, multY, multString, multColor); // category text for (GameMod.Category category : GameMod.Category.values()) { Fonts.LARGE.drawString(category.getX(), category.getY() - Fonts.LARGE.getLineHeight() / 2f, category.getName(), category.getColor()); } // buttons for (GameMod mod : GameMod.values()) mod.draw(); super.draw(container, game, g); }
Example 11
Source File: UserSelectOverlay.java From opsu with GNU General Public License v3.0 | 5 votes |
/** Prepares the user selection state. */ private void prepareUserSelect() { selectedButton = null; // initialize user buttons userButtons.clear(); UserButton defaultUser = null; for (User user : UserList.get().getUsers()) { UserButton button = new UserButton(0, 0, Color.white); button.setUser(user); if (user.getName().equals(UserList.DEFAULT_USER_NAME)) defaultUser = button; else userButtons.add(button); } // add default user at the end if (defaultUser != null) userButtons.add(defaultUser); // add button to create new user UserButton addUserButton = new UserButton(0, 0, Color.white); addUserButton.setPlaceholderText("Add User"); userButtons.add(addUserButton); maxScrollOffset = Math.max(0, (UserButton.getHeight() + usersPaddingY) * userButtons.size() - (int) ((height - usersStartY) * 0.9f)); scrolling.setPosition(0f); scrolling.setAllowOverScroll(true); scrolling.setMinMax(0, maxScrollOffset); }
Example 12
Source File: Transform.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 5 votes |
/** * Instantiates a new transform. */ public Transform() { rotation = 0; translateX = 0; translateY = 0; scaleX = 1; scaleY = 1; flipHorizontal = false; flipVertical = false; color = Color.white; }
Example 13
Source File: OptionsStage.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 5 votes |
/** Return a color to use for this object */ protected Color getColor(final boolean columnSelected) { final boolean rowSelected = currentOptionIndex >= 0 && options[currentOptionIndex] == this; return (columnSelected ? (rowSelected ? new Color(90,200,90) : new Color(67, 150, 67)) : (rowSelected ? Color.white : new Color(192, 192, 192)) ); }
Example 14
Source File: GeomAccuracyTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; geomColor = Color.magenta; overlayColor = Color.white; magImage = new Image(21, 21); }
Example 15
Source File: RendererSlick.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * fieldOfBlockDraw a * @param x X-coordinate * @param y Y-coordinate * @param engine GameEngineInstance of * @param small Half size */ protected void drawField(int x, int y, GameEngine engine, int size) { if(graphics == null) return; int blksize = 16; float scale = 1.0f; if (size == -1) { blksize = 8; scale = 0.5f; } else if (size == 1){ blksize = 32; scale = 2.0f; } Field field = engine.field; int width = 10; int height = 20; int viewHeight = 20; if(field != null) { width = field.getWidth(); viewHeight = height = field.getHeight(); } if((engine.heboHiddenEnable) && (engine.gameActive) && (field != null)) { viewHeight -= engine.heboHiddenYNow; } int outlineType = engine.blockOutlineType; if(engine.owBlockOutlineType != -1) outlineType = engine.owBlockOutlineType; for(int i = 0; i < viewHeight; i++) { for(int j = 0; j < width; j++) { int x2 = x + (j * blksize); int y2 = y + (i * blksize); Block blk = null; if(field != null) blk = field.getBlock(j, i); if((field != null) && (blk != null) && (blk.color > Block.BLOCK_COLOR_NONE)) { if(blk.getAttribute(Block.BLOCK_ATTRIBUTE_WALL)) { drawBlock(x2, y2, Block.BLOCK_COLOR_NONE, blk.skin, blk.getAttribute(Block.BLOCK_ATTRIBUTE_BONE), blk.darkness, blk.alpha, scale, blk.attribute); } else if (engine.owner.replayMode && engine.owner.replayShowInvisible) { drawBlockForceVisible(x2, y2, blk, scale); } else if(blk.getAttribute(Block.BLOCK_ATTRIBUTE_VISIBLE)) { drawBlock(x2, y2, blk, scale); } if(blk.getAttribute(Block.BLOCK_ATTRIBUTE_OUTLINE) && !blk.getAttribute(Block.BLOCK_ATTRIBUTE_BONE)) { Color filter = new Color(Color.white); filter.a = blk.alpha; graphics.setColor(filter); int ls = (blksize-1); if(outlineType == GameEngine.BLOCK_OUTLINE_NORMAL) { if(field.getBlockColor(j, i - 1) == Block.BLOCK_COLOR_NONE) graphics.drawLine(x2, y2, x2 + ls, y2); if(field.getBlockColor(j, i + 1) == Block.BLOCK_COLOR_NONE) graphics.drawLine(x2, y2 + ls, x2 + ls, y2 + ls); if(field.getBlockColor(j - 1, i) == Block.BLOCK_COLOR_NONE) graphics.drawLine(x2, y2, x2, y2 + ls); if(field.getBlockColor(j + 1, i) == Block.BLOCK_COLOR_NONE) graphics.drawLine(x2 + ls, y2, x2 + ls, y2 + ls); } else if(outlineType == GameEngine.BLOCK_OUTLINE_CONNECT) { if(!blk.getAttribute(Block.BLOCK_ATTRIBUTE_CONNECT_UP)) graphics.drawLine(x2, y2, x2 + ls, y2); if(!blk.getAttribute(Block.BLOCK_ATTRIBUTE_CONNECT_DOWN)) graphics.drawLine(x2, y2 + ls, x2 + ls, y2 + ls); if(!blk.getAttribute(Block.BLOCK_ATTRIBUTE_CONNECT_LEFT)) graphics.drawLine(x2, y2, x2, y2 + ls); if(!blk.getAttribute(Block.BLOCK_ATTRIBUTE_CONNECT_RIGHT)) graphics.drawLine(x2 + ls, y2, x2 + ls, y2 + ls); } else if(outlineType == GameEngine.BLOCK_OUTLINE_SAMECOLOR) { if(field.getBlockColor(j, i - 1) != blk.color) graphics.drawLine(x2, y2, x2 + ls, y2); if(field.getBlockColor(j, i + 1) != blk.color) graphics.drawLine(x2, y2 + ls, x2 + ls, y2 + ls); if(field.getBlockColor(j - 1, i) != blk.color) graphics.drawLine(x2, y2, x2, y2 + ls); if(field.getBlockColor(j + 1, i) != blk.color) graphics.drawLine(x2 + ls, y2, x2 + ls, y2 + ls); } } graphics.setColor(Color.white); } } } // BunglerHIDDEN if((engine.heboHiddenEnable) && (engine.gameActive) && (field != null)) { int maxY = engine.heboHiddenYNow; if(maxY > height) maxY = height; for(int i = 0; i < maxY; i++) { for(int j = 0; j < width; j++) { drawBlock(x + (j * blksize), y + ((height - 1 - i) * blksize), Block.BLOCK_COLOR_GRAY, 0, false, 0.0f, 1.0f, scale); } } } }
Example 16
Source File: UserSelectOverlay.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Creates the user selection overlay. * @param container the game container * @param listener the event listener */ public UserSelectOverlay(GameContainer container, UserSelectOverlayListener listener) { super(container); this.listener = listener; this.input = container.getInput(); this.containerWidth = container.getWidth(); this.containerHeight = container.getHeight(); // overlay positions this.x = containerWidth / 3; this.y = 0; this.width = containerWidth / 3; this.height = containerHeight; // user positions this.titleY = Fonts.LARGE.getLineHeight() * 2; this.usersStartX = (width - UserButton.getWidth()) / 2; this.usersStartY = (int) (titleY + Fonts.XLARGE.getLineHeight() * 1.5f); this.usersPaddingY = UserButton.getHeight() / 10; // new user this.newUser = new User("", UserList.DEFAULT_ICON); this.newUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY + Fonts.MEDIUMBOLD.getLineHeight()), Color.white ); newUserButton.setUser(newUser); newUserButton.setHoverAnimationDuration(400); newUserButton.setHoverAnimationEquation(AnimationEquation.LINEAR); // new user text field this.textField = new TextField(container, null, 0, 0, 0, 0); textField.setMaxLength(UserList.MAX_USER_NAME_LENGTH); // user icons this.userIcons = new MenuButton[UserButton.getIconCount()]; for (int i = 0; i < userIcons.length; i++) { userIcons[i] = new MenuButton(UserButton.getIconImage(i), 0, 0); userIcons[i].setHoverFade(0.5f); } // edit user this.editUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY), Color.white ); // delete user deleteUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY + UserButton.getHeight() + usersPaddingY), Colors.RED_HOVER ); deleteUserButton.setHoverAnimationBase(0.5f); // kinetic scrolling this.scrolling = new KineticScrolling(); scrolling.setAllowOverScroll(true); }
Example 17
Source File: BarNotificationState.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
public BarNotificationState() { this.bgcol = new Color(Color.black); this.textCol = new Color(Color.white); this.timeShown = TOTAL_TIME; }
Example 18
Source File: BeatmapSetNode.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draws the button. * @param x the x coordinate * @param y the y coordinate * @param grade the highest grade, if any * @param focus true if this is the focused node */ public void draw(float x, float y, Grade grade, boolean focus) { Image bg = GameImage.MENU_BUTTON_BG.getImage(); boolean expanded = (beatmapIndex > -1); Beatmap beatmap = beatmapSet.get(expanded ? beatmapIndex : 0); bg.setAlpha(0.9f); Color bgColor; Color textColor = Options.getSkin().getSongSelectInactiveTextColor(); // get drawing parameters if (expanded) { x -= bg.getWidth() / 10f; if (focus) { bgColor = Color.white; textColor = Options.getSkin().getSongSelectActiveTextColor(); } else bgColor = Colors.BLUE_BUTTON; } else if (beatmapSet.isPlayed()) bgColor = Colors.ORANGE_BUTTON; else bgColor = Colors.PINK_BUTTON; bg.draw(x, y, bgColor); float cx = x + (bg.getWidth() * 0.043f); float cy = y + (bg.getHeight() * 0.18f) - 3; // draw grade if (grade != Grade.NULL) { Image gradeImg = grade.getMenuImage(); gradeImg.drawCentered(cx - bg.getWidth() * 0.01f + gradeImg.getWidth() / 2f, y + bg.getHeight() / 2.2f); cx += gradeImg.getWidth(); } // draw text if (Options.useUnicodeMetadata()) { // load glyphs Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.titleUnicode); Fonts.loadGlyphs(Fonts.DEFAULT, beatmap.artistUnicode); } Fonts.MEDIUM.drawString(cx, cy, beatmap.getTitle(), textColor); Fonts.DEFAULT.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() - 3, String.format("%s // %s", beatmap.getArtist(), beatmap.creator), textColor); if (expanded || beatmapSet.size() == 1) Fonts.BOLD.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 6, beatmap.version, textColor); // draw stars // (note: in osu!, stars are also drawn for beatmap sets of size 1) if (expanded) { if (beatmap.starRating >= 0) { Image star = GameImage.STAR.getImage(); float starOffset = star.getWidth() * 1.25f; float starX = cx + starOffset * 0.02f; float starY = cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() * 2 - 6f * GameImage.getUIscale(); float starCenterY = starY + star.getHeight() / 2f; final float baseAlpha = focus ? 1f : 0.8f; final float smallStarScale = 0.4f; final int maxStars = 10; star.setAlpha(baseAlpha); int i = 1; for (; i < beatmap.starRating && i <= maxStars; i++) { if (focus) star.drawFlash(starX + (i - 1) * starOffset, starY, star.getWidth(), star.getHeight(), textColor); else star.draw(starX + (i - 1) * starOffset, starY); } if (i <= maxStars) { float partialStarScale = smallStarScale + (float) (beatmap.starRating - i + 1) * (1f - smallStarScale); Image partialStar = star.getScaledCopy(partialStarScale); partialStar.setAlpha(baseAlpha); float partialStarY = starCenterY - partialStar.getHeight() / 2f; if (focus) partialStar.drawFlash(starX + (i - 1) * starOffset, partialStarY, partialStar.getWidth(), partialStar.getHeight(), textColor); else partialStar.draw(starX + (i - 1) * starOffset, partialStarY); } if (++i <= maxStars) { Image smallStar = star.getScaledCopy(smallStarScale); smallStar.setAlpha(0.5f); float smallStarY = starCenterY - smallStar.getHeight() / 2f; for (; i <= maxStars; i++) smallStar.draw(starX + (i - 1) * starOffset, smallStarY); } } } }
Example 19
Source File: Notification.java From FEMultiplayer with GNU General Public License v3.0 | 4 votes |
public Notification(float x, float y, String font, String text, float lifetime, float depth) { this(x, y, font, text, lifetime, Color.white, depth); }
Example 20
Source File: Notification.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 2 votes |
/** * Instantiates a new notification. * * @param x the x * @param y the y * @param font the font * @param text the text * @param lifetime the lifetime * @param depth the depth */ public Notification(float x, float y, String font, String text, float lifetime, float depth) { this(x, y, font, text, lifetime, Color.white, depth); }