本文整理汇总了Python中simplegui.load_image函数的典型用法代码示例。如果您正苦于以下问题:Python load_image函数的具体用法?Python load_image怎么用?Python load_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_image函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, pos):
self.center_x = pos
self.y_top = random.randrange(PIPE_HEAD_HEIGHT * 2, GAME_HEIGHT - PIPE_OPENING_HEIGHT - (PIPE_HEAD_HEIGHT * 2))
self.y_bottom = self.y_top + PIPE_OPENING_HEIGHT
self.is_stop = True
self.is_passed = False
self.pipe_body_image = simplegui.load_image(PIPE_BODY_IMAGE)
self.pipe_head_down_image = simplegui.load_image(PIPE_HEAD_DOWN_IMAGE)
self.pipe_head_up_image = simplegui.load_image(PIPE_HEAD_UP_IMAGE)
开发者ID:zincsoda,项目名称:flappy_bird,代码行数:9,代码来源:7_create_and_remove_pipes.py
示例2: __init__
def __init__(self, pos):
self.width = PIPE_WIDTH
self.center_x = pos
self.y_top = random.randrange(70, STAGE_HEIGHT - PIPE_GAP_Y - 70)
self.y_bottom = self.y_top + PIPE_GAP_Y
self.is_stop = True
self.is_passed = False
self.body_image = simplegui.load_image("https://raw.github.com/ben7th/flappy-html5-bird/gh-pages/ui/images/pipe_body.png")
self.head1_image = simplegui.load_image("https://raw.github.com/ben7th/flappy-html5-bird/gh-pages/ui/images/pipe_head_1.png")
self.head2_image = simplegui.load_image("https://raw.github.com/ben7th/flappy-html5-bird/gh-pages/ui/images/pipe_head_2.png")
开发者ID:zincsoda,项目名称:flappy_bird,代码行数:10,代码来源:original.py
示例3: start
def start():
global lives, score, time, started, debris_image, nebula_image
lives = 3
score = 0
time = 0
timer.start()
soundtrack.play()
started = True
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris3_brown.png")
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.png")
开发者ID:hieast,项目名称:PlayGround,代码行数:10,代码来源:RiceRocket.py
示例4: init
def init(self):
global card_images, card_back, score
card_images = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")
card_back = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/card_back.png")
self.deal()
# Score is just reset at start of game
score = 0
return
开发者ID:hemmerling,项目名称:python-coursera2012,代码行数:10,代码来源:blackjack_codesculptor.py
示例5: build_game
def build_game(self):
# create timer and frame
self.frame = simplegui.create_frame("Blackjack", CANVAS_W, CANVAS_H)
self.cards_url = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")
self.card_back = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/card_back.png")
# register event handlers
self.frame.add_button(" Deal ", self.deal, 100)
self.frame.add_button(" Hit ", self.hit, 100)
self.frame.add_button(" Stand ", self.stand, 100)
self.frame.set_draw_handler(self.draw_handler)
self.frame.set_canvas_background("Green")
# start frame
self.frame.start()
开发者ID:mistert14,项目名称:mistert-skulpt,代码行数:13,代码来源:blackjack.py
示例6: rock_spawner
def rock_spawner():
if asteroids.started:
if len(asteroids.rock_group) <12:
if asteroids.time % 100 == 0:
rock_pos = [random.randrange(0, asteroids.width), random.randrange(0, asteroids.height)]
rock_vel = [random.random() * .6 - .3, random.random() * .6 - .3]
rock_avel = random.random() * .2 - .1
url = "http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/"
url_asteroid_1 = url + "asteroid_blue.png"
url_asteroid_2 = url + "asteroid_brown.png"
url_asteroid_3 = url + "asteroid_blend.png"
urls = [url_asteroid_1, url_asteroid_2, url_asteroid_3]
print str(random.choice(urls))
asteroid_image = simplegui.load_image(str(random.choice(urls)))
new_set = []
print "new pos", new_set
for p in group_of_players:
if (dist(rock_pos, p.pos) > p.radius + asteroid_info.radius):
new_set.append (True)
else:
new_set.append(False)
print new_set
# for n in new_set:
if new_set[len(new_set)-1] == True and new_set[0] == True:
a_rock = Sprite(rock_pos, rock_vel, 0, rock_avel, asteroid_image, asteroid_info)
asteroids.rock_group.add(a_rock)
开发者ID:josegallo,项目名称:python-asteroids,代码行数:26,代码来源:Asteroids-2players.py
示例7: __init__
def __init__(self):
self.tl = ( 400, 770 - 182 )
self.br = ( 400 + 150 , 770 )
#Rectangle.__init__(self,tl,br)
url3 = 'https://lh3.googleusercontent.com/-ISPY4T0J2Kw/VQuHOqIHB9I/AAAAAAAAHw8/p-8OF-7fayc/w150-h182-no/waste.png'
self.garbage = simplegui.load_image(url3)
开发者ID:semisided1,项目名称:cousera-iip,代码行数:7,代码来源:user39_wvz2tEacHD46Vlo_2.py
示例8: draw
def draw(self, canvas):
if self.destroy == False:
canvas.draw_image(self.image, self.image_center, self.image_size,
self.pos, self.image_size, self.angle)
if dist(self.pos, self.lifespan) > 300:
if self.radius < 10:
missile_group.remove(self)
if self.destroy == True:
if self.time1<25:
explosion_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/explosion_alpha.png")
EXPLOSION_CENTER = [64, 64]
EXPLOSION_SIZE = [128, 128]
EXPLOSION_DIM = [24, 9]
explosion_index = [self.time1 % EXPLOSION_DIM[0], 0]
canvas.draw_image(explosion_image,
[EXPLOSION_CENTER[0] + explosion_index[0] * EXPLOSION_SIZE[0],
EXPLOSION_CENTER[1] + explosion_index[1] * EXPLOSION_SIZE[1]],
EXPLOSION_SIZE, self.pos, EXPLOSION_SIZE)
self.time1+=1
else:
self.time1=0
rock_group.remove(self)
if self.destroy == False and self.radius > 10:
for m in missile_group:
if dist(self.pos, m.pos) < self.radius + m.radius:
self.destroy_itself()
explosion_sound.rewind()
explosion_sound.play()
m.destroy_itself()
开发者ID:dmytrofrolov,项目名称:python,代码行数:29,代码来源:SpaceShip.py
示例9: guess_a_letter
def guess_a_letter(guess):
global correct_input, guessed_letter, cnt, guessed_letters, word, missed_letters, guess_result, warning_msg, result_msg, hangmanpic, guess_result_str, missed_letters_str, image
if result_msg == "":
if cnt < 6:
correct_input = False
if len(guess) != 1:
warning_msg = "*ONLY ONE* letter!"
elif not ('a' <= guess.lower() <= 'z'):
warning_msg = "a *LETTER*!"
elif guess in guessed_letters:
warning_msg = "Already guessed!"
else:
guessed_letters += guess.lower()
warning_msg = ""
correct_input = True
if correct_input:
new_guess_result = ""
if guess in word:
for i in range(0, len(word)):
if word[i] == guess:
new_guess_result += guess
else:
new_guess_result += guess_result[i]
guess_result = new_guess_result
else:
missed_letters += guess
cnt += 1
image = simplegui.load_image("https://dl.dropboxusercontent.com/u/52743103/hangman/hangman" + str(cnt) + ".jpg")
guess_result_str = add_underline(guess_result)
missed_letters_str = "Missed letter: " + missed_letters
if guess_result == word:
result_msg = "You win!"
elif cnt == 6:
result_msg = "You lose!"
开发者ID:nkukarl,项目名称:inventwithpython,代码行数:35,代码来源:hangman.py
示例10: init
def init():
global WIDTH, HEIGHT, number_cards, cards, flipped, game_state, moves
global image_atlas, image_coords
WIDTH = 150 * 4
HEIGHT = 150 * 4
number_cards = 16 # 4x4=16
cards = list()
for i in range(number_cards // 2):
for j in range(2):
card = Card()
card.value = i
cards.append(card)
random.shuffle(cards) # unsort card list
flipped = list() # list of flipped cards
game_state = False
moves = 0 # number of moves
image_atlas = simplegui.load_image("http://goo.gl/0Ea0R") # card image
image_coords = {"0": ((100, 100), (200, 200)),
"1": ((300, 100), (200, 200)),
"2": ((500, 100), (200, 200)),
"3": ((100, 300), (200, 200)),
"4": ((300, 300), (200, 200)),
"5": ((500, 300), (200, 200)),
"6": ((100, 500), (200, 200)),
"7": ((300, 500), (200, 200)),
"8": ((500, 500), (200, 200))}
开发者ID:hellodk,项目名称:Games,代码行数:26,代码来源:MemoryGame.py
示例11: __init__
def __init__(self, url, size, animated = False, layout = "horizontal", n_tiled = [1]):
"""The data like size, animated, etc. are not valid for another image source, so
why not integrate the image url into the class.
:url: @ imaage url
:size: @ size of one tiled image, may not be the full size of image source
:animated: @ will it automatically iterate through tiled images when drawing
:layout: @ geometry indexing of tiled images
:n_tiled: @ number of tiled images in each dimensions
get_center(*indexes) @ get the center coordinates according to indexes
draw(canvas, pos, output_size, *indexes) @ draw image on canvas at pos with output_size.
"""
self.img = simplegui.load_image(url)
self.size = size
self._center = [l // 2 for l in size]
self.animated = animated
self.layout = layout
self.n_tiled = n_tiled
if animated: # cache the current displayed tiled image's index
self.tiled_pos = [0] * len(n_tiled)
if len(self.n_tiled) < len(self.size): # because I can't use izip_longest
self.n_tiled += [float('inf')] * (len(self.size) - len(self.n_tiled))
开发者ID:jjliun,项目名称:Python,代码行数:26,代码来源:spaceship2.py
示例12: draw_tops
def draw_tops(canvas):
# Draws the blank tops and if the length of the top is greater
# than 0 it draws the last card in the top
global top0, top1, top2, top3
TOPBLANK = simplegui.load_image('http://i.imgur.com/MOQhHbc.png')
CARDWIDTH = TOPBLANK.get_width()
CARDHEIGHT = TOPBLANK.get_height()
DRAWSCALE = 1.1
LOC_BACK_Y = 76
START_X = 500
DIST_BETWEEN = 100
top_dict = [top0, top1, top2, top3]
for tops in range(4):
LOC_BACK_X = START_X + DIST_BETWEEN * tops
canvas.draw_image(TOPBLANK, (CARDWIDTH /2 , CARDHEIGHT / 2),
(CARDWIDTH, CARDHEIGHT),
(LOC_BACK_X, LOC_BACK_Y),
(CARDWIDTH * DRAWSCALE, CARDHEIGHT * DRAWSCALE))
if len(top_dict[tops]) > 0:
top_dict[tops][-1].set_X(LOC_BACK_X)
top_dict[tops][-1].set_Y(LOC_BACK_Y)
top_dict[tops][-1].get_cardfront(canvas)
开发者ID:anjandev,项目名称:Programming-Class,代码行数:31,代码来源:Solitaire.py
示例13: loadImages
def loadImages():
global imageMap
global imageList
global facedownImage
# Make 1 single list of all image names
for key in IMAGE_NAME_MAP:
print "Adding " + key + " to image list"
print "Adding " + IMAGE_NAME_MAP[key] + " to image list"
imageList.append(key)
imageList.append(IMAGE_NAME_MAP[key])
# Load each image
for imageName in imageList:
imageMap[imageName] = simplegui.load_image(GAME_ASSETS + imageName)
# Load the facedown image - from weheartnintendo.tumblr
facedownImage = simplegui.load_image(GAME_ASSETS + "unturned.jpg")
开发者ID:mwales,项目名称:education,代码行数:18,代码来源:game.py
示例14: __init__
def __init__(self, img, center, size, radius = 0, lifespan = 0, animated = False, dimensions = []):
self.center = center
self.size = size
self.radius = radius
self.dimensions = dimensions
self.lifespan = lifespan
self.animated = animated
COMMON_URL = ASSETS_URL
if lifespan != 60: COMMON_URL += "lathrop/"
self.image = simplegui.load_image(COMMON_URL + img)
开发者ID:heldersepu,项目名称:hs-scripts,代码行数:10,代码来源:asteroids.py
示例15: draw
def draw(canvas):
global time, lives, score, debris_image, nebula_image
# animiate background
time += 1
wtime = (time / 4) % WIDTH
center = debris_info.get_center()
size = debris_info.get_size()
canvas.draw_image(nebula_image, nebula_info.get_center(), nebula_info.get_size(), [WIDTH / 2, HEIGHT / 2], [WIDTH, HEIGHT])
canvas.draw_image(debris_image, center, size, (wtime - WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT))
canvas.draw_image(debris_image, center, size, (wtime + WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT))
# draw user interface
canvas.draw_text("lives = " + str(lives), [WIDTH / 6, HEIGHT / 10],
22, "White")
canvas.draw_text("score = " + str(score), [WIDTH * 4 / 6, HEIGHT / 10],
22, "White")
# draw and update rocks and missiles
process_sprite_group(rock_group, canvas)
process_sprite_group(missile_group, canvas)
process_sprite_group(explosion_group, canvas)
# draw and update ship
my_ship.draw(canvas)
my_ship.update()
# update lives if ship collides rock
if group_collide(rock_group, my_ship):
lives -= 1
if lives < 1:
stop()
# update score
score += 10 * group_group_collide(rock_group, missile_group)
if score == 300:
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris_blend.png")
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_brown.png")
# draw splash screen if not started
if not started:
canvas.draw_image(splash_image, splash_info.get_center(),
splash_info.get_size(), [WIDTH / 2, HEIGHT / 2],
splash_info.get_size())
开发者ID:hieast,项目名称:PlayGround,代码行数:42,代码来源:RiceRocket.py
示例16: __init__
def __init__(self, fname, center, size, radius = 0, lifespan = None, animated = False):
self.center = center
self.size = size
self.radius = radius
if lifespan:
self.lifespan = lifespan
else:
self.lifespan = float('inf')
self.animated = animated
#print fullpath(self.depath,fname)
self.image = gui.load_image(fullpath(self.depath,fname))
开发者ID:chenxiao4,项目名称:GitHubRepo,代码行数:11,代码来源:spaceship.py
示例17: __init__
def __init__(self,image_file,center,size,radius=0,lifespan=0,animated=False,tiles=1):
self.image=simplegui.load_image(image_file)
self.center = center
self.size = size
self.radius = radius
self.tiles=tiles
if lifespan:
self.lifespan = lifespan
else:
self.lifespan = float('inf')
self.animated = animated
开发者ID:tejasai97,项目名称:pang-game,代码行数:11,代码来源:python_game.py
示例18: __init__
def __init__(self, name, image, center, size, radius = 0, lifespan = None, animated = False):
self.name = name
self.center = center
self.size = size
self.radius = radius
self.image = simplegui.load_image(image)
if lifespan:
self.lifespan = lifespan
else:
self.lifespan = float('inf')
self.animated = animated
开发者ID:mistert14,项目名称:mistert-skulpt,代码行数:11,代码来源:coursera8_corr.py
示例19: draw_card_back
def draw_card_back(canvas, LOC_BACK_X, LOC_BACK_Y):
# returns a graphic that represents the back of a card
SET = simplegui.load_image('http://i.imgur.com/p6hCw9U.png')
CARDWIDTH = SET.get_width()
CARDHEIGHT = SET.get_height()
DRAWSCALE = 1.2
return canvas.draw_image(SET, (CARDWIDTH /2 , CARDHEIGHT / 2),
(CARDWIDTH, CARDHEIGHT),
(LOC_BACK_X, LOC_BACK_Y),
(CARDWIDTH * DRAWSCALE, CARDHEIGHT * DRAWSCALE))
开发者ID:anjandev,项目名称:Programming-Class,代码行数:11,代码来源:Solitaire.py
示例20: __init__
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()
开发者ID:balta2ar,项目名称:algorithmicthink-001,代码行数:13,代码来源:alg_counties_simplegui.py
注:本文中的simplegui.load_image函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论