def __init__(self):
     """
     Create a frame and load the cancer data
     """
     self._frame = simplegui.create_frame("Cancer risk visualization", CANVAS_WIDTH, CANVAS_HEIGHT)
     self._frame.set_canvas_background("White")
     self._frame.set_draw_handler(self.draw)
     self._frame.add_input("Enter cutoff (scaled by 0.00001)", self.enter_cutoff, 200)
     self._frame.add_button("Print data table in CSV", self.print_table, 200)
     self._data_table = self.load_data()
     self.enter_cutoff("0.0")
     self._USA_Counties = simplegui.load_image(MAP_URL)
     self._frame.start()
Exemplo n.º 2
0
 def __init__(self, game):
     self._cols = game.get_grid_height()
     self._rows = game.get_grid_width()
     self._frame = simplegui.create_frame(
         "2048", self._rows * TILE_SIZE + 2 * BORDER_SIZE, self._cols * TILE_SIZE + 2 * BORDER_SIZE
     )
     self._frame.add_button("New Game", self.start)
     self._frame.set_keydown_handler(self.keydown)
     self._frame.set_draw_handler(self.draw)
     self._frame.set_canvas_background("#A39480")
     self._frame.start()
     self._game = game
     url = "http://codeskulptor-assets.commondatastorage.googleapis.com/assets_2048.png"
     self._tiles = simplegui.load_image(url)
     self._directions = {"up": UP, "down": DOWN, "left": LEFT, "right": RIGHT}
Exemplo n.º 3
0
 def __init__(self, game):
     self._game = game
     self._rows = game.get_grid_height()
     self._cols = game.get_grid_width()
     self._frame = simplegui.create_frame('2048',
                     self._cols * TILE_SIZE + 2 * BORDER_SIZE,
                     self._rows * TILE_SIZE + 2 * BORDER_SIZE)
     self._frame.add_button('New Game', self.start)
     self._frame.set_keydown_handler(self.keydown)
     self._frame.set_draw_handler(self.draw)
     self._frame.set_canvas_background("#BCADA1")
     self._tiles = simplegui.load_image(IMAGE_URL)
     self._directions = {"up": UP, "down": DOWN,
                         "left": LEFT, "right": RIGHT}
     self._frame.start()
Exemplo n.º 4
0
        self.age += 1
        if (self.pos[0] < 0)  or (self.pos[0] > WIDTH) or (self.age >= self.lifespan):
            return True
        else:
            return False
        
    def collide(self, other_object):
        dis = dist(self.get_position(), other_object.get_position())
        if dis <= self.get_radius() + other_object.get_radius():
            return True
        else:
            return False

# image and sound resource
background_info = ImageInfo([383, 165], [766, 330])
background_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132516amq1535025.png")

splash_info = ImageInfo([286, 90], [572, 180])
splash_image = simplegui.load_image("http://d2.freep.cn/3tb_1407111325231o85535025.png")

gameover_info = ImageInfo([163, 147], [327, 294])
gameover_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132519y8e8535025.png")

zombie_info = ImageInfo([32, 50], [64, 100], 20, True, 15)
zombie_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132515f08j535025.png")

zombie1_info = ImageInfo([47.5, 56], [95, 112], 22, True, 17)
zombie1_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132528kiko535025.png")

shooter_info = ImageInfo([28.5, 32], [55.5, 64], 20, True, 15)
shooter_image = simplegui.load_image("http://d3.freep.cn/3tb_140711132521gb83535025.png")
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

import simpleguitk as simplegui
import random

## 定义常量
# 画布的尺寸
WIDTH = 800
HEIGHT = 600

# 骨牌的尺寸、中心位置及所有骨牌的图像
DOMINO_SIZE = (70, 190)
DOMINO_CENTER = (35, 95)
domino_images = simplegui.load_image("http://www.goldata.biz/images/dominoes.png")

# 所有骨牌。文牌是成对的,武牌是独一无二的。
DOMINOES = ('TIAN', 'TIAN', 'DI', 'DI', 'REN', 'REN', 'HE', 'HE', 'MEI', 'MEI', 'CHANG', 'CHANG', \
            'BAN', 'BAN', 'FU', 'FU', 'HONG', 'HONG', 'GAO', 'GAO', 'LING', 'LING', \
            'JIU1', 'JIU2', 'BA1', 'BA2', 'QI1', 'QI2', 'WU1', 'WU2', 'ZHIZUN1', 'ZHIZUN2')

# 所有骨牌对应的点数
POINTS = {'TIAN':12, 'DI':2, 'REN':8, 'HE':4, 'MEI':10, 'CHANG':6, 'BAN':4, 'FU':11, 'HONG':10, \
          'GAO':7, 'LING':6, 'JIU1':9, 'JIU2':9, 'BA1':8, 'BA2':8, 'QI1':7, 'QI2':7, 'WU1':5, \
          'WU2':5, 'ZHIZUN1':6, 'ZHIZUN2':3}

# 对牌与其排位、名称
DOMINO_PATTERNS = {('ZHIZUN1', 'ZHIZUN2'):(1, '至尊宝'), ('TIAN', 'TIAN'):(2, '双天'), ('DI', 'DI'):(3, '双地'), \
                   ('REN', 'REN'):(4, '孖人'), ('HE', 'HE'):(5, '孖和'), ('MEI', 'MEI'):(6, '孖梅'), \
                   ('CHANG', 'CHANG'):(7, '孖长'), ('BAN', 'BAN'):(8, '孖板凳'), ('FU', 'FU'):(9, '孖斧头'), \
                   ('HONG', 'HONG'):(10, '孖红头'), ('GAO', 'GAO'):(11, '孖高脚'), ('LING', 'LING'):(12, '孖零霖'), \
                   ('JIU1', 'JIU2'):(13, '杂九'), ('BA1', 'BA2'):(14, '杂八'), ('QI1', 'QI2'):(15, '杂七'), \
Exemplo n.º 6
0
__author__ = 'expressyang'
"""
简易放大镜
"""
import simpleguitk as simplegui


MAP_WIDTH = 2000
MAP_HEIGHT = 1818
#map_image = simplegui.load_image("http://ads.xjts.cn/zt/xj_map/images/1.jpg")
map_image = simplegui.load_image("1.jpg")
# 常量
MAP_SCALE = 3
CANVAS_WIDTH = MAP_WIDTH / MAP_SCALE
CANVAS_HEIGHT = MAP_HEIGHT / MAP_SCALE
MAGNIFIER_SIZE = 120

# Event handlers
def click(pos):
    magnifier_center[0] = pos[0]
    magnifier_center[1] = pos[1]

def drag(pos):
    magnifier_center[0] = pos[0]
    magnifier_center[1] = pos[1]

def draw(canvas):
    # 绘制图片
    canvas.draw_image(map_image, (MAP_WIDTH / 2, MAP_HEIGHT / 2), (MAP_WIDTH, MAP_HEIGHT),
                     (CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2), (CANVAS_WIDTH, CANVAS_HEIGHT))
Exemplo n.º 7
0
import math
from datetime import datetime

# 全局变量
interval = 1000  # 时间事件处理器触发的周期,1秒
hour = 0.0
minute = 0.0
second = 0.0
hour_radian = 0.0
minute_radian = 0.0
second_radian = 0.0
digit_date = ""
digit_time = ""
display_digit = False

clock_face = simplegui.load_image("images/ClockFace.jpg")
hour = simplegui.load_image("images/Hour.png")
minute = simplegui.load_image("images/Minute.png")
second = simplegui.load_image("images/Second.png")


# 定义按钮的事件处理函数
def toggle():
    global display_digit
    display_digit = not display_digit
    if display_digit:
        button.set_text("关闭数显")
    else:
        button.set_text("开启数显")

Exemplo n.º 8
0
"""
The explosion example in code skulptor
"""
import simpleguitk as simplegui

EXPLOSION_CENTRE = [50, 50]
EXPLOSION_SIZE = [100, 100]
EXPLOSION_DIM = [9, 9]

explosion_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/explosion.hasgraphics.png")

# create timer that iterate current_sprite_centre through sprite
time = 0

# define draw handler
def draw(canvas):
	global time
	explosion_index = [time % EXPLOSION_DIM[0], (time // EXPLOSION_DIM[0]) % EXPLOSION_DIM[1]]
	canvas.draw_image(explosion_image,
			[EXPLOSION_CENTRE[0] + explosion_index[0] * EXPLOSION_SIZE[0],
			EXPLOSION_CENTRE[1] + explosion_index[1] * EXPLOSION_SIZE[1]],
			EXPLOSION_SIZE, EXPLOSION_CENTRE, EXPLOSION_SIZE)
	time += 1
# end of draw()

# create frame and size frame based on 100x100 pixel sprite
frame = simplegui.create_frame("Asteroid sprite", EXPLOSION_SIZE[0], EXPLOSION_SIZE[1])

# set draw handler and canvas background using custom HTML colour
frame.set_draw_handler(draw)
frame.set_canvas_background("blue")
Exemplo n.º 9
0
# 华容道

import simpleguitk as simplegui

# 全局变量
canvas_height = 500  # 画布高度,单位为像素
canvas_width = 400  # 画布宽度,单位为像素
game_over = False  # 游戏是否结束
figure_moving = False  # 是否有运动的人物
all_figure = {}  # 所有人物
steps = 0  # 移动步数
current_figure = None  # 鼠标点中的人物
current_center = []  # 鼠标点中人物的中心坐标
original_point = []  # 鼠标点击的初始位置坐标
speed = 4  # 人物移动的速度
machao_image = simplegui.load_image("images/马超.png")
zhangfei_image = simplegui.load_image("images/张飞.png")
zhaoyun_image = simplegui.load_image("images/赵云.png")
huangzhong_image = simplegui.load_image("images/黄忠.png")
guanyu_image = simplegui.load_image("images/关羽.png")
caocao_image = simplegui.load_image("images/曹操.png")
soldier_image = simplegui.load_image("images/士兵.png")

# 绘制全部人物
def draw_all_figure(all_figure, canvas):
    for figure in all_figure.values():
        figure.draw(canvas)


# 检查移动人物与其它人物及边界的碰撞
def check_collide():
Exemplo n.º 10
0
# 定义步数
steps = 0

#是否完成
#finish = False

# 保存所有图像块的列表
board = [[None, None, None], [None, None, None], [None, None, None]]
yuan = [[None, None, None], [None, None, None], [None, None, None]]
#load那个函数参数是路径
# 1.设置图像,载入图像
im = Image.open(GetImagePath('./pictures'))
imBackground = im.resize((600, 600))
imBackground.save('pic22.bmp', 'BMP')
baymax = simplegui.load_image('pic22.bmp')  # pic.bmp

# 可以:https://images.cnblogs.com/cnblogs_com/kukicookie/1842259/o_200907100833untitled.png
# 可以:http://img.netbian.com/file/2020/0130/c5d20fe416022a3d72be820e76bfba9b.jpg
# 不可以:D:\python_files\pic.bmp
#此处修改了simplegui里的image.py,实现本地图片也能用


# 定义一个图像块的类
class Square:
    # 定义一个构造函数,用于初始化
    def __init__(self, coordinate):
        self.center = coordinate

    # 绘制图像的方法
    def draw(self, canvas, board_pos):
Exemplo n.º 11
0
# Mini-project #6 - Blackjack

import simpleguitk as simplegui
import random

# load card sprite - 936x384 - source: jfitz.com
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
card_images = simplegui.load_image(
    "http://storage.googleapis.com/codeskulptor-assets/cards_jfitz.png")

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = (36, 48)
card_back = simplegui.load_image(
    "http://storage.googleapis.com/codeskulptor-assets/card_jfitz_back.png")

# initialize some useful global variables
in_play = False
outcome = ""
score = 0
player_hand = []
dealer_hand = []
deck = []

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {
    'A': 1,
    '2': 2,
    '3': 3,
    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated


# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/debris2_blue.png"
)

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/nebula_blue.png"
)

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/splash.png"
)

# ship image
Exemplo n.º 13
0
        self.age += 1
        if (self.pos[0] < 0)  or (self.pos[0] > WIDTH) or (self.age >= self.lifespan):
            return True
        else:
            return False
        
    def collide(self, other_object):
        dis = dist(self.get_position(), other_object.get_position())
        if dis <= self.get_radius() + other_object.get_radius():
            return True
        else:
            return False

# image and sound resource
background_info = ImageInfo([383, 165], [766, 330])
background_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/140499012687.png")

splash_info = ImageInfo([286, 90], [572, 180])
splash_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/140499012492.png")

gameover_info = ImageInfo([163, 147], [327, 294])
gameover_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/140499012868.png")

zombie_info = ImageInfo([32, 50], [64, 100], 20, True, 15)
zombie_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/140499013175.png")

zombie1_info = ImageInfo([47.5, 56], [95, 112], 22, True, 17)
zombie1_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/14049901265.png")

shooter_info = ImageInfo([28.5, 32], [55.5, 64], 20, True, 15)
shooter_image = simplegui.load_image("http://byiah.img41.wal8.com/img41/427239_20140710190014/140499012446.png")
Exemplo n.º 14
0
import random
import json
import simpleguitk as simplegui
from tkinter import *
from tkinter.messagebox import showinfo
from SignupPage import SignupPage
from PIL import ImageTk, Image
infoPath = './info.json'
# 1.设置图像,载入图像
baymax = simplegui.load_image('./test.png')
Login = 0
# 设置画布尺寸
w = 600
h = w + 100

# 定义图像块的边长
image_size = w / 3

# 定义图像块坐标列表
all_coordinates = [
    [image_size * 0.5, image_size * 0.5],
    [image_size * 1.5, image_size * 0.5],
    [image_size * 2.5, image_size * 0.5],
    None,
    [image_size * 1.5, image_size * 1.5],
    [image_size * 2.5, image_size * 1.5],
    [image_size * 0.5, image_size * 2.5],
    [image_size * 1.5, image_size * 2.5],  # None
    [image_size * 2.5, image_size * 2.5]
]
'''
Exemplo n.º 15
0
#!python3
# Dec 12, 2019
# -*- coding: utf-8 -*-

import simpleguitk as simplegui
import random
# open the image from this website
#address = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576970052&di=3314b7ee3a4151fddf15ff0c0cacb32a&imgtype=jpg&er=1&src=http%3A%2F%2Fimg.sj33.cn%2Fuploads%2Fallimg%2F201404%2F7-140419131052964.jpg'
byamax = simplegui.load_image(
    'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576970052&di=3314b7ee3a4151fddf15ff0c0cacb32a&imgtype=jpg&er=1&src=http%3A%2F%2Fimg.sj33.cn%2Fuploads%2Fallimg%2F201404%2F7-140419131052964.jpg'
)
# set the screen size
WIDTH = 600
HEIGHT = WIDTH + 100
# set the size of the each piece of puzzle
IMAGE_SIZE = WIDTH / 3

# set the coordinates of the pieces
all_coordinates = [[IMAGE_SIZE * 0.5, IMAGE_SIZE * 0.5],
                   [IMAGE_SIZE * 1.5, IMAGE_SIZE * 0.5],
                   [IMAGE_SIZE * 2.5, IMAGE_SIZE * 0.5],
                   [IMAGE_SIZE * 0.5, IMAGE_SIZE * 1.5],
                   [IMAGE_SIZE * 1.5, IMAGE_SIZE * 1.5],
                   [IMAGE_SIZE * 2.5, IMAGE_SIZE * 1.5],
                   [IMAGE_SIZE * 0.5, IMAGE_SIZE * 2.5],
                   [IMAGE_SIZE * 1.5, IMAGE_SIZE * 2.5], None]

# set the screen to a 3x3 board
ROWS = 3
COLS = 3
Exemplo n.º 16
0
		return self.size

	def get_radius(self):
		return self.radius

	def get_lifespan(self):
		return self.lifespan

	def get_animated(self):
		return self.animated

# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim

# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")

# sound assets purchased from sounddogs.com, please do not redistribute
ship_thrust_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3")

# ship class
class Ship:
	def __init__(self, pos, vel, angle, image, info):
		self.pos = [pos[0], pos[1]]
		self.vel = [vel[0], vel[1]]
		self.thrust = False
		self.angle = angle
		self.angle_vel = 0
		self.image = image
		self.image_centre = info.get_centre()
		self.image_size = info.get_size()
    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated

    
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
    
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2014.png")

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")

# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")

# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 50)
Exemplo n.º 18
0

# 创建窗口
# 16强共32张图片,每个图片的显示大小为128x128像素
# 32张图片显示为4行8列,因此窗口的宽度为128x8=1024像素,高度为128x4=512像素
frame = simplegui.create_frame("2014巴西世界杯16强连连看", 1024, 512)
frame.add_button("重新开始", new_game, 100)
label = frame.add_label("回合次数 = 0")

# 注册事件处理函数
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)


# 读取图片
logo_image = simplegui.load_image("images\\Logo.png")
flag_image.append(simplegui.load_image("images\\Algeria.png"))
flag_image.append(simplegui.load_image("images\\Argentina.png"))
flag_image.append(simplegui.load_image("images\\Belgium.png"))
flag_image.append(simplegui.load_image("images\\Brazil.png"))
flag_image.append(simplegui.load_image("images\\Chile.png"))
flag_image.append(simplegui.load_image("images\\Colombia.png"))
flag_image.append(simplegui.load_image("images\\Costa-rica.png"))
flag_image.append(simplegui.load_image("images\\France.png"))
flag_image.append(simplegui.load_image("images\\Germany.png"))
flag_image.append(simplegui.load_image("images\\Greece.png"))
flag_image.append(simplegui.load_image("images\\Mexico.png"))
flag_image.append(simplegui.load_image("images\\Netherlands.png"))
flag_image.append(simplegui.load_image("images\\Nigeria.png"))
flag_image.append(simplegui.load_image("images\\Switzerland.png"))
flag_image.append(simplegui.load_image("images\\Uruguay.png"))
# Blackjack

import simpleguitk as simplegui
import random

# load card sprite - 936x384
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
card_images = simplegui.load_image(
    "https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-6/images/cards.png"
)

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = (36, 48)
card_back = simplegui.load_image(
    "https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-6/images/cards_back.png"
)

# initialize some useful global variables
in_play = False
outcome = ""
score = 0

# define globals for cards
SUITS = ("C", "S", "H", "D")
RANKS = ("A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K")
VALUES = {"A": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "T": 10, "J": 10, "Q": 10, "K": 10}

# define card class
class Card:
    def __init__(self, suit, rank):
Exemplo n.º 20
0
 
    def get_lifespan(self):
        return self.lifespan
 
    def get_animated(self):
        return self.animated
 
 
# art assets created by Kim Lathrop, may be freely re-used in
# non-commercial projects, please credit Kim
 
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png,
# debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
 
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.png")
 
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")
 
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image(
    "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
        index_x = 0
        location_card_x = 0
        for card in list_cards:
            if exposed[index_y][index_x] == False:
                canvas.draw_image(game_thrones, (412 / 2, 564 / 2), (412, 564),
                                  ((WIDTH_CARD / 2) + location_card_x, (HEIGHT_CARD / 2) + location_card_y), (WIDTH_CARD, HEIGHT_CARD))
            else:
                canvas.draw_image(card, (412 / 2, 564 / 2), (412, 564),
                                  ((WIDTH_CARD / 2) + location_card_x, (HEIGHT_CARD / 2) + location_card_y), (WIDTH_CARD, HEIGHT_CARD))
            index_x += 1
            location_card_x += WIDTH_CARD
        index_y += 1
        location_card_y += HEIGHT_CARD

# load images
game_thrones = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/game_thrones.jpg")
catelyn_tully = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/catelyn_tully.jpg")
cersei_lannister = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/cersei_lannister.jpg")
daenerys_targaryen = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/daenerys_targaryen.jpg")
eddard_stark = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/eddard_stark.jpg")
jaime_lannister = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/jaime_lannister.jpg")
joffrey_baratheon = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/joffrey_baratheon.jpg")
jon_snow = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/jon_snow.jpg")
loras_tyrell = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/loras_tyrell.jpg")
lysa_tully = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/lysa_tully.jpg")
margaery_tyrell = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/margaery_tyrell.jpg")
oberyn_martell = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/oberyn_martell.jpg")
renly_baratheon = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/renly_baratheon.jpg")
robb_stark = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/robb_stark.jpg")
robert_baratheon = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/robert_baratheon.jpg")
sansa_stark = simplegui.load_image("https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-5/images/sansa_stark.jpg")
Exemplo n.º 22
0
# -*- coding: utf-8 -*-

import simpleguitk as simplegui
import random

## 定义常量
# 画布的尺寸
WIDTH = 800
HEIGHT = 600

# 骨牌的尺寸、中心位置及所有骨牌的图像
DOMINO_SIZE = (70, 190)
DOMINO_CENTER = (35, 95)
domino_images = simplegui.load_image("http://")

# 所有骨牌。文牌是成对的,武牌是独一无二的。
DOMINOES = ('TIAN', 'TIAN', 'DI', 'DI', 'REN', 'REN', 'HE', 'HE', 'MEI', 'MEI', 'CHANG', 'CHANG', \
            'BAN', 'BAN', 'FU', 'FU', 'HONG', 'HONG', 'GAO', 'GAO', 'LING', 'LING', \
            'JIU1', 'JIU2', 'BA1', 'BA2', 'QI1', 'QI2', 'WU1', 'WU2', 'ZHIZUN1', 'ZHIZUN2')

# 所有骨牌对应的点数
POINTS = {'TIAN':12, 'DI':2, 'REN':8, 'HE':4, 'MEI':10, 'CHANG':6, 'BAN':4, 'FU':11, 'HONG':10, \
          'GAO':7, 'LING':6, 'JIU1':9, 'JIU2':9, 'BA1':8, 'BA2':8, 'QI1':7, 'QI2':7, 'WU1':5, \
          'WU2':5, 'ZHIZUN1':6, 'ZHIZUN2':3}

# 对牌与其排位、名称
DOMINO_PATTERNS = {('ZHIZUN1', 'ZHIZUN2'):(1, '至尊宝'), ('TIAN', 'TIAN'):(2, '双天'), ('DI', 'DI'):(3, '双地'), \
                   ('REN', 'REN'):(4, '孖人'), ('HE', 'HE'):(5, '孖和'), ('MEI', 'MEI'):(6, '孖梅'), \
                   ('CHANG', 'CHANG'):(7, '孖长'), ('BAN', 'BAN'):(8, '孖板凳'), ('FU', 'FU'):(9, '孖斧头'), \
                   ('HONG', 'HONG'):(10, '孖红头'), ('GAO', 'GAO'):(11, '孖高脚'), ('LING', 'LING'):(12, '孖零霖'), \
                   ('JIU1', 'JIU2'):(13, '杂九'), ('BA1', 'BA2'):(14, '杂八'), ('QI1', 'QI2'):(15, '杂七'), \
Exemplo n.º 23
0
# demo for drawing using tiled images

import simpleguitk as simplegui

# define globals for cards
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
SUITS = ('C', 'S', 'H', 'D')

# card sprite - 950x392
CARD_CENTER = (36.5, 49)
CARD_SIZE = (73, 98)
card_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")



# define card class
class Card:
    def __init__(self, suit, rank):
        self.rank = rank
        self.suit = suit

    def draw(self, canvas, loc):
        i = RANKS.index(self.rank)
        j = SUITS.index(self.suit)
        card_pos = [CARD_CENTER[0] + i * CARD_SIZE[0],
                    CARD_CENTER[1] + j * CARD_SIZE[1]]
        canvas.draw_image(card_image, card_pos, CARD_SIZE, loc, CARD_SIZE)

# define draw handler        
def draw(canvas):
    one_card.draw(canvas, (155, 90))
Exemplo n.º 24
0
import random

#定义全局变量
WIDTH = 400
HEIGHT = 400               #画布高度和宽度 
image_size= [60,60]        #手势图像高度和宽度
gesture_image = []         # 3张手势图片
choice_image = []          # 显示的2张出拳的图片 
#index_image = [0,1,2]
turns = 0                  #表示局数
score1,score2 = 0, 0       #得分
started = False            #控制是否进入游戏界面
mouse_pos =(0,0)
message = ""               #屏幕上显示输赢的信息 

background1_image = simplegui.load_image("images\\background1.png")
background2_image = simplegui.load_image("images\\background2.png")
start_image = simplegui.load_image("images\\start.png")
gesture_image.append(simplegui.load_image("images\\scissors.png"))
gesture_image.append(simplegui.load_image("images\\stone.png"))
gesture_image.append(simplegui.load_image("images\\cloth.png"))
choice_image.append(simplegui.load_image("images\\stone.png"))
choice_image.append(simplegui.load_image("images\\stone.png"))
background_sound = simplegui.load_sound("sound\\sound1.ogg")
# 定义函数

#定义事件处理函数
def newgame():
    global turns, score1, score2, message 
    turns = 0
    score1,score2 = 0, 0
Exemplo n.º 25
0
voiceover = ''
rule = '大规则:同花顺>铁支(四张相同)>葫芦(三带二)>同花>顺子>三条>两对>对子>散牌'
m_win_num = 0
p_win_num = 0
side_flag = ''
p_total_money = 10000
m_total_money = 1000000
bet_money = 0
p_bet_money = 100
m_bet_money = 100
p_is_bet = False
m_is_bet = False
# Source
CARD_SIZE = (72, 111)                 #加载图片资料
CARD_CENTER = (36, 55.5)
card_images = simplegui.load_image("image\\card.png")

CARD_BACK_SIZE = [72, 111]             #加载扑克背面图片
CARD_BACK_CENTER = [36, 55.5]
card_back = simplegui.load_image("image\\back.png")


background_size = [808, 606]           #加载开始前背景图片
background_center = [404, 303]
background_image = simplegui.load_image("image\\shguize1.png")

# initialize some useful global variables
in_play, stand_flag, bet_flag, flag= False, False, False, -1
value = -1
total = 0
pos = [140, 180]
Exemplo n.º 26
0
        return self.center

    def get_size(self):
        return self.size

    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated

grassland_info = ImageInfo([960, 600], [1920, 1200])
grassland_image = simplegui.load_image("resources/grassland.jpg") # 地面背景
arrow_info = ImageInfo([21, 5], [42, 10],5,60)
arrow_image = simplegui.load_image("resources/arrow.png")         # 箭
castle_info = ImageInfo([54, 52], [109, 105],50)
castle_image = simplegui.load_image("resources/castle.png")       # 城堡
enemy_info = ImageInfo([32, 15], [64, 29], 15, 1000, True)
enemy_image = simplegui.load_image("resources/enemy.png")         # 敌人,图像文件中包含4副图片用来实现动画
soldier_info = ImageInfo([32, 26], [64, 52])
soldier_image = simplegui.load_image("resources/soldier.png")     # 战士,图像文件中包含2副图片用来实现动画
win_info = ImageInfo([320, 240], [640, 480])
win_image = simplegui.load_image("resources/win.png")             # 游戏成功
gameover_info = ImageInfo([320, 240], [640, 480])
gameover_image = simplegui.load_image("resources/gameover.png")   # 游戏结束
explosion_info = ImageInfo([64, 64], [128, 128], 17, 24, True)
explosion_image = simplegui.load_image("resources/explosion.png") # 爆炸,图像文件中包含多副图片用来实现动画
Exemplo n.º 27
0
    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated

    
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
    
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image_url = {'local' : "E:\MyDropbox\Photos\spaceship\debris2_blue.png",
                    'web' : "https://dl.dropbox.com/s/ltii3ztqgesc8kk/debris2_blue.png"}
debris_image = simplegui.load_image(debris_image_url[mode])

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image("https://dl.dropbox.com/s/1b8nkxdedap16kc/nebula_blue.s2014.png")

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image("https://dl.dropbox.com/s/vkcje1kj1kzfrgp/splash.png")

# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("https://dl.dropbox.com/s/8l4zmm1ez6lyqnb/double_ship.png")

# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 50)
Exemplo n.º 28
0

# 创建窗口
# 8强共16张图片,每个图片的显示大小为128x128像素
# 16张图片显示为4行4列,因此窗口的宽度为128x4=512像素,高度为128x4=512像素
frame = simplegui.create_frame("2014巴西世界杯8强连连看", 512, 512)
frame.add_button("重新开始", new_game, 100)
label = frame.add_label("回合次数 = 0")

# 注册事件处理函数
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)


# 读取图片
background_image = simplegui.load_image("images/background.png")
logo_image = simplegui.load_image("images/Logo.png")
flag_image.append(simplegui.load_image("images/Argentina.png"))
flag_image.append(simplegui.load_image("images/Belgium.png"))
flag_image.append(simplegui.load_image("images/Brazil.png"))
flag_image.append(simplegui.load_image("images/Colombia.png"))
flag_image.append(simplegui.load_image("images/Costa-rica.png"))
flag_image.append(simplegui.load_image("images/France.png"))
flag_image.append(simplegui.load_image("images/Germany.png"))
flag_image.append(simplegui.load_image("images/Netherlands.png"))

# 读取世界杯之歌
background_sound = simplegui.load_sound("sound/We_Are_One.ogg")
# 启动游戏
new_game()
frame.start()
Exemplo n.º 29
0
# input will come from buttons and an input field
# all output for the game will be printed in the console

import simpleguitk as simplegui # 简单用户图形界面接口
import random    # 用random.randrange(start, stop)随机产生秘密的房间号
import math      # 用math.log(x, base)计算猜中所需的最少次数

# 初始化全局变量
secret_number = 1    # 每个回合计算机随机产生的秘密数字
remaining_guesses =0 # 一个回合剩余的猜测次数
range_low = 1        # 秘密房间号的下限
range_high = 25     # 秘密房间号的上限
canvas_height = 500                   # 画布高度,单位为像素
canvas_width = 500                    # 画布宽度,单位为像素
room_list = []                        # 所有房间,
cat_image = simplegui.load_image("cat.png")
# 启动或重新启动游戏的辅助函数
def new_game():
    global secret_number
    global remaining_guesses
    global room_list
    secret_number = random.randrange(range_low, range_high + 1)
    remaining_guesses = int(math.ceil(math.log(range_high, 2)))
    print()  # 为新一轮游戏输出一空白行,以便和上一轮游戏的输出分开
    print("新一轮游戏开始")
    print("你应当在%s和%s之间猜测一个数字" % (range_low, range_high))
    print("你还剩%s次猜测机会!" % remaining_guesses)
    print("请输入你猜测的房间号并按回车键")

    room_list = []
    for i in range(range_high):
Exemplo n.º 30
0

# 创建窗口
# 8强共16张图片,每个图片的显示大小为128x128像素
# 16张图片显示为4行4列,因此窗口的宽度为128x4=512像素,高度为128x4=512像素
frame = simplegui.create_frame("2014巴西世界杯8强连连看", 512, 512)
frame.add_button("重新开始", new_game, 100)
label = frame.add_label("回合次数 = 0")

# 注册事件处理函数
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)


# 读取图片
background_image = simplegui.load_image("images\\background.png")
logo_image = simplegui.load_image("images\\Logo.png")
flag_image.append(simplegui.load_image("images\\Argentina.png"))
flag_image.append(simplegui.load_image("images\\Belgium.png"))
flag_image.append(simplegui.load_image("images\\Brazil.png"))
flag_image.append(simplegui.load_image("images\\Colombia.png"))
flag_image.append(simplegui.load_image("images\\Costa-rica.png"))
flag_image.append(simplegui.load_image("images\\France.png"))
flag_image.append(simplegui.load_image("images\\Germany.png"))
flag_image.append(simplegui.load_image("images\\Netherlands.png"))

# 读取世界杯之歌
background_sound = simplegui.load_sound("sound\\We_Are_One.ogg")
# 启动游戏
new_game()
frame.start()
Exemplo n.º 31
0
 def __init__(self):
     self.images = []
     for i in range(1, 13):
         image = simplegui.load_image(source + str(i) + ".png")
         self.images.append(image)
Exemplo n.º 32
0
# user interface
score = 0
lives = 3
time = 0.5
gameover = False
started = False
explosion_group = set()
rock_group = set()
bonus_group = set()

# game
missile = False

#  ------------- IMAGES ---------------------------#
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(DEBRIS)

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(NEBULA)
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(SPLASH)
gameover_image = simplegui.load_image(GAMEOVER)
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image(SHIP)

debris_image = simplegui.load_image(DEBRIS)
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
# Mini-project #6 - Blackjack

import simpleguitk as simplegui
import random

# load card sprite - 936x384 - source: jfitz.com
CARD_SIZE = (72, 96)
CARD_CENTER = (36, 48)
card_images = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/cards_jfitz.png")

CARD_BACK_SIZE = (72, 96)
CARD_BACK_CENTER = (36, 48)
card_back = simplegui.load_image("http://storage.googleapis.com/codeskulptor-assets/card_jfitz_back.png")

# initialize some useful global variables
in_play = False
outcome = "Hit or Stand?"
player_score = 0
dealer_score = 0

# define globals for cards
SUITS = ('C', 'S', 'H', 'D')
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
VALUES = {'A': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 10, 'Q': 10, 'K': 10}


# define card class
class Card:
    def __init__(self, suit, rank):
        if (suit in SUITS) and (rank in RANKS):
            self.suit = suit
# Image positioning problem

###################################################
# Student should enter code below

import simpleguitk as sg

# global constants
WIDTH = 1000
HEIGHT = 1000
click_pos = [WIDTH/2, HEIGHT/2]

# load test image
image_st = sg.load_image("https://avatars2.githubusercontent.com/u/15324716?s=400&u=037e1fd9b770fd07e2b93a6a0a468449e296978d&v=4")
image_sz = [image_st.get_width(), image_st.get_height()]
image_ct = [image_sz[0]/2, image_sz[1]/2]

# mouseclick handler
def click(pos):
    global click_pos
    click_pos = pos
    
# draw handler
def draw(canvas):
    canvas.draw_image(image_st, image_ct, image_sz,
                        click_pos, image_sz)

    
# create frame and register draw handler    
frame = sg.create_frame("Test image", WIDTH, HEIGHT)
frame.set_canvas_background("Gray")
Exemplo n.º 35
0
        self.pos = [pos[0],pos[1]]
        self.image = image
        self.image_center = info.get_center()
        self.image_size = info.get_size()
   
    def get_position(self):
        return self.pos
    
    def set_y(self, y):
        self.pos[1] = y
    
    def draw(self, canvas):
            canvas.draw_image(self.image, self.image_center, self.image_size, self.pos, [90, 240])

background_info = ImageInfo([400, 337], [800, 673])
background_image = simplegui.load_image("http://d2.freep.cn/3tb_1407151317143r1o535025.png")

circle_info = ImageInfo([76, 205], [152, 410])
circle_image = simplegui.load_image("http://d2.freep.cn/3tb_1407141630147118535025.png")

pole_info = ImageInfo([298, 15], [596, 29])
pole_image = simplegui.load_image("http://d2.freep.cn/3tb_140715131715ya7m535025.png")

  
success_info = ImageInfo([166, 33], [332, 66])
success_image = simplegui.load_image("http://d2.freep.cn/3tb_140715131715lw5u535025.png")
 
info_info = ImageInfo([471, 244], [942, 489])
info_image = simplegui.load_image("http://d3.freep.cn/3tb_140715131714rgsh535025.png")

Exemplo n.º 36
0
#GUI框架
import simpleguitk as sim
#随机数模块
import random

#获取网络照片
myPicture = sim.load_image(
    "http://img.zcool.cn/community/0142135541fe180000019ae9b8cf86.jpg@1280w_1l_2o_100sh.png"
)

#定义画布的宽、高
WIDTH = 600
HEIGHT = 700

#定义图像块的边长
IMAGE_SIZE = WIDTH / 3

#定义棋盘的行和列
ROWS = 3
COLS = 3

#定义步数
steps = 0

#定义一个列表存放图像块的坐标
all_coord_pos = [[100,100],[300,100],[500,100], \
                [100,300],[300,300],[500,300], \
                [100,500],[300,500],None]

#定义一个列表保存图像块
borad = [[None, None, None], [None, None, None], [None, None, None]]