Created
May 13, 2017 14:09
-
-
Save ssophwang/95e4fdef4cfe04e6ef732efac39ffc9e to your computer and use it in GitHub Desktop.
Rabbit_Robber.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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