Advertisement
Guest User

Untitled

a guest
Jun 20th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. package com.thethiorix.rain.level;
  2.  
  3. import com.thethiorix.rain.graphics.Screen;
  4. import com.thethiorix.rain.level.tile.Tile;
  5.  
  6. public class Level {
  7.  
  8. protected int width, height;
  9. protected int[] tiles;
  10.  
  11. public Level(int width, int height) {
  12. this.width = width;
  13. this.height = height;
  14. tiles = new int[width * height];
  15. generateLevel();
  16.  
  17. }
  18.  
  19. public Level(String path) {
  20. loadLevel(path);
  21. }
  22.  
  23. protected void generateLevel() {
  24. }
  25.  
  26. private void loadLevel(String path) {
  27.  
  28. }
  29. public void update() {
  30.  
  31. }
  32. private void time() {
  33.  
  34. }
  35. public void render(int xScroll, int yScroll, Screen screen) {
  36. screen.setOffset(xScroll, yScroll);
  37. int x0 = xScroll >> 4;
  38. int x1 = (xScroll + screen.width) >> 4;
  39. int y0 = yScroll >> 4;
  40. int y1 = (yScroll + screen.height) >> 4;
  41.  
  42. for (int y = y0; y < y1; y++) {
  43. for (int x = x0; x < x1; x++) {
  44. getTile(x, y).render(x, y, screen);
  45. }
  46. }
  47. }
  48. public Tile getTile(int x, int y) {
  49. if (tiles [x + y * width] == 0) return Tile.grass;
  50. return Tile.voidTile;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement