Created
May 13, 2017 15:21
-
-
Save ssophwang/4d30cc0c37d1cda31b85210194098b85 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 | |
rabbit_size = 100 | |
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, rabbit_size/2, v.height-rabbit_size, v.height-rabbit_size) | |
board.border_width = 3 | |
board.border_color = ('black') | |
board.background_color = ('#ffffff') | |
rows = 8 | |
cols = 8 | |
blocks = [] | |
for r in range(rows): | |
for c in range(cols): | |
random_num = random.randint(1, 100) | |
block = ui.ImageView() | |
if random_num < 12: | |
block = ui.ImageView() | |
block.image = ui.Image('emj:Wolf_Face') | |
elif random_num < 24 and random_num > 11: | |
block = ui.ImageView() | |
block.image = ui.Image('emj:Bank') | |
else: | |
block.background_color = ('#838383') | |
block.width = board.height/cols | |
block.height = board.height/rows | |
block.border_color = ('black') | |
block.border_width = 1 | |
block.x = block.width*c | |
block.y = block.height*r | |
block.font = ('American Typewriter',60) | |
board.add_subview(block) | |
blocks.append({'block' : block, 'original_color' : block.background_color, 'queens_eating' : 0, 'row_number' : r, 'column_number' : c}) | |
rabbit_buttons = [] | |
for r in range(9): | |
for c in range(9): | |
test_rabbit_button = ui.Button() | |
test_rabbit_button.image = ui.Image('emj:Rabbit_Face') | |
test_rabbit_button.tint_color = '#000000' | |
test_rabbit_button.x = 296 + r*75.28 | |
test_rabbit_button.y = 20 + c*75.28 | |
test_rabbit_button.width = 50 | |
test_rabbit_button.height = 50 | |
v.add_subview(test_rabbit_button) | |
blocks.append({'rabbit' : rabbit_buttons, 'original_color' : block.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