Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void drawMap(Graphics g, int cameraX, int cameraY){
- int tilesize = 16;
- int cameraOffsetX = 40; //Tiles to draw to left and right of camera.
- int cameraOffsetY = 20; //Tiles to draw above and below the camera.
- int startingPointX = Math.max(cameraX - cameraOffsetX, 0);
- int startingPointY = Math.max(cameraY - cameraOffsetY, 0);
- int stoppingPointX = Math.min(cameraX + cameraOffsetX, WIDTH);
- int stoppingPointY = Math.min(cameraY + cameraOffsetY, HEIGHT);
- for (int x = startingPointX; x < stoppingPointX; x++){
- for (int y = startingPointY; y < stoppingPointY; y++){
- g.setColor(Color.green);
- g.fillRect(x * tilesize, y * tilesize, tilesize, tilesize);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment