use of java.awt.image.BufferStrategy in project cardgame1 by joey101937.
the class Board method render.
public void render() {
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
// /run once at the start
this.createBufferStrategy(3);
return;
}
Graphics gr = bs.getDrawGraphics();
Graphics2D g = (Graphics2D) gr;
g.scale(xScale, yScale);
g.setColor(Color.white);
// render options gear
g.drawImage(Main.BackgroundImage, 0, 0, null);
g.setFont(new Font("Arial", Font.BOLD, 35));
renderHeros(g);
renderMinions(g);
renderPlayerHand(g);
renderEnemyHand(g);
renderTraps(g);
g.drawImage(SpriteHandler.gearSmall, 0, 0, null);
this.visHandler.render(g);
g.dispose();
bs.show();
}
use of java.awt.image.BufferStrategy in project 2D-Game-Engine by vanZeben.
the class Game method render.
public void render() {
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
int xOffset = player.x - (screen.width / 2);
int yOffset = player.y - (screen.height / 2);
level.renderTiles(screen, xOffset, yOffset);
level.renderEntities(screen);
for (int y = 0; y < screen.height; y++) {
for (int x = 0; x < screen.width; x++) {
int colourCode = screen.pixels[x + y * screen.width];
if (colourCode < 255)
pixels[x + y * WIDTH] = colours[colourCode];
}
}
Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
g.dispose();
bs.show();
}
use of java.awt.image.BufferStrategy in project grounded by alejolp.
the class GameCanvas method paint.
@Override
public void paint(Graphics arg0) {
Game g = Game.getInstance();
BufferStrategy bs = getBufferStrategy();
int x, y, px, py;
if (bs == null) {
loadGraphics();
return;
}
g2d = (Graphics2D) bs.getDrawGraphics();
for (y = 0, py = 0; y < g.map.H; ++y, py += Constants.TILE_SIZE) {
for (x = 0, px = 0; x < g.map.W; ++x, px += Constants.TILE_SIZE) {
drawTileNum((g.map.data[y][x] == '.') ? Constants.ID_WALL : Constants.ID_BACKGROUND, px, py);
}
}
drawObjects(g.map.items);
drawObjects(g.map.exits);
drawObjects(g.map.elevators);
drawObjects(g.map.zombies);
drawObjects(g.map.fireballs);
drawObjects(g.map.specials);
drawTileNum(Constants.ID_PLAYER, g.p.x, g.p.y);
g2d.dispose();
if (!bs.contentsLost()) {
bs.show();
} else {
loadGraphics();
}
}
Aggregations