Skip to content

Instantly share code, notes, and snippets.

@ssophwang
Created May 13, 2017 14:09
Show Gist options
  • Save ssophwang/95e4fdef4cfe04e6ef732efac39ffc9e to your computer and use it in GitHub Desktop.
Save ssophwang/95e4fdef4cfe04e6ef732efac39ffc9e to your computer and use it in GitHub Desktop.
Rabbit_Robber.py
import ui
import random
from PIL import Image
v = ui.View(background_color=('#bcdeff'))
board = ui.View()
v.add_subview(board)
v.present('full_screen', hide_title_bar=False , orientations=['landscape'])
board.frame = (v.width-v.height, 0, v.height, v.height)
board.border_width = 2
board.border_color = ('black')
board.background_color = ('#ffffff')
rows = 8
cols = 8
buttons = []
for r in range(rows):
for c in range(cols):
random_num = random.randint(1, 100)
button = ui.ImageView()
if random_num < 12:
button = ui.ImageView()
button.image = ui.Image('emj:Police_Officer')
elif random_num < 24 and random_num > 11:
button = ui.ImageView()
button.image = ui.Image('emj:Bank')
else:
button.background_color = ('#838383')
button.width = v.height/cols
button.height = v.height/rows
button.border_color = ('black')
button.border_width = 1
button.x = button.width*c
button.y = button.height*r
button.font = ('American Typewriter',60)
board.add_subview(button)
buttons.append({'button' : button, 'original_color' : button.background_color, 'queens_eating' : 0, 'row_number' : r, 'column_number' : c})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment