@Override public void display(Graphics g, Player player, Area currentArea, int camX, int camY) { int viewX = StateSingleplayer.VIEW_SIZE_X; int viewY = StateSingleplayer.VIEW_SIZE_Y; int worldX = StateSingleplayer.WORLD_SIZE_X; int worldY = StateSingleplayer.WORLD_SIZE_Y; g.setColor(BACKGROUND_BLACK); int posX = (int) (7.5 * viewX) / 10 + camX; int posY = (int) (.75 * viewY) / 10 + camY; int width = (int) (2.3 * viewX) / 10; int height = (int) (((double) worldY / worldX) * (2.3 * viewX) / 10); g.fillRect(posX, posY, width, height); for (GameObject o : currentArea.getObjects()) { g.setColor(o.getColor()); g.fillRect( (int) (posX + (width - o.getMiniWidth()) * ((double) o.getX()) / worldX), (int) (posY + (height - o.getMiniHeight()) * ((double) o.getY()) / worldY), o.getMiniWidth(), o.getMiniHeight()); } }
public void render(Graphics g) { g.setColor(Color.red); Images.ITEMS .getSubImage(0, 2) .draw( ox + (x * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * x)), oy + (y * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * y))); g.translate(ox, oy); if (hasItem()) { item.render(g); } g.translate(-ox, -oy); g.setColor(color); g.fillRect( ox + (x * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * x)), oy + (y * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * y)), Constants.TILE_SIZE, Constants.TILE_SIZE); if (tooltip) { int x = ox + (this.x * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * this.x)); int y = oy + (this.y * Constants.TILE_SIZE + (Inventory.SLOT_SPACING * this.y)); g.setColor(Color.black); g.fillRect(x, y - 25, Fonts.CLASS_TEXT.getWidth("Remove"), 20); g.setColor(Color.white); Fonts.CLASS_TEXT.drawString(x, y - 23, "Remove"); } }
/* * Vykresleni */ @Override public void render(Graphics graphics) { super.render(graphics); graphics.setColor(Color.black); graphics.fillRect(530, 10, 102, 7); graphics.setColor(Color.red); graphics.fillRect(531, 11, (float) (hStep * getHealth()), 5); inventory.draw(graphics); }
@Override public void renderProgressBar(Graphics gfx, ProgressBar w) { int x = w.getAbsoluteX(); int y = w.getAbsoluteY(); int t = (int) (w.getProgressRatio() * (float) (w.getWidth())); gfx.setColor(Color.green); gfx.fillRect(x, y, t, w.getHeight()); gfx.setColor(Color.gray); gfx.fillRect(x + t, y, w.getWidth() - t, w.getHeight()); }
private void drawHealthBar(Graphics g, Entity entity, int xOffset, int yOffset) { int width = entity.getTexture().getWidth(); float xPos = entity.getX() + xOffset; int height = entity.getTexture().getHeight(); float yPos = entity.getY() + yOffset + height; g.setColor(new Color(200, 0, 0)); g.fillRect(xPos, yPos, width, 3); g.setColor(new Color(0, 200, 0)); g.fillRect(xPos, yPos, width * (entity.getHealth() / entity.getMaxHealth()), 3); }
@Override public void render(GameContainer gc, Graphics g) { // Fond d'ecran plus sombre g.setColor(new Color(0.0f, 0.0f, 0.0f, backgroundTransparency)); g.fillRect(0, 0, Global.WINDOW_WIDTH, Global.WINDOW_HEIGHT); // Menu this.menuBackgroundImage.draw(DEATH_X, DEATH_Y, DEATH_W, DEATH_H); g.setColor(new Color(0.0f, 0.0f, 0.0f, menuBackgroundTransparency)); g.fillRect(DEATH_X, DEATH_Y, DEATH_W, DEATH_H); // Boutons display.render(gc, g); }
@Override public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics g) throws SlickException { for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells.length; j++) { cells[i][j].draw(g, this.maze); if (cellStack.size() > 0) { if (cellStack.contains(cells[i][j])) { g.setColor(Color.blue); g.fillRect(cells[i][j].gridPosX * ratio, cells[i][j].gridPosY * ratio, ratio, ratio); g.setColor(Color.black); } } if (cells[i][j].start) { g.setColor(Color.green); g.fillRect(cells[i][j].gridPosX * ratio, cells[i][j].gridPosY * ratio, ratio, ratio); g.setColor(Color.black); } } } if (this.search) { if (dfsBacktracked.size() > 0) { for (int i = 0; i < dfsBacktracked.size(); i++) { g.setColor(Color.blue); g.fillRect( dfsBacktracked.get(i).gridPosX * ratio, dfsBacktracked.get(i).gridPosY * ratio, ratio, ratio); g.setColor(Color.black); } } } if (this.path.size() > 0) { for (int i = 0; i < path.size(); i++) { if (!foundSolution && search) { g.setColor(Color.yellow); g.fillRect(path.get(i).gridPosX * ratio, path.get(i).gridPosY * ratio, ratio, ratio); g.setColor(Color.black); } else { cells[path.get(i).gridPosX][path.get(i).gridPosY].way = true; } } } if (currentDFSCell != null) { g.setColor(Color.green); g.fillRect(currentDFSCell.gridPosX * ratio, currentDFSCell.gridPosY * ratio, ratio, ratio); g.setColor(Color.black); } }
public void render(GameContainer gc, Graphics g) throws SlickException { // clears g.clear(); // backgrond g.setColor(new Color(103, 194, 240)); g.fillRect(0, 0, MainApp.SCREEN_WIDTH, MainApp.SCREEN_HEIGHT); // compute shift right shiftRight += computeShiftRight(); // draws every object ObjectBoilerplate object; for (int x = 0; x < WORLD_LENGTH; x++) { for (int y = 0; y < WORLD_HEIGHT; y++) { object = tileArray[x][y]; if (object != null) { object.render(shiftRight); g.setColor(Color.red); // g.fillRect(object.rect.getX() - shiftRight, MainApp.SCREEN_HEIGHT - // object.rect.getY(), object.rect.getWidth(), object.rect.getHeight()); } } } // g.setColor(Color.red); // g.fillRect(player.rect.getX() - shiftRight, MainApp.SCREEN_HEIGHT - // player.rect.getY(), player.rect.getWidth(), -player.rect.getHeight()); player.render(shiftRight); }
public void renderShopStock(Graphics g, int[] inventory) { int x = 240, y = 464; g.setColor(Color.black); int inventoryCounter = 0; for (Items item : this.itemList) { if (!item.isEquipped()) { if (inventoryCounter <= 20) { g.setColor(item.getItemRarityColor()); g.fillRect(x, y, 32, 32); item.drawImageItem(x, y); inventory[inventoryCounter++] = item.getID(); } x += 64; if (x > 496) { x = 112; y += 64; } } } }
@Override public void draw(GameContainer gc, Graphics g) { g.setDrawMode(Graphics.MODE_ADD); particleEngine.draw(gc, g); g.setDrawMode(Graphics.MODE_NORMAL); if (alive) { image.setCenterOfRotation(image.getWidth() / 2, image.getHeight() / 2); image.setRotation(rotation); // g.setColor(new org.newdawn.slick.Color(0,0,120)); // g.drawRect(position.x, position.y - image.getHeight() / 2, image.getWidth(), // 4); // g.fillRect(position.x, position.y - image.getHeight() / 2, image.getWidth() // * sheld / 100, 4); // g.setColor(new org.newdawn.slick.Color(0, 120, 23)); g.drawRect(position.x, position.y - image.getHeight() / 2 - 6, image.getWidth(), 4); g.fillRect( position.x, position.y - image.getHeight() / 2 - 6, image.getWidth() * hull / 100, 4); // // g.drawRect(position.x + image.getWidth() / 2 - 16, position.y + // image.getHeight() / 2 - 16, 32, 32); g.drawImage(image, position.x, position.y); for (int i = 0; i < 50; i++) { bullet[i].draw(gc, g); } } }
@Override public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { for (int i = 0; i < tile_map.length; i++) { for (int j = tile_map[i].length - 1; j >= 0; j--) { int x = (int) (((j * tile_width / 2) + (i * tile_width / 2)) * Properties.ResolutionScale); int y = (int) (((i * tile_height / 2) - (j * tile_height / 2) + 360) * Properties.ResolutionScale); getSpriteImage(tile_map[i][j]).draw(x, y, Properties.ResolutionScale); } } for (int i = 0; i < object_map.length; i++) { for (int j = object_map[i].length - 1; j >= 0; j--) { int x = (int) (((j * tile_width / 2) + (i * tile_width / 2)) * Properties.ResolutionScale); int y = (int) (((i * tile_height / 2) - (j * tile_height / 2) + 360) * Properties.ResolutionScale); getSpriteImage(object_map[i][j]).draw(x, y, Properties.ResolutionScale); } } if (updatePreview) { g.copyArea(imagePreview, 0, 0); updatePreview = false; } if (!HideOverlay) { g.setColor(backgroundColor); g.fillRect(0, 0, 1280 * Properties.ResolutionScale, 720 * Properties.ResolutionScale); textHandle.drawStrings(sceneDescription); } }
public void render(GameContainer gc, Graphics g) { int rid, x, y; if (!filling) g.drawImage(c, 0, 0); for (int i = 0; i < speed; i++) { if (fpx.size() == 0) { // after this all of the data in this class will be written over if (filling) { ClientMain.menu = postTrans; } filling = true; initialize(); } rid = ServerMain.r.nextInt(fpx.size()); x = fpx.get(rid); y = fpy.get(rid); fpx.remove(rid); fpy.remove(rid); indeces[x][y] = !indeces[x][y]; if (filling) { g1.drawImage( a.getSubImage( x * ClientMain.pixW, y * ClientMain.pixW, ClientMain.pixW, ClientMain.pixW), x * ClientMain.pixW, y * ClientMain.pixW); } else { g1.setColor(Colors.backgroundColor.darker(1f - (ServerMain.r.nextInt(55) + 200f) / 256f)); g1.fillRect(x * ClientMain.pixW, y * ClientMain.pixW, ClientMain.pixW, ClientMain.pixW); } add(x + 1, y); add(x - 1, y); add(x, y + 1); add(x, y - 1); } g.drawImage(b, 0, 0); }
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { g.setBackground(Color.black); g.setFont( new TrueTypeFont( new java.awt.Font(java.awt.Font.SANS_SERIF, java.awt.Font.BOLD, 50), true)); for (int i = 0; i < 4; ++i) { if (i == this.selected) { g.setColor(new Color(255, 255, 255)); } else { g.setColor(new Color(0, 0, 255)); } g.fillRect(10, 10 * (i + 1) + 137 * i, 780, 137); } g.setColor(new Color(255, 255, 255)); g.drawString("Block Dutz", 250, 50); String[] texte = {"Jouer", "Scores", "Quitter"}; for (int i = 1; i < 4; ++i) { if (i == this.selected) { g.setColor(new Color(0, 0, 0)); } else { g.setColor(new Color(255, 255, 255)); } g.drawString(texte[i - 1], 300, 10 * (i + 1) + 137 * i + 30); } }
private void renderMinimap() { int minimapWidth = minimapBg.getWidth(); int minimapHeight = minimapBg.getHeight(); int boundaryWidth = boundarySystem.getBoundaryWidth(); int boundaryHeight = boundarySystem.getBoundaryHeight(); float scaleX = (float) minimapWidth / (float) boundaryWidth; float scaleY = (float) minimapHeight / (float) boundaryHeight; g.setColor(Color.white); g.translate(container.getWidth() - minimapWidth - 20, 20); { minimapBg.draw(); float offsetX = cameraSystem.getStartX(); float offsetY = cameraSystem.getStartY(); g.drawRect( offsetX * scaleX, offsetY * scaleY, scaleX * cameraSystem.getWidth(), scaleY * cameraSystem.getHeight()); ImmutableBag<Entity> entities = world.getManager(GroupManager.class).getEntities("crates"); for (int i = 0; entities.size() > i; i++) { Entity crate = entities.get(i); Physics cratePhysics = physicsMapper.get(crate); float crateX = cratePhysics.getX() * scaleX; float crateY = cratePhysics.getY() * scaleY; g.fillRect(crateX - 1, crateY - 1, 2, 2); } ImmutableBag<Entity> tanks = world.getManager(GroupManager.class).getEntities("tanks"); for (int i = 0; tanks.size() > i; i++) { Entity t = tanks.get(i); String tp = world.getManager(PlayerManager.class).getPlayer(t); Physics physics = physicsMapper.get(t); g.setColor(Color.green); float tx = physics.getX() * scaleX; float ty = physics.getY() * scaleY; g.fillRect(tx - 3, ty - 3, 6, 6); } } g.translate(-container.getWidth() + minimapWidth + 20, -20); }
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) { Entity owner = this.owner; g.setColor(owner.getBackgroundColor()); g.fillRect( owner.getPosition().getX() - owner.getPadding().getLeft() - owner.getMargin().getRight(), owner.getPosition().getY() - owner.getPadding().getTop(), owner.getWidth() + owner.getPadding().getRight() + owner.getPadding().getLeft(), owner.getHeight() + owner.getPadding().getBottom() + owner.getPadding().getTop()); }
@Override public void render(Graphics g) { if (isVisible) { g.setColor(colorB); g.fillRect(0, 0, widht, height); g.setColor(colorF); g.setFont(font); g.drawString(pause, x, y); } }
@Override public void renderWindow(Graphics gfx, Window w) { int x = w.getAbsoluteX(); int y = w.getAbsoluteY(); gfx.setColor(backColor1); gfx.fillRect(x, y, w.getWidth(), w.getHeight()); gfx.setColor(borderColor); gfx.setLineWidth(2); gfx.drawRect(x, y, w.getWidth(), w.getHeight()); }
@Override public void renderPanel(Graphics gfx, Panel w) { int x = w.getAbsoluteX(); int y = w.getAbsoluteY(); // TODO translate into widgets render() method gfx.setColor(backColor1); gfx.fillRect(x, y, w.getWidth(), w.getHeight()); gfx.setColor(borderColor); gfx.setLineWidth(2); gfx.drawRect(x, y, w.getWidth(), w.getHeight()); }
@Override public void Draw(GameContainer gc, StateBasedGame arg1, Graphics g) { if (Visible) { if (height == 1) { height = g.getFont().getLineHeight(); } g.setColor(Color.black); g.fillRect(getX(), getY(), width, height); g.setColor(Color.white); g.drawRect(getX(), getY(), width, height); g.drawString(text, getX() + 2, getY() + 1); } }
@Override public void render(GameContainer container, Graphics g) { // TESTS if (this.path != null) for (int a = 0; a > this.path.getLength(); a++) // g.fillRect(this.path.getStep(a).getX(), this.path.getStep(a) // .getY(), 2, 2); g.fillRect( this.map.getTile(this.path.getX(a), this.path.getY(a)).getCenterX(), this.map.getTile(this.path.getX(a), this.path.getY(a)).getCenterY(), 2, 2); }
/* */ public void render(GameContainer container, Graphics g) /* */ throws SlickException /* */ { /* 41 */ g.setColor(new Color(0.4F, 0.6F, 0.8F)); /* 42 */ g.fillRect(0.0F, 0.0F, 1024.0F, 568.0F); /* 43 */ g.setColor(Color.white); /* 44 */ g.drawRect(5.0F, 5.0F, 1014.0F, 558.0F); /* */ /* 46 */ g.setColor(Color.white); /* 47 */ g.drawString( container.getInput().getMouseX() + "," + container.getInput().getMouseY(), 10.0F, 400.0F); /* 48 */ g.setColor(Color.red); /* 49 */ g.fillOval( container.getInput().getMouseX() - 10, container.getInput().getMouseY() - 10, 20.0F, 20.0F); /* */ }
/** @see AbstractComponent#render(GUIContext, org.newdawn.slick.Graphics) */ public void render(GUIContext container, Graphics g) { if (lastKey != -1) { if (input.isKeyDown(lastKey)) { if (repeatTimer < System.currentTimeMillis()) { repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; keyPressed(lastKey, lastChar); } } else { lastKey = -1; } } Rectangle oldClip = g.getClip(); g.setWorldClip(x, y, width, height); // Someone could have set a color for me to blend... Color clr = g.getColor(); if (background != null) { g.setColor(background.multiply(clr)); g.fillRect(x, y, width, height); } g.setColor(text.multiply(clr)); Font temp = g.getFont(); int cpos = font.getWidth(value.substring(0, cursorPos)); int tx = 0; if (cpos > width) { tx = width - cpos - font.getWidth("_"); } g.translate(tx + 2, 0); g.setFont(font); g.drawString(value, x + 1, y + 1); if (hasFocus() && visibleCursor) { g.drawString("_", x + 1 + cpos + 2, y + 1); } g.translate(-tx - 2, 0); if (border != null) { g.setColor(border.multiply(clr)); g.drawRect(x, y, width, height); } g.setColor(clr); g.setFont(temp); g.clearWorldClip(); g.setClip(oldClip); }
public static void render(GameContainer gc, StateBasedGame sbg, Graphics g) { if (showHint) { TrueTypeFont currentFont = LDSRacing.font; int x = gc.getInput().getMouseX(); int y = gc.getInput().getMouseY(); int width = currentFont.getWidth(hint); int height = currentFont.getHeight(); g.setFont(currentFont); g.setColor(new Color(255, 255, 255, 255)); g.fillRect(x - 5, y - height - 10, width + 10, height + 10); g.setColor(new Color(0, 0, 0, 255)); g.drawString(hint, x, y - height - 5); } }
@Override public void renderWindowTitleBar(Graphics gfx, WindowTitleBar w) { int x = w.getAbsoluteX(); int y = w.getAbsoluteY(); gfx.setColor(backColor2); gfx.fillRect(x, y, w.getWidth(), w.getHeight()); gfx.setColor(borderColor); gfx.setLineWidth(2); gfx.drawRect(x, y, w.getWidth(), w.getHeight()); // Title if (w.getText() != null) { gfx.setColor(textColor); gfx.drawString(w.getText(), x + 8, y + 2); } }
@Override public void draw(Graphics g) { int width = getWidth(); int height = getHeight(); if (width == -1 || height == -1) return; g.setClip(getRealX(), getRealY(), width, height); if (this.hasBackground()) g.setColor(getBackground()); else g.setColor(Color.darkGray); g.fillRect(getRealX(), getRealY(), width, height); if (this.hasBorder()) g.setColor(getBorder().getColor()); else g.setColor(new Color(150, 150, 150)); g.drawRect(getRealX(), getRealY(), width - 1, height - 1); if (hasText()) { g.setColor(getTextColor()); int x = getRealX(), y = getRealY(); if (textcenterx) { x -= g.getFont().getWidth(getDisplayText()) / 2; if (hasWidth()) x += getWidth() / 2; } if (textcentery) { y -= g.getFont().getHeight(getDisplayText()) / 2; if (hasHeight()) y += getHeight() / 2; } g.drawString(getDisplayText(), x, y); } g.clearClip(); }
private void drawLight(Entity entity, int lightSize, int x, int y) { Graphics g = container.getGraphics(); ResourceManager manager = ResourceManager.getInstance(); String resName = resourceMapper.get(entity).getResourceName(); Resource res = manager.getResource(resName); Image entityFrame = getFrame(res); int ew = entityFrame.getWidth(); int eh = entityFrame.getHeight(); float invSize = 1f / lightSize; g.clearAlphaMap(); g.scale(lightSize, lightSize); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); Image light = (Image) manager.getResource("light").getObject(); light.drawCentered((x) * invSize, (y) * invSize); g.scale(invSize, invSize); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_DST_ALPHA); g.setColor(new Color(0, 0, 0, 255)); g.fillRect(0, 0, container.getWidth(), container.getHeight()); g.setDrawMode(Graphics.MODE_NORMAL); }
public void renderButton(Graphics gfx, Button b, String text, Image icon) { int x = b.getAbsoluteX(); int y = b.getAbsoluteY(); if (b.isPressed()) gfx.setColor(backColor1); else gfx.setColor(backColor2); gfx.fillRect(x, y, b.getWidth(), b.getHeight()); if (b.isMouseOver()) gfx.setColor(Color.white); else gfx.setColor(borderColor); gfx.setLineWidth(2); gfx.drawRect(x, y, b.getWidth(), b.getHeight()); if (icon != null) gfx.drawImage(icon, x, y); if (text != null) { if (b.isEnabled()) gfx.setColor(Color.white); else gfx.setColor(Color.black); gfx.drawString(text, x + 4, y + 2); } }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, * org.newdawn.slick.Graphics) */ @Override public void render(GameContainer container, Graphics g) throws SlickException { g.scale(2, 2); g.fillRect(0, 0, 800, 600, back, 0, 0); g.resetTransform(); g.drawImage(image, 100, 100); image.draw(100, 200, 80, 200); font.drawString(100, 200, "Text Drawn before the callable"); SlickCallable callable = new SlickCallable() { @Override protected void performGLOperations() throws SlickException { renderGL(); } }; callable.call(); homer.draw(450, 250, 80, 200); font.drawString(150, 300, "Text Drawn after the callable"); }
/** * Renders the player to the screen * * @param x the x position to render the player to * @param y the y position to render the player to * @param g the graphics context * @param viewerRole the role of the one viewing this player */ public void draw(float x, float y, Graphics g, Role viewerRole) { if (Role.isRestriced(viewerRole) && "Fuzzi_Traitor.png".equals(texture)) { image = RessourceManager.loadImage("Fuzzi_Innocent.png"); } else image = RessourceManager.loadImage(texture); image.rotate(lookAngle - image.getRotation() + 90); image.draw(x, y); if (this.getInventory()[this.getCurrentWeapon()] != null) this.getInventory()[this.getCurrentWeapon()].draw(x, y); g.setColor(Color.black); g.drawRect(x, y - 12, 32, 8); g.setColor(Color.red); g.fillRect(x + 1, y - 11, lifepoints * 0.31f, 7); Vector2f v = new Vector2f(x + 16, y + 16); Vector2f v1 = new Vector2f(getLookAngle()).scale(130f); Vector2f v2 = v.copy().add(v1); g.drawLine(v.x, v.y, v2.x, v2.y); }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, * org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.drawString("left shift down: " + lshift, 100, 240); g.drawString("right shift down: " + rshift, 100, 260); g.drawString("space down: " + space, 100, 280); g.setColor(Color.white); g.drawString(message, 10, 50); g.drawString("" + container.getInput().getMouseY(), 10, 400); g.drawString( "Use the primary gamepad to control the blob, and hit a gamepad button to change the color", 10, 90); for (int i = 0; i < lines.size(); i++) { Line line = (Line) lines.get(i); line.draw(g); } g.setColor(cols[index]); g.fillOval((int) x, (int) y, 50, 50); g.setColor(Color.yellow); g.fillRect(50, 200 + ypos, 40, 40); }