Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. MazePanel mazePanel;
  2. MazePanel mazePanel2;
  3. Bitmap bmap;
  4. Paint paint;
  5. Maze maze;
  6. FirstPersonDrawer drawer;
  7.  
  8.  
  9. public GameView(Context context) {
  10. super(context);
  11. paint = new Paint();
  12. paint.setStyle(Paint.Style.FILL);
  13. mazePanel = new MazePanel(context.getApplicationContext());
  14. mazePanel.initBmap();
  15. bmap = mazePanel.getBitmap();
  16. mazePanel2 = new MazePanel(context.getApplicationContext());
  17. mazePanel2.setBitmap(bmap);
  18.  
  19. @Override
  20. protected void onDraw(Canvas canvas) {
  21. mazePanel2.setPaintColor(Color.RED);
  22. mazePanel2.fillGraphicsRect(100, 100, 200, 300);
  23. canvas.drawBitmap(bmap, 0, 0, paint);
  24. }
  25.  
  26. public GameView(Context context) {
  27. super(context);
  28. paint = new Paint();
  29. paint.setStyle(Paint.Style.FILL);
  30. mazePanel = new MazePanel(context.getApplicationContext());
  31. mazePanel2 = new MazePanel(context.getApplicationContext());
  32. mazePanel2.initBmap();
  33. }
  34.  
  35. @Override
  36. protected void onDraw(Canvas canvas) {
  37. mazePanel2.setPaintColor(Color.RED);
  38. mazePanel2.fillGraphicsRect(100, 100, 200, 300);
  39. mazePanel.setBitmap(mazePanel2.getBitmap());
  40. bmap = mazePanel.getBitmap();
  41. canvas.drawBitmap(bmap, 0, 0, paint);
  42. }
  43.  
  44. public class MazePanel extends View {
  45.  
  46. private Bitmap bmap;
  47. private Canvas canvas;
  48. private Paint paint;
  49. private Path polyPath;
  50.  
  51. private DisplayMetrics metrics;
  52.  
  53. private int viewWidth;
  54. private int viewHeight;
  55.  
  56. public enum Colors {
  57. BLACK, GRAY, DARK_GRAY, WHITE, YELLOW, RED
  58. };
  59.  
  60. public MazePanel(Context context) {
  61. super(context);
  62. metrics = context.getResources().getDisplayMetrics();
  63. viewWidth = metrics.widthPixels;
  64. viewHeight = metrics.heightPixels;
  65. canvas = new Canvas();
  66. paint = new Paint();
  67. polyPath = new Path();
  68. }
  69.  
  70. public void initBmap() {
  71. bmap = Bitmap.createBitmap(viewWidth, viewHeight, Config.RGB_565);
  72. this.canvas = new Canvas(bmap);
  73. }
  74.  
  75. public Canvas getCanvas() {
  76. return canvas;
  77. }
  78.  
  79. public void setCanvas(Canvas canvas) {
  80. this.canvas = canvas;
  81. }
  82.  
  83. public void setGraphicsColor(Colors colors) {
  84. switch(colors) {
  85. case BLACK:
  86. paint.setColor(Color.BLACK);
  87. break;
  88. case GRAY:
  89. paint.setColor(Color.GRAY);
  90. break;
  91. case DARK_GRAY:
  92. paint.setColor(Color.DKGRAY);
  93. break;
  94. case WHITE:
  95. paint.setColor(Color.WHITE);
  96. break;
  97. case YELLOW:
  98. paint.setColor(Color.YELLOW);
  99. break;
  100. case RED:
  101. paint.setColor(Color.RED);
  102. break;
  103. default:
  104. break;
  105. };
  106. }
  107.  
  108.  
  109.  
  110. public Bitmap getBitmap() {
  111. return bmap;
  112. }
  113.  
  114. public void setBitmap(Bitmap bitmap) {
  115. bmap = bitmap;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement