本文整理汇总了Python中tealight.art.image函数的典型用法代码示例。如果您正苦于以下问题:Python image函数的具体用法?Python image怎么用?Python image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: vertical
def vertical():
for i in range(0,width):
for j in range(0,height):
if i % 4 == 0:
image(x + i * 60, y + j * 60, "misc/YellowFlower.png")
else:
image(x + i * 60, y + j * 60, "misc/Clover.png")
示例2: gameOver
def gameOver(i, j):
tx = startx + i * size
ty = starty + j * size
red(tx,ty)
bombx=(size-48)/2
image(tx + bombx,ty+bombx, "http://png-2.findicons.com/files/icons/2023/standard_smile/48/bomb.png")
image((screen_width-260)/2,starty + size*5 - 82, "http://media.urbandictionary.com/image/page/gameover-8320.jpg")
示例3: diagonal
def diagonal(spacing):
for i in range(0,width):
for j in range(0,height):
if (i+j) % spacing == 0:
image(x + i * 60, y + j * 60, "misc/YellowFlower.png")
else:
image(x + i * 60, y + j * 60, "misc/Clover.png")
示例4: draw
def draw(Num_1,Num_2):
if Winner == 3:
image(850,50,"http://i.imgur.com/0zoXV5h.png")
color("White")
box(840,120,500,200)
color("Black")
text(850,125, "Player 1: %d" % Num_1)
text(1050,125, "Player 2: %d" % Num_2)
image(850,155,"animals/Diplodocus.png")
image(1050,180,"animals/Stegosaurus.png")
x = 25
y = 25
color("green")
box(25,25,800,800)
color("black")
for i in range(0,9):
line(x,y,x,(y+800))
x += 100
x = 25
for j in range(0,9):
line(x,y,(x+800),y)
y += 100
for a in range(0,8):
for b in range(0,8):
if Grid[a][b] == 1:
y1 = a
x1 = b
y1 *= 100
y1 += 30
x1 *= 100
x1 += 30
image(x1,y1,"animals/Diplodocus.png")
elif Grid[a][b] == 2:
y1 = a
x1 = b
y1 *= 100
y1 += 55
x1 *= 100
x1 += 35
image(x1,y1,"animals/Stegosaurus.png")
示例5: handle_mousedown
def handle_mousedown(x, y):
global Pturn
Array_X = (x - offset_x) // cell_size # sets xcoord for array from click
Array_Y = (y - offset_y) // cell_size # sets ycoord for array from click
if Array_X >= 7 or Array_X < 0 or Array_Y < 0 or Array_Y >= 7:
return 0 # breaks function if outside of grid without switching
CentreX = (Array_X + 1) * 100 + 75 # finds centre point for dot as below
CentreY = (2 + Array_Y) * 100 + 50
# if (matrix[Array_Y-1][Array_X] != 0):
if Array_Y == 6 or matrix[Array_Y + 1][Array_X] != 0:
if matrix[Array_Y][Array_X] == 0: #!= 1 or matrix[Array_Y][Array_X] != -1:
if Pturn == 1:
print(Array_X)
print(Array_Y)
color("red")
Pturn = -1
else:
print(Array_X)
print(Array_Y)
color("yellow")
Pturn = 1
spot(CentreX - 1, CentreY - 1, 35)
matrix[Array_Y][Array_X] = -Pturn
if checkwin(matrix) == True:
print("Red wins")
# color("red")
image(
125,
200,
"https://photos-2.dropbox.com/t/0/AAADMd5_ZYX1JR1o2m2Wcn-smmLnF1NQCdP_dF0rf8PdUA/12/85596892/png/1024x768/3/1408705200/0/2/RED_WINS.png/2RKVLGw4E8Oh-w3vRAduhboRA1CZEgjUl5W70FAWTdc",
)
elif checkwin(matrix) == False:
print("P2 wins")
image(
125,
200,
"https://photos-3.dropbox.com/t/0/AAAQatRVEnQ5-zZZJKOkmSlPE78GJ3la0QewGPWgaNkBZA/12/85596892/png/1024x768/3/1408705200/0/2/YELLOW_WINS.png/eIEUmrzdj3JywkWfYV6ScacXMdkSRb5PkVLiumDJiDo",
)
return 0
示例6: handle_mousedown
def handle_mousedown(Mx,My, button):
global lastx, lasty, VisibleArray, BombArray, lost, won, NumberUncovered
Mx = Mx - StartingX
My = My - StartingY
if lost == False and won == False:
if button == "left":
if 0 < Mx < SquareSize*WLimit:
if 0 < My < SquareSize*HLimit:
i=Mx/SquareSize
j=My/SquareSize
lastx = i
lasty = j
if VisibleArray[lastx][lasty] == 0:
VisibleArray[lastx][lasty] = 1
NumberUncovered += 1
if BombArray[lastx][lasty] == 0:
FloodBoard(lastx,lasty)
else:
IsBomb(lastx,lasty)
if lost == True:
for x in range(0,HLimit):
for y in range(0,WLimit):
if BombArray[x][y] == -1:
VisibleArray[x][y] = 1
elif HLimit * WLimit - NumberOfBombs == NumberUncovered:
won = True
DrawGrid()
if lost == True:
image(StartingX,StartingY, "http://www.ezimba.com/work/140822C/ezimba16125715215800.png")
elif won == True:
image(StartingX,StartingY,"http://www.ezimba.com/work/140822C/ezimba16125711294800.png")
elif button == "right":
if 0 < Mx < SquareSize*WLimit:
if 0 < My < SquareSize*HLimit:
i=Mx/SquareSize
j=My/SquareSize
lastx = i
lasty = j
if VisibleArray[lastx][lasty] == 0:
VisibleArray[lastx][lasty] = 2
elif VisibleArray[lastx][lasty] == 2:
VisibleArray[lastx][lasty] = 0
DrawGrid()
示例7: draw
def draw(Num_1,Num_2):
if Winner == 3:
image(450,50,"http://i.imgur.com/0zoXV5h.png")
text(450,150, "Player 1: (%d)" % Num_1)
text(450,250, "Player 2: (%d)" % Num_2)
x = 25
y = 25
color("green")
box(25,25,400,400)
color("black")
for i in range(0,9):
line(x,y,x,(y+400))
x += 50
x = 25
for j in range(0,9):
line(x,y,(x+400),y)
y += 50
for a in range(0,8):
for b in range(0,8):
if Grid[a][b] == 1:
y1 = a
x1 = b
y1 *= 125
y1 += 15
y1 /= 2.0
x1 *= 125
x1 += 15
x1 /= 2.0
image(x1,y1,"http://i.imgur.com/Ef7rj15.png")
elif Grid[a][b] == 2:
y1 = a
x1 = b
y1 *= 125
y1 += 15
y1 /= 2.0
x1 *= 125
x1 += 5
x1 /= 2
image(x1,y1,"http://i.imgur.com/mTw75jg.png")
示例8: background
print "This is art mode!"
print screen_width
print screen_height
background("paper.jpg")
line(0,0,screen_width, screen_height)
spot(200,300, 20)
circle(300,200, 20)
box(500, 500, 60, 60)
image(200,200,"bird.png")
line(560,0,560,495)
text(600, 100, "Hello Tealight!")
lastx = None
lasty = None
hue = 0
def handle_mousemove(x,y):
global lastx, lasty, hue
line(lastx or x, lasty or y, x, y)
color("hsl(%d,100%%,50%%)" % hue)
示例9: import
from tealight.art import (color, line, spot, circle, box, image, text, background)
x = 0
y = 150
width = 20
height = 4
for i in range(0,width):
for j in range(0,height):
if 3 - i % 4 == j:
image(x + i * 60, y + j * 60, "misc/YellowFlower.png")
else:
image(x + i * 60, y + j * 60, "misc/Clover.png")
示例10: handle_frame
#.........这里部分代码省略.........
#if track.test_point(player_1.points[0],player_1.points[1]):
car_v = 5
#if track.test_point(player_1.points[0],player_1.points[1]):
#car_x = car_x - 4 * sin(direction+(pi/2))
#car_y = car_y + 4 * cos(direction+(pi/2))
#print "should be working"
elif not track.test_point(player_1.points[4],player_1.points[5]):
if car_v > 0:
car_v = car_v*-0.6
if track.test_point(player_1.points[2],player_1.points[3]):
car_x = car_x - side_bounce * sin(direction)
car_y = car_y + side_bounce * cos(direction)
else:
car_v = 5
#if track.test_point(player_1.points[0],player_1.points[1]):
#if track.test_point(player_1.points[0],player_1.points[1]):
#car_x = car_x - 4 * sin(direction-(pi/2))
#car_y = car_y + 4 * cos(direction-(pi/2))
#print "should be working2"
#############################
# Colisions for second car
if not track.test_point(player_2.points[0],player_2.points[1]):
car_v2 = car_v2*-0.6
car_x2 = car_x2 + -5 * cos(direction2)
car_y2 = car_y2 - -5 * sin(direction2)
if not track.test_point(player_2.points[2],player_2.points[3]):
if car_v2 > 0:
car_v2 = car_v2*-0.6
if track.test_point(player_2.points[2],player_2.points[3]):
car_x2 = car_x2 - side_bounce * sin(direction2)
car_y2 = car_y2 + side_bounce * cos(direction2)
else:
car_v2 = 2
#car_x = car_x - 10 * sin(direction)
#car_y = car_y + 10 * cos(direction)
#print "should be working"
if not track.test_point(player_2.points[4],player_2.points[5]):
if car_v2 > 0:
car_v2 = car_v2*-0.6
if track.test_point(player_2.points[2],player_2.points[3]):
car_x2 = car_x2 - side_bounce * sin(direction2)
car_y2 = car_y2 + side_bounce * cos(direction2)
else:
car_v2 = 2
#car_x = car_x - 10 * sin(direction)
#car_y = car_y + 10 * cos(direction)
#print "should be working2"
##########
# Physics
#car1
if car_v > 0:
car_v -= friction
else:
car_v += friction
car_v = min(car_v + car_a,10)
car_x = car_x + car_v * cos(direction)
car_y = car_y - car_v * sin(direction)
direction = direction + spin*min(1,car_v/5)
#car2
if car_v2 > 0:
car_v2 -= friction
else:
car_v2 += friction
car_v2 = min(car_v2 + car_a2,10)
car_x2 = car_x2 + car_v2 * cos(direction2)
car_y2 = car_y2 - car_v2 * sin(direction2)
direction2 = direction2 + spin2*min(1,car_v2/5)
################
# Drawing bits
################
color("black")
track.draw_polygons()
player_1.move(car_x,car_y,direction)
player_2.move(car_x2,car_y2,direction2)
if player_won == 1:
image(screen_width/2 - 320,screen_height/2 - 200,"http://i.imgur.com/OQ5AJok.png")
if player_won == 2:
image(screen_width/2 - 320,screen_height/2 - 200,"http://i.imgur.com/Bzd2sgV.png")
示例11: check_winner
#.........这里部分代码省略.........
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row=0
col=0
for i in range (0,5):
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==1:
winnerRed = 1
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row=1
col=0
for i in range (0,4):
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==1:
winnerRed = 1
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row=2
col=0
for i in range (0,3):
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==1:
winnerRed = 1
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row=3
col=0
for i in range (0,2):
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==1:
winnerRed = 1
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row=4
col=0
for i in range (0,1):
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==1:
winnerRed = 1
if boardArray [row][col] ==boardArray [row+1][col+1]==boardArray [row+2][col+2]==boardArray [row+3][col+3]==2:
winnerYellow = 1
row = row + 1
row = 0
col = 0
#2declaration
if winnerRed == 1:
print 'Red is the winner'
color("red")
spot(445,500,150)
color("black")
text(390,480,"Red Wins!!!")
image(310,490,"misc/WhiteBalloon.png")
image(325,400,"misc/BlackBalloon.png")
image(375,360,"misc/BlueBalloon.png")
image(450,360,"misc/GreenBalloon.png")
image(375,540,"misc/OrangeBalloon.png")
image(450,540,"misc/PinkBalloon.png")
image(510,400,"misc/RedBalloon.png")
image(510,510,"misc/YellowBalloon.png")
return "red"
if winnerYellow == 1:
print 'Yellow is the winner'
color("yellow")
spot(445,500,150)
color("black")
text(390,480,"Yellow Wins!!!")
image(310,490,"misc/WhiteBalloon.png")
image(325,400,"misc/BlackBalloon.png")
image(375,360,"misc/BlueBalloon.png")
image(450,360,"misc/GreenBalloon.png")
image(375,540,"misc/OrangeBalloon.png")
image(450,540,"misc/PinkBalloon.png")
image(510,400,"misc/RedBalloon.png")
image(510,510,"misc/YellowBalloon.png")
return "yellow"
return None
示例12: import
from tealight.art import (color, line, spot, circle, box, image, text, background)
x = 0
y = 150
width = 20
height = 8
for i in range(0,width):
for j in range(0,height):
if (i-j) % 4 == 0:
image(x + i * 60, y + j * 60, "misc/Bomb.png")
else:
image(x + i * 60, y + j * 60, "misc/Clover.png")
示例13: import
from tealight.art import (color, line, spot, circle, box, image, text, background)
import random
from random import shuffle
x = range(24) + range(24)
shuffle(x)
print x
i = random.randrange(500)
j = random.randrange(500)
image(i, j, "animals/Ant.png")
image(j, i, "animals/Horse.png")
image(i, 200, "animals/Fish1.png")
image(50, j, "animals/Lion.png")
示例14: import
from tealight.art import (color, line, spot, circle, box, image, text, background)
x = 40
y = 100
width = 10
height = 8
for i in range(0,width):
for j in range(0,height):
if (i-j) % 4 == 0:
image(x + i * 60, y + j * 60, "misc/Sword.png")
else:
image(x + i * 60, y + j * 60, "misc/PirateFlag.png")
示例15: FloodBoard
FloodBoard(i,j)
NumberOfBombs = 1
HLimit = 20
WLimit = HLimit
SquareSize = 500/HLimit
StartingX = screen_width /2 - SquareSize * WLimit/2
StartingY = 280
OffsetX = 0
OffsetY = 0
lastx = 0
lasty = 0
lost = False
won = False
NumberUncovered = 0
image(StartingX,50,"http://www.ezimba.com/work/140822C/ezimba16125732408300.png")
image(screen_width/2 - 1000,screen_height -347,"http://i.imgur.com/ofNb09J.png")
BombArray = [[0 for x in range(0,HLimit)] for y in range(0,WLimit)]
VisibleArray = [[0 for x in range(0,HLimit)] for y in range(0,WLimit)]
PlaceBombs(NumberOfBombs)
DrawGrid()
#===================================BUTTONS===================================#
def drawbuttons(HLimit):
color=gold
box(100,250,50,50)
drawbuttons():