Guest User

Untitled

a guest
Oct 12th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. from com.badlogic.gdx import Gdx, Game, Screen
  2. from com.badlogic.gdx.graphics.g2d import BitmapFont, SpriteBatch, Sprite
  3. from com.badlogic.gdx.graphics import GL10, Texture, Pixmap, Color
  4. import random
  5.  
  6.  
  7. class Mine(Sprite):
  8.     def __init__(self):
  9.         tex = Texture(Gdx.files.internal("assets/gfx/tile_untouched.png"))
  10.         Sprite.__init__(self, tex)
  11.  
  12.         # 10% chance for true, else false
  13.         self.is_mine = (random.random() < 0.1)
  14.  
  15.     def reveal(self):
  16.         pass
  17.  
  18. class PoopSweeper(Game):
  19.     def create(self):
  20.         self.batch = SpriteBatch()
  21.         self.font = BitmapFont()
  22.         self.screen = PlayScreen(self)
  23.  
  24.     def dispose(self):
  25.         self.batch.dispose()
  26.         self.font.dispose()
  27.  
  28.     def render(self):
  29.         self.super__render()
  30.  
  31.  
  32. class PlayScreen(Screen):
  33.     def __init__(self, game):
  34.         self.game = game
  35.         self.font = BitmapFont()
  36.         self.batch = game.batch
  37.  
  38.         # Init 25*25 mines
  39.         self.mines = []
  40.         for _ in range(25*25):
  41.             self.mines.append(Mine())
  42.  
  43.  
  44.         # Create 25*25 grid
  45.         self.grid = Pixmap(16*25, 16*25, Pixmap.Format.RGBA8888)
  46.         self.grid.setColor(Color.LIGHT_GRAY)
  47.         for line_x in range(25):
  48.             self.grid.drawLine(16*line_x, 0, 16*line_x, Gdx.graphics.height)
  49.         for line_y in range(25):
  50.             self.grid.drawLine(0, 16*line_y, Gdx.graphics.width, 16*line_y)
  51.  
  52.  
  53.     def update(self):
  54.         delta = Gdx.graphics.getDeltaTime()
  55.  
  56.  
  57.     def render(self):
  58.         self.update()
  59.  
  60.         # Clear screen
  61.         Gdx.gl.glClearColor(0, 0, 0.2, 1)
  62.         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT)
  63.  
  64.         self.batch.begin()
  65.  
  66.         # Draw FPS number
  67.         self.font.draw(self.batch, "FPS: {0}".format(Gdx.graphics.framesPerSecond), 10, Gdx.graphics.height-10)
  68.  
  69.         # Draw grid
  70.         self.batch.draw(self.grid, 0, 0)
  71.  
  72.         self.batch.end()
Advertisement
Add Comment
Please, Sign In to add comment