コード例 #1
0
ファイル: Project.py プロジェクト: jackm110/tealight-files
def DrawClear(x,y):
  color("white")
  box(x*34+182,y*34+202,32,32)
  color("Black")
  if check(x,y) > 0:
    text(x*34+192,y*34+207,check(x,y))
    flags[x][y] = 3
コード例 #2
0
ファイル: points.py プロジェクト: willg-c/tealight-files
def doSecond(): 
  global points
  points = points-1
  color("white")
  box(0,0,100,100)
  color("black")
  text(0,0,points)
コード例 #3
0
ファイル: Minesweeper.py プロジェクト: AimeeH/tealight-files
def flag(i,j):
  color("red")
  tx = startx + size/2 + i * size
  ty = starty + size/2 + j * size
  spot(tx, ty, size/3)
  color("black")
  text(tx - size/10, ty - size/10, "F")
コード例 #4
0
ファイル: 2DArray.py プロジェクト: pb471/tealight-files
  def draw_debug(self, position = [30, 30], size = [200,200]):
    for i in range(0, self.i_size):
      for j in range(0, self.j_size):
        #Set rgba value based on max value

        
        #Convert to color string "rgba(...)
        #Positive values are red, negative are blue
        #Values close to zero will be paler
        if self.array[i][j] >= 0 :
          colour = "red"
        else:
          colour = "blue"
        
        #Draw box
        color(colour)
        box(position[0] + j * size[0]/self.j_size,
            position[1] + i * size[1]/self.i_size,
            size[0]/self.j_size - 1,
            size[1]/self.i_size - 1)
        
        #Draw text
        color("white")
        text(position[0] + j * size[0]/self.j_size,
            position[1] + i * size[1]/self.i_size,
            str(i) + str(j) + " " + str(self.array[i][j]))
コード例 #5
0
ファイル: palette.py プロジェクト: jawadadnan0/tealight-files
def initialPlayer1():
    reset()
    drawToolbar()
    text(10, 10, "Colour Palette:")
    for i in range(0, 8):
        color(palette[i])
        box((i * 25 + 10), 35, 25, 25)
コード例 #6
0
def DrawNumber(x,y,NumberOfMines):
  global BombArray
  
  if BombArray[x][y] == 1:
    color("blue")
  elif BombArray[x][y] == 2:
    color("green")
  elif BombArray[x][y] == 3:
    color("red")
  elif BombArray[x][y] == 4:
    color("purple")
  elif BombArray[x][y] == 5:
    color("#940023")
  elif BombArray[x][y] == 6:
    color("black")
  elif BombArray[x][y] == 7:
    color("#878787")
  elif BombArray[x][y] == 8:
    color("#00C19B")

  size = SquareSize /2
  fontsize = str(size)+"px Courier New Bold"
  font(fontsize)
  x += 0.125
  text(StartingX + SquareSize * x +size/2,StartingY + SquareSize * y +size/2, NumberOfMines)
コード例 #7
0
ファイル: timer.py プロジェクト: jawadadnan0/tealight-files
def doSecond(): 
  global points
  points = points - 1
  color("white")
  box(0,screen_height - 100, 100, 100)
  color("black")
  if points < 0:
    points = 0
  text(10,screen_height - 30, ("Points: " + str(points)))
コード例 #8
0
ファイル: Ising1.py プロジェクト: pb471/tealight-files
def print_params(P):
  color("black")
  t = ["a", "b", "c"]
  t[0] = str(P.J)
  t[1] = str(P.T)
  t[2] = str(P.B)
  
  for i in range(0,3):
    text(690, 50 + (i+1) * 20, t[i])
コード例 #9
0
ファイル: correct.py プロジェクト: amyble/tealight-files
def stopButton():
  global stopMinY,stopMaxY,stopMinX,stopMaxX
  color("red")
  rectangle((screen_width - 180), screen_height - 40, 150,30)
  text(screen_width - 85, screen_height - 35, "STOP")
  stopMinX = (screen_width - 180)
  stopMaxX = (screen_width - 30)
  stopMinY = (screen_height - 40)
  stopMaxY = (screen_height - 10)
  print stopMinX
コード例 #10
0
ファイル: correct.py プロジェクト: amyble/tealight-files
def stopButton():
    global stopMinY, stopMaxY, stopMinX, stopMaxX
    color("red")
    rectangle((screen_width - 180), screen_height - 40, 150, 30)
    text(screen_width - 85, screen_height - 35, "STOP")
    stopMinX = (screen_width - 180)
    stopMaxX = (screen_width - 30)
    stopMinY = (screen_height - 40)
    stopMaxY = (screen_height - 10)
    print stopMinX
コード例 #11
0
def getSurroundingMines(x, y):
    surround = 0
    global mine
    for i in range(-1, 2):
        for j in range(-1, 2):
            if get(mine, x + i, y + j) == 1:
                surround = surround + 1
    color('black')
    if surround > 0:
        text(x * 60 + 17, y * 60 + 20, surround)
    return surround
コード例 #12
0
ファイル: Minesweeper.py プロジェクト: NayfS/tealight-files
def getSurroundingMines(x, y):
  surround = 0
  global mine
  for i in range(-1,2):
    for j in range(-1, 2):
      if get(mine, x+i, y+j) ==1:
        surround=surround+1
  color('black')
  if surround>0:
    text(x*60 + 17, y*60 + 20 , surround)
  return surround
コード例 #13
0
def drawGrid():
  font("100px arial")
  text(250,55, "Connect 4")

  color("blue")
  box(offset_x,offset_y,700,700)

  
  x=offset_x + 49
  y=offset_y +49

  for i in range(0,7):
    for j in range(0,7):
      color("white")
      spot(x+i*100,y+j*100,35)
  color("black")
コード例 #14
0
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")
コード例 #15
0
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")
コード例 #16
0
def reveal(i, j):
    global flags
    global uncovered
    if flags[i][j]:
        return
    if mines[i][j] == -1:
        defeat()
    tx = xstart + size / 10 + i * size
    ty = ystart + size / 10 + j * size
    color("white")
    box(tx, ty, size / 10 * 8, size / 10 * 8)
    color("black")
    text(tx + size / 10 * 3, ty + size / 10 * 3, mines[i][j])
    uncovered += 1
    flags[i][j] = 2
    if mines[i][j] == 0:
        for offx in range(-1, 2):
            for offy in range(-1, 2):
                if i + offx >= 0 and i + offx <= 9 and j + offy >= 0 and j + offy <= 9:
                    reveal(i + offx, j + offy)
コード例 #17
0
ファイル: racecar.py プロジェクト: Krimzar/tealight-files
  def draw_car(self, Name):
    
    RandomNumber = randint(1, 3)
    #Generate a random number between 1 and 3
    
    
    if RandomNumber == 1:
      color("red") #Random number 1 = set red
      
    elif RandomNumber == 2:
      color("green") #Random number 2 = set green
    
    elif RandomNumber == 3:
      color("blue") #Random number 3 = set blue
    
    text(self.CoordD["x"]-15, self.CoordD["y"]-35, self.Name)
    #Sets the name of the car to a string parameter passed to the method
 
    line(self.CoordA["x"], self.CoordA["y"], self.CoordB["x"], self.CoordB["y"])
    line(self.CoordA["x"], self.CoordA["y"], self.CoordD["x"], self.CoordD["y"])
    line(self.CoordB["x"], self.CoordB["y"], self.CoordD["x"], self.CoordD["y"])
    line(self.CoordA["x"], self.CoordA["y"], self.CoordC["x"], self.CoordC["y"])
    line(self.CoordB["x"], self.CoordB["y"], self.CoordC["x"], self.CoordC["y"])
    line(self.CoordD["x"], self.CoordD["y"], self.CoordC["x"], self.CoordC["y"])
コード例 #18
0
ファイル: palette.py プロジェクト: jawadadnan0/tealight-files
def finishButtons():
    global fbShown, chosen_color, p2cMinX, p2cMaxX, p2cMinY, p2cMaxY, p2wMinX, p2wMaxX, p2wMinY, p2wMaxY, p3cMinX, p3cMaxX, p3cMinY, p3cMaxY, p3wMinX, p3wMaxX, p3wMinY, p3wMaxY
    color("green")

    #P2 Correct
    rectangle((screen_width / 2) - 75, screen_height / 2, 150, 30)
    text((screen_width / 2) - 45, ((screen_height / 2) + 5), "P2 Correct")
    #P3 Correct
    rectangle((screen_width / 2) - 75, ((screen_height / 2) + 40), 150, 30)
    text((screen_width / 2) - 45, ((screen_height / 2) + 45), "P3 Correct")

    color("red")
    #P2 Wrong
    rectangle((screen_width / 2) + 95, screen_height / 2, 150, 30)
    text((screen_width / 2) + 125, ((screen_height / 2) + 5), "P2 Wrong")
    #P3 Wrong
    rectangle((screen_width / 2) + 95, ((screen_height / 2) + 40), 150, 30)
    text((screen_width / 2) + 125, ((screen_height / 2) + 45), "P3 Wrong")

    p2cMinX = ((screen_width / 2) - 75)
    p2cMaxX = ((screen_width / 2) + 75)
    p2cMinY = (screen_height / 2)
    p2cMaxY = (screen_height / 2) + 30

    p2wMinX = ((screen_width / 2) + 95)
    p2wMaxX = ((screen_width / 2) + 245)
    p2wMinY = (screen_height / 2)
    p2wMaxY = ((screen_height / 2) + 30)

    p3cMinX = ((screen_width / 2) - 75)
    p3cMaxX = ((screen_width / 2) + 175)
    p3cMinY = ((screen_height / 2) + 40)
    p3cMaxY = ((screen_width / 2) + 70)

    p3wMinX = ((screen_width / 2) + 95)
    p3wMaxX = ((screen_width / 2) + 245)
    p3wMinY = ((screen_width / 2) + 40)
    p3wMaxY = ((screen_width / 2) + 70)
    fbShown = "true"
コード例 #19
0
ファイル: correct.py プロジェクト: amyble/tealight-files
def finishButtons():
  global p2cMinX,p2cMaxX,p2cMinY,p2cMaxY, p2wMinX, p2wMaxX, p2wMinY, p2wMaxY, p3cMinX, p3cMaxX, p3cMinY, p3cMaxY, p3wMinX, p3wMaxX, p3wMinY, p3wMaxY
  color("green")
  #P2 Correct
  rectangle((screen_width / 2) - 75, screen_height / 2, 150,30)
  text((screen_width / 2) - 45, ((screen_height / 2) + 5), "P2 Correct")
  #P3 Correct
  rectangle((screen_width / 2) - 75, ((screen_height / 2) + 40), 150,30)
  text((screen_width / 2) - 45, ((screen_height / 2) + 45), "P3 Correct")
  
  color("red")
  #P2 Wrong
  rectangle((screen_width / 2) + 95, screen_height / 2, 150,30)
  text((screen_width / 2) + 125, ((screen_height / 2) + 5), "P2 Wrong")
  #P3 Wrong
  rectangle((screen_width / 2) + 95, ((screen_height / 2) + 40), 150,30)
  text((screen_width / 2) + 125, ((screen_height / 2) + 45), "P3 Wrong")
  
  p2cMinX = ((screen_width / 2) - 75)
  p2cMaxX = ((screen_width / 2) + 75)
  p2cMinY = (screen_height / 2)
  p2cMaxY = (screen_height / 2) + 30
  
  p2wMinX = ((screen_width / 2) + 95)
  p2wMaxX = ((screen_width / 2) + 245)
  p2wMinY = (screen_height / 2)
  p2wMaxY = ((screen_height / 2) + 30)
  
  p3cMinX = ((screen_width / 2) - 75)
  p3cMaxX = ((screen_width / 2) + 175) 
  p3cMinY = ((screen_height / 2) + 40)
  p3cMaxY = ((screen_width / 2) + 70)
  
  p3wMinX = ((screen_width / 2) + 95)
  p3wMaxX = ((screen_width / 2) + 245) 
  p3wMinY = ((screen_width / 2) + 40)
  p3wMaxY = ((screen_width / 2) + 70)
コード例 #20
0
ファイル: Project.py プロジェクト: jackm110/tealight-files
def handle_mousedown(x,y,button):
  global EndGame
  global flags
  global score
  positionx = (x - 184)/34
  print positionx
  positiony = (y - 204)/34
  print positiony
  if positionx < 0 or positionx > 15:
    return
  if positiony < 0 or positiony > 15:
    return
  if EndGame == False:
    if button == "left" and flags[positionx][positiony] != 1:
      if m[positionx][positiony] == 0:
        DrawClear(positionx,positiony)
        score = score + 1
        color("black")
        box(625,155,100,28)
        color("white")
        text(630,160,"score")
        
        text(700,160,score)
      elif m[positionx][positiony] == 1:
        DrawBomb(positionx,positiony)
        EndGame = True
        color("black")
        box(370,435,166,54)
        color("red")
        box(372,437,162,50)
        color("white")
        text(377,450, "YOU ARE DEAD")
    elif button == "right" and flags[positionx][positiony] != 3:
      if flags[positionx][positiony] == 1:
        color("grey")
        box(positionx*34+182,positiony*34+202,32,32)
        flags[positionx][positiony] = 0
      elif flags[positionx][positiony] == 0:
        DrawFlag(positionx,positiony)
        flags[positionx][positiony] = 1
コード例 #21
0
def check_winner(boardArray):
  global winnerRed, winnerYellow
  
  winnerRed=0
  winnerYellow=0

  #1winnerchecker
  row = 0
  col = 0
  
  
  
  #2verticals
  for i in range (0,5):
    for i in range (0,8):
      if boardArray [row][col] ==boardArray [row +1][col]==boardArray [row +2][col]==boardArray [row+3][col]==1:
        winnerRed = 1
  
      if boardArray [row][col] ==boardArray [row +1][col]==boardArray [row +2][col]==boardArray [row+3][col]==2:
        winnerYellow = 1
      col = col + 1
    col=0
    row = row+1
  
  row = 0
  col = 0
  
  #2horizontals
  for i in range (0,5):
    for i in range (0,8):
      if boardArray [row][col] ==boardArray [row][col+1]==boardArray [row][col+2]==boardArray [row][col+3]==1:
        winnerRed = 1
  
      if boardArray [row][col] ==boardArray [row][col+1]==boardArray [row][col+2]==boardArray [row][col+3]==2:
        winnerYellow = 1
      row = row + 1
    row=0
    col=col+1
  
  row = 0
  col = 0
  
  #2diagonals positive
  
  row=3
  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=4	
  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=5	
  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=6	
  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=7	
  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=3	
  col=1
  
  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=4	
  col=1
  
  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=5	
  col=1
  
  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=6	
  col=1
  
  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=7	
  col=1
  
  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=3	
  col=2
  
  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=4	
  col=2
  
  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=5	
  col=2
  
  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=6	
  col=2
  
  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=7	
  col=2
  
  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=3	
  col=3
  
  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=4	
  col=3
  
  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=5	
  col=3
  
  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=6	
  col=3
  
  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=7	
  col=3
  
  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=3	
  col=4
  
  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=4	
  col=4
  
  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=5	
  col=4
  
  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=6	
  col=4
  
  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=7	
  col=4
  
  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
  
  #2diag neg
  
  row=0
  col=4
  
  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=4
  
  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=4
  
  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=4
  
  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=4
  
  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=3
  
  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=3
  
  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=3
  
  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=3
  
  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=3
  
  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=2
  
  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=2
  
  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=2
  
  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=2
  
  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=2
  
  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=1
  
  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=1
  
  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=1
  
  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=1
  
  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=1
  
  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
  
  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
コード例 #22
0
ファイル: racetrack.py プロジェクト: c-ryan747/tealight-files
def handle_frame():
  global time, friction, car_x, car_y, car_v, car_a, direction, lap1, car_x2, car_y2, car_v2, car_a2, direction2, lap2, player_won
  
  # refreshes screen
  color("rgba(255,255,255,0.1)")
  
  
  box(0,screen_height/10,screen_width,screen_height/10*9)
  
  # Does time
  if lap1 < 4:
    time = time + 0.04
  color( "rgba(150,150,150,0.7)")
  box(0,0,screen_width,screen_height/10)
  color("blue")
  #text(40,20,str(math.ceil(time)))
  text(180,20,"Polygon Racers!")
  text(20,50,"arrow keys lap: " + str(math.floor(lap1))[0]+"/4")
  text(280,50,"wasd keys lap: " + str(math.floor(lap2))[0]+"/4")
  # Does laps for player 1
  if track.test_in_top_detector(player_1.points[0],player_1.points[1]) == True:
    if ((lap1-0.5) % 1) == 0:
      lap1 = lap1 + 0.5
      if lap1 == 4.0 and lap2 < 4:
        player_won = 1
  if track.test_in_bottom_detector(player_1.points[0],player_1.points[1]) == True:
    if (lap1 % 1) == 0:
      lap1 = lap1 + 0.5
   
  # Does laps for player 2
  if track.test_in_top_detector(player_2.points[0],player_2.points[1]) == True:
    if ((lap2-0.5) % 1) == 0:
      lap2 = lap2 + 0.5
      if lap2 == 4.0 and lap1 < 4:
        player_won = 2
  if track.test_in_bottom_detector(player_2.points[0],player_2.points[1]) == True:
    if (lap2 % 1) == 0:
      lap2 = lap2 + 0.5   
  
  
  ################################
  # Collisions with the polygons
  ################################
  
  if not track.test_point(player_1.points[0],player_1.points[1]):
    car_v = car_v*-0.6
    car_x = car_x + -5 * cos(direction)
    car_y = car_y - -5 * sin(direction)
    
  if not track.test_point(player_1.points[2],player_1.points[3]):
    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:
      #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")
コード例 #23
0
ファイル: word.py プロジェクト: amyble/tealight-files
def word():
    a = [
        "Dog", "Cat", "Castle", "Voldemort", "Barack Obama", "Snowman",
        "Aeroplane", "Apple", "Bible", "Chocolates", "Electricity"
    ]
    text(screen_width / 2, screen_height / 2, random.choice(a))
コード例 #24
0
def Num_of_Values():
 global Winner
 Num_0 = 0
 Num_1 = 0
 Num_2 = 0
 for a in range(0,8):
  for b in range(0,8):
   c = Grid[a][b]
   if c == 0:
    Num_0 += 1
   elif c == 1:
    Num_1 += 1
   elif c == 2:
    Num_2 += 1
 
 
 if Num_0 == 0:
  if Num_1 > Num_2:
   Winner = 1
  elif Num_1 == Num_2:
   Winner = 0
  elif Num_2 > Num_1:
   Winner = 2
  
  
  if Winner == 1 or Winner == 2:
   color("White")
   box(26,26,399,399)
   color("Red")
   text(75,195,"Game over. The winner was player (%d)" % Winner)
   text(75,215,"To restart, run again.")
  else:
   color("White")
   box(26,26,399,399)
   color("Red")
   text(75,195,"Game over. Both players got the same score.")
   text(75,215,"To restart, run again.")
  return
 elif Num_1 == 0:
  color("White")
  box(26,26,399,399)
  color("Red")
  text(75,195,"Game over. The winner was player 2.")
  text(75,215,"To restart, run again.")
  return
 elif Num_2 == 0:
  color("White")
  box(26,26,399,399)
  color("Red")
  text(75,195,"Game over. The winner was player 1.")
  text(75,215,"To restart, run again.")
コード例 #25
0
ファイル: Project.py プロジェクト: jackm110/tealight-files
from tealight.art import (color, line, spot, circle, box, image, text, background)
from github.princz.art.project import *

EndGame = False  
score = 0
color("white")
text(630,160,"score 0")
#---Grid-----------------------------------------
color("black")
box(0,0,1000,1200)

color("grey")
box(178,198,550,550)

color("white")
box(180,200,546,546)

color("red")
box(138,140,630,3)

color("red")
box(138,145,630,3)

color("red")
box(138,185,630,3)

color("red")
box(138,190,630,3)

color("red")
box(138,750,630,3)
コード例 #26
0
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)
  
  hue += 1
  
  lastx = x
  lasty = y
コード例 #27
0
ファイル: toolbar.py プロジェクト: amyble/tealight-files
def drawToolbar():
  tools = ["line","bold","circle","bird","stars","italics","triangle","hearts","eraser"]

  text (screen_width - 300, 10, "Toolbar:")
  rectangle(screen_width - 300,35,25,25)
  line(screen_width - 286, 40, screen_width - 286, 52)
  rectangle(screen_width - 275,35,25,25)
  box (screen_width - 264, 37, 5, 20)
  rectangle(screen_width - 250,35,25,25)
  spot (screen_width - 238, 47, 8)
  rectangle(screen_width - 225,35,25,25)
  text(screen_width - 219, 38, "B")
  rectangle(screen_width - 200,35,25,25)
  text(screen_width - 193, 38, "*")
  rectangle(screen_width - 175,35,25,25)
  text(screen_width - 165, 38, "/")
  rectangle(screen_width - 150,35,25,25)
  text(screen_width - 145, 38, "T")
  rectangle(screen_width - 125,35,25,25) 
  text(screen_width - 120, 38, "H")
  rectangle(screen_width - 100,35,25,25) 
  text(screen_width - 95, 38, "X")
コード例 #28
0
ファイル: Minesweeper.py プロジェクト: AimeeH/tealight-files
def welcome():
  color("black")
  text(startx, starty+size*10+20, "Welcome to Mineswepper!")
  text(startx, starty+size*10+50, "- Left click to play, right click to flag/unflag a cell.")
コード例 #29
0
import random
from random import randrange
from math import floor
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)
score = 0
ingame = 1
color('white')
box(0, 0, 1000, 1000)
color("black")
text(0, 600, "Score: " + str(score))


#this makes the grid
def makegrid():
    for j in range(0, 10):
        for i in range(0, 10):
            if ((i + j) % 2) != 1:
                color("black")
            else:
                color("blue")
            box(i * 60, j * 60, 50, 50)


#this gets the information about a box from the corresponding list
def get(A, x, y):
    position = (11 * (y)) + x
    return A[position]


#this sets the information about a box to the corresponding lis
コード例 #30
0
ファイル: Minesweeper.py プロジェクト: NayfS/tealight-files
def uncover(boxX, boxY):
  global score
  global ingame
  global mine
  print boxY, boxX
  print get(mine, boxX, boxY)
  if get(mine, boxX, boxY)==1:
    color('red')
    box(boxX*60,boxY*60,50,50)
    ingame=0
    color("white")
    box(0,600,500,50)
    color("black")
    text(0, 600,"Final score: "+str(score))
    text(500,600, "You Lost!")
    findMines()
  if get(mine, boxX, boxY)==0:
    color('white')
    box(boxX*60,boxY*60,50,50)
    setbox(mine,boxX,boxY,2)
    end =  getSurroundingMines(boxX,boxY)
    score = getscore()
    color("white")
    box(0,600,500,50)
    color("black")
    text(0, 600,"Score: "+str(score))
    if score==85:
      score = 100
      ingame=0
      color("white")
      box(0,600,500,50)
      color("black")
      text(0, 600,"Final score: "+str(score))
      text(500,600, "You WIN!")
    if end == 0:
      if boxX<9:
        if boxY<9:
          if boxX>0:
            if boxY>0:
              uncover(boxX +1, boxY)
              uncover(boxX -1, boxY)
              uncover(boxX, boxY +1)
              uncover(boxX, boxY -1)
      if boxX<9:
        if boxY==9:
          if boxX>0:
            uncover(boxX +1, boxY)
            uncover(boxX -1, boxY)
            uncover(boxX, boxY -1)
      if boxX<9:
        if boxY==0:
          if boxX>0:
            uncover(boxX +1, boxY)
            uncover(boxX -1, boxY)
            uncover(boxX, boxY +1)
      if boxY<9:
        if boxX==9:
          if boxY>0:
            uncover(boxX +1, boxY)
            uncover(boxX -1, boxY)
            uncover(boxX, boxY -1)
      if boxY<9:
        if boxX==0:
          if boxY>0:
            uncover(boxX, boxY +1)
            uncover(boxX, boxY -1)
            uncover(boxX +1, boxY)
      if boxX == 0:
        if boxY == 9:
          uncover(boxX, boxY -1)
          uncover(boxX +1, boxY)
      if boxX == 9:
        if boxY == 0:
          uncover(boxX, boxY +1)
          uncover(boxX -1, boxY)
      if boxX == 0:
        if boxY == 0:
          uncover(boxX, boxY +1)
          uncover(boxX +1, boxY)
      if boxX == 9:
        if boxY == 9:
          uncover(boxX, boxY -1)
          uncover(boxX -1, boxY)
コード例 #31
0
def handle_frame():
  global balls, sr, sb, gameend, e3, redcount, bluecount, hippo1, hippo2, hippo3, hippo4
  if gameend==0:
    
    sleep(20)
    color("white")
    box(0,0,screen_width,screen_height)
    color("black")
    circle(screen_width/2,screen_height/2,domain+radius)
    color("rgba(255,0,0,1)")
    circle(screen_width/2-domain/2,screen_height/2,hipporadius)
    color("rgba(255,0,255,1)")
    circle(screen_width/2,screen_height/2-domain/2,hipporadius)
    color("rgba(255,100,0,1)")
    circle(screen_width/2,screen_height/2+domain/2,hipporadius)
    color("rgba(0,0,255,1)")
    circle(screen_width/2+domain/2,screen_height/2,hipporadius)
    
    for ball in balls:
      #a[d*i+8]=-a[d*i]/1000
      #a[d*i+9]=-a[d*i+1]/1000
      ball.position = ball.position + ball.velocity
    
      
      # TODO: Acceleration
      #a1=a[d*i]-screen_width/2
      #a2=a[d*i+1]-screen_height/2
      #aa=sqrt(a1*a1+a2*a2)
      #a[d*i+8]=-mu*a[d*i+2]-g*a1/aa
      #a[d*i+9]=-mu*a[d*i+3]-g*a2/aa
      #if a[d*i]<screen_width:
      #  a[d*i+2]=a[d*i+2]*1+a[d*i+8]
      #  a[d*i+3]=a[d*i+3]*1+a[d*i+9]
     
    
    
    for i in range (0,len(balls)):
      for j in range (i+1,len(balls)):
        
        normal = balls[i].position - balls[j].position
        
        nn=normal.mod()
        
        if nn<2*radius:
          if nn !=0:
            
            # rotate so colission along x
            tangent=Vector(-normal.y,normal.x)
            
            v3 = Vector(normal * balls[i].velocity,
                        tangent * balls[i].velocity)
            v4 = Vector(normal * balls[j].velocity,
                        tangent * balls[j].velocity)
            
            
            
            v5x=0.5*((1-e)*v3.x+(1+e)*v4.x)
            v6x=0.5*((1-e)*v4.x+(1+e)*v3.x)
            
            balls[i].velocity = \
                  Vector((normal.x*v5x-normal.y*v3.y)/nn**2,
                         (normal.y*v5x+normal.x*v3.y)/nn**2)
            balls[j].velocity = \
                  Vector((normal.x*v6x-normal.y*v4.y)/nn**2,
                         (normal.y*v6x+normal.x*v4.y)/nn**2)
           
            
             
            
            balls[i].position += normal.scale((2*radius-nn) / (2 * nn))
            balls[j].position += normal.scale(-(2*radius-nn) / (2 * nn))
            
            
      
              
      #if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)>domain*domain and a[d*i]<screen_width:
        #print(i)
      #  n1=-(a[d*i]-screen_width/2)
      #  n2=-(a[d*i+1]-screen_height/2)
      #  v1x=a[d*i+2]
      #  v1y=a[d*i+3]
      #  nn=n1*n1+n2*n2
      #  a[d*i+2]=((n2*n2-e2*n1*n1)*v1x-(1+e2)*n1*n2*v1y)/nn
      #  a[d*i+3]=(-(1+e2)*n1*n2*v1x+(n1*n1-e2*n2*n2)*v1y)/nn
      #  a[d*i]=a[d*i]+(1-domain+sqrt(nn))*n1/sqrt(nn)
      #  a[d*i+1]=a[d*i+1]+(1-domain+sqrt(nn))*n2/sqrt(nn)
      
      
      
      #hcx=a[d*i]-screen_width/2+domain/2
      #hcy=a[d*i+1]-screen_height/2
      #if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo1>1:
      #  print(i)
      #  a[d*i+2]=nom*a[d*i+2]
      #  a[d*i+3]=nom*a[d*i+3]
        
      #if hippo1>1:
      #  hippo1=hippo1-1
      #if hippo2==2:
      #  hippo2=1
      #if hippo3==2:
      #  hippo3=1
      #if hippo4==2:
      #  hippo4=1
      #if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo1>0:
      #  n1=hcx
      #  n2=hcy
      #  nn=n1*n1+n2*n2
      #  v1x=a[d*i+2]
      #  v1y=a[d*i+3]
      #  a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
      #  a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
      #  a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
      #  a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      #if (a[d*i]-screen_width/2+domain/2)*(a[d*i]-screen_width/2+domain/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)<hipporadius*hipporadius and hippo1==1:
      #  a[d*i]=screen_width+100
      #  a[d*i+1]=screen_height+100
      #  a[d*i+2]=0
      #  a[d*i+3]=0
      #  team=int(i/n)
      #  if team==0:
      #    sr=sr-1
      #    bluecount=bluecount-1
      #  elif team==1:
      #    sr=sr-1
      #    bluecount=bluecount-1
      #  elif team==2:
      #    sr=sr+3
      #    redcount=redcount-1
      #  elif team==3:
      #    sr=sr-1
      #    redcount=redcount-1
      #  elif team==4:
      #    sr=-100
      #    gameend=1
      #    print("Blue team wins!")
      #hcx=a[d*i]-screen_width/2
      #hcy=a[d*i+1]-screen_height/2+domain/2
      #if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo2==1:
      #  n1=hcx
      #  n2=hcy
      #  nn=n1*n1+n2*n2
      #  v1x=a[d*i+2]
      #  v1y=a[d*i+3]
      #  a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
      #  a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
      #  a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
      #  a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      #if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2+domain/2)*(a[d*i+1]-screen_height/2+domain/2)<hipporadius*hipporadius and hippo2==1:
      #  a[d*i]=1000000
      #  a[d*i+1]=1000000
      #  a[d*i+2]=0
      #  a[d*i+3]=0
      #  team=int(i/n)
      #  if team==0:
      #    sr=sr
      #    bluecount=bluecount-1
      #  elif team==1:
      #    sb=sb+1
      #    bluecount=bluecount-1
      #  elif team==2:
      #    sr=sr
      #    redcount=redcount-1
      #  elif team==3:
      #    sr=sr
      #    redcount=redcount-1
      #  elif team==4:
      #    sb=-100
      #    gameend=1
      #    print("Red team wins!")
      #    
      #hcx=a[d*i]-screen_width/2
      #hcy=a[d*i+1]-screen_height/2-domain/2
      #if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo3==1:
      #  n1=hcx
      #  n2=hcy
      #  nn=n1*n1+n2*n2
      #  v1x=a[d*i+2]
      #  v1y=a[d*i+3]
      #  a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
      #  a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
      #  a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
      #  a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      #if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2-domain/2)*(a[d*i+1]-screen_height/2-domain/2)<hipporadius*hipporadius and hippo3==1:
      #  a[d*i]=1000000
      #  a[d*i+1]=1000000
      #  a[d*i+2]=0
      #  a[d*i+3]=0
      #  team=int(i/n)
      #  if team==0:
      #    sr=sr
      #    bluecount=bluecount-1
      #  elif team==1:
      #    sr=sr
      #    bluecount=bluecount-1
      #  elif team==2:
      #    sr=sr
      #    redcount=redcount-1
      #  elif team==3:
      #    sr=sr+1
      #    redcount=redcount-1
      #  elif team==4:
      #    sr=-100
      #    gameend=1
      #    print("Blue team wins!")
      #hcx=a[d*i]-screen_width/2-domain/2
      #hcy=a[d*i+1]-screen_height/2
      #if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo4==1:
      #  n1=hcx
      #  n2=hcy
      #  nn=n1*n1+n2*n2
      #  v1x=a[d*i+2]
      #  v1y=a[d*i+3]
      #  a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
      #  a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
      #  a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
      #  a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      #  
      #if (a[d*i]-screen_width/2-domain/2)*(a[d*i]-screen_width/2-domain/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)<hipporadius*hipporadius and hippo4==1:
      #  a[d*i]=1000000
      #  a[d*i+1]=1000000
      #  a[d*i+2]=0
      #  a[d*i+3]=0
      #  team=int(i/n)
      #  if team==0:
      #    sb=sb+3
      #    bluecount=bluecount-1
      #  elif team==1:
      #    sb=sb-1
      #    bluecount=bluecount-1
      #  elif team==2:
      #    sb=sb-1
      #    redcount=redcount-1
      #  elif team==3:
      #    sb=sb-1
      #    redcount=redcount-1
      #  elif team==4:
      #    sb=-100
      #    gameend=1
      #    print("Red team wins!")
    for i, ball in enumerate(balls):
      color(ctorgba(ball.colour))
      spot(ball.position.x, ball.position.y, radius)
    if i==4*n:
      color("white")
      text(ball.position.x-3, ball.position.y-12,"!")
    if hippo1==1:
      color("rgba(255,0,0,1)")
      spot(screen_width/2-domain/2,screen_height/2,hipporadius)
      color("white")
      spot(screen_width/2-domain/2+hipporadius/3,screen_height/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2-domain/2+hipporadius/3,screen_height/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2-domain/2+1.2*hipporadius/3,screen_height/2+hipporadius/3,hipporadius/10)
      spot(screen_width/2-domain/2+1.2*hipporadius/3,screen_height/2-hipporadius/3,hipporadius/10)
    if hippo2==1:
      color("rgba(255,0,255,1)")
      spot(screen_width/2,screen_height/2-domain/2,hipporadius)
      color("white")
      spot(screen_width/2+hipporadius/3,screen_height/2-domain/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2-hipporadius/3,screen_height/2-domain/2+hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2+hipporadius/3,screen_height/2-domain/2+1.2*hipporadius/3,hipporadius/10)
      spot(screen_width/2-hipporadius/3,screen_height/2-domain/2+1.2*hipporadius/3,hipporadius/10)
    if hippo3==1:
      color("rgba(255,100,0,1)")
      spot(screen_width/2,screen_height/2+domain/2,hipporadius)
      color("white")
      spot(screen_width/2-hipporadius/3,screen_height/2+domain/2-hipporadius/3,hipporadius/5)
      spot(screen_width/2+hipporadius/3,screen_height/2+domain/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2-hipporadius/3,screen_height/2+domain/2-1.2*hipporadius/3,hipporadius/10)
      spot(screen_width/2+hipporadius/3,screen_height/2+domain/2-1.2*hipporadius/3,hipporadius/10)
    if hippo4==1:
      color("rgba(0,0,255,1)")
      spot(screen_width/2+domain/2,screen_height/2,hipporadius)
      color("white")
      spot(screen_width/2+domain/2-hipporadius/3,screen_height/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2+domain/2-hipporadius/3,screen_height/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2+domain/2-1.2*hipporadius/3,screen_height/2+hipporadius/3,hipporadius/10)
      spot(screen_width/2+domain/2-1.2*hipporadius/3,screen_height/2-hipporadius/3,hipporadius/10)
 
    color("red")  
    text(10,10,sr)
    color("blue")
    text(screen_width-100,10,sb)
    
    if redcount==0 or bluecount==0:
      gameend=1
      if sr>sb:
        print("Red team wins!")
      elif sb>sr:
        print("Blue team wins!")
      else:
        print("Draw!")
コード例 #32
0
ファイル: Minesweeper.py プロジェクト: NayfS/tealight-files
import random
from random import randrange
from math import floor
from tealight.art import (color, line, spot, circle, box, image, text, background)
score=0
ingame=1
color('white')
box(0,0,1000,1000)
color("black")
text(0, 600,"Score: "+str(score))
 
#this makes the grid
def makegrid():
  for j in range(0, 10):
    for i in range(0, 10):
      if((i+j) % 2) !=1:
        color("black")
      else:
        color("blue")
      box(i*60, j*60, 50, 50)
 
#this gets the information about a box from the corresponding list
def get(A, x, y):
  position = (11*(y))+x
  return A[position]
 
#this sets the information about a box to the corresponding lis
def setbox(A, x, y, val):
  position = (11*(y))+x
  A[position] = val
 
コード例 #33
0
ファイル: art-demo.py プロジェクト: luisdomin5/tealight-files
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)

    hue += 1

    lastx = x
コード例 #34
0
ファイル: word.py プロジェクト: amyble/tealight-files
def word():
  a = ["Dog", "Cat", "Castle", "Voldemort", "Barack Obama", "Snowman", "Aeroplane", "Apple", "Bible", "Chocolates", "Electricity"]
  text(screen_width /2, screen_height / 2, random.choice(a))
コード例 #35
0
def handle_frame():
  global mx,my, gamestate, sr, sb, shiftx, shifty, dshiftx, dshifty, gameover, player, aimrad, ffwd, counter
  
  counter=(counter+1)%20
  
  if ffwd==0 or counter==0:  
    color("black")
    box(0,0,screen_width,screen_height)
  
  vsum=0
  shiftx=(shiftx+dshiftx)%screen_width
  shifty=(shifty+dshifty)%screen_height
  mx=mmx-shiftx
  my=mmy-shifty
  
  if ffwd==0 or counter==0:
    color("white")
    circle(cx+shiftx,cy+shifty,2*radius)
    circle(cx+screen_width+shiftx,cy+shifty,2*radius)
    circle(cx+shiftx-screen_width,cy+shifty,2*radius)
    circle(cx+shiftx,cy+shifty+screen_height,2*radius)
    circle(cx+shiftx,cy+shifty-screen_height,2*radius)
    circle(cx+shiftx+screen_width,cy+shifty+screen_height,2*radius)
    circle(cx+shiftx+screen_width,cy+shifty-screen_height,2*radius)
    circle(cx+shiftx-screen_width,cy+shifty+screen_height,2*radius)
    circle(cx+shiftx-screen_width,cy+shifty-screen_height,2*radius)
    color("rgba(255,0,0,1)")
    text(cx+shiftx-6,cy+shifty-24,sr)
    text(cx+shiftx+screen_width-6,cy+shifty-24,sr)
    text(cx+shiftx-screen_width-6,cy+shifty-24,sr)
    text(cx+shiftx-6,cy+shifty+screen_height-24,sr)
    text(cx+shiftx-6,cy+shifty-screen_height-24,sr)
    text(cx+shiftx+screen_width-6,cy+shifty+screen_height-24,sr)
    text(cx+shiftx+screen_width-6,cy+shifty-screen_height-24,sr)
    text(cx+shiftx-screen_width-6,cy+shifty+screen_height-24,sr)
    text(cx+shiftx-screen_width-6,cy+shifty-screen_height-24,sr)
    
    color("rgba(0,0,255,1)") 
    text(cx+shiftx-6,cy+shifty,sb)
    text(cx+shiftx+screen_width-6,cy+shifty,sb)
    text(cx+shiftx-screen_width-6,cy+shifty,sb)
    text(cx+shiftx-6,cy+shifty+screen_height,sb)
    text(cx+shiftx-6,cy+shifty-screen_height,sb)
    text(cx+shiftx+screen_width-6,cy+shifty+screen_height,sb)
    text(cx+shiftx+screen_width-6,cy+shifty-screen_height,sb)
    text(cx+shiftx-screen_width-6,cy+shifty+screen_height,sb)
    text(cx+shiftx-screen_width-6,cy+shifty-screen_height,sb)
  
    a1=mx-a[d*(n-1)]
    a2=my-a[d*(n-1)+1]
    if a1>screen_width/2:
      a1=-screen_width+a1
    elif a1<-screen_width/2:
      a1=screen_width+a1
    if a2>screen_height/2:
      a2=-screen_height+a2
    elif a2<-screen_height/2:
      a2=screen_height+a2
    aa=a1*a1+a2*a2
    a1=a1*aimrad/sqrt(aa)
    a2=a2*aimrad/sqrt(aa)
    if gamestate==0 and aa<aimrad**2:
      if player==0:
        color("rgba(255,0,0,1)")
      elif player==1:
        color("rgba(0,0,255,1)")
      line(a[d*(n-1)]+shiftx,a[d*(n-1)+1]+shifty,a[d*(n-1)]+shiftx+a1,a[d*(n-1)+1]+shifty+a2)
      line(a[d*(n-1)]+shiftx+screen_width,a[d*(n-1)+1]+shifty,a[d*(n-1)]+shiftx+screen_width+a1,a[d*(n-1)+1]+shifty+a2)
      line(a[d*(n-1)]+shiftx-screen_width,a[d*(n-1)+1]+shifty,a[d*(n-1)]+shiftx-screen_width+a1,a[d*(n-1)+1]+shifty+a2)
      line(a[d*(n-1)]+shiftx,a[d*(n-1)+1]+shifty+screen_height,a[d*(n-1)]+shiftx+a1,a[d*(n-1)+1]+shifty+screen_height+a2)
      line(a[d*(n-1)]+shiftx,a[d*(n-1)+1]+shifty-screen_height,a[d*(n-1)]+shiftx+a1,a[d*(n-1)+1]+shifty-screen_height+a2)
      
      line(a[d*(n-1)]+shiftx+screen_width,a[d*(n-1)+1]+shifty+screen_height,a[d*(n-1)]+shiftx+screen_width+a1,a[d*(n-1)+1]+shifty+screen_height+a2)
      line(a[d*(n-1)]+shiftx+screen_width,a[d*(n-1)+1]+shifty-screen_height,a[d*(n-1)]+shiftx+screen_width+a1,a[d*(n-1)+1]+shifty-screen_height+a2)
      line(a[d*(n-1)]+shiftx-screen_width,a[d*(n-1)+1]+shifty+screen_height,a[d*(n-1)]+shiftx-screen_width+a1,a[d*(n-1)+1]+shifty+screen_height+a2)
      line(a[d*(n-1)]+shiftx-screen_width,a[d*(n-1)+1]+shifty-screen_height,a[d*(n-1)]+shiftx-screen_width+a1,a[d*(n-1)+1]+shifty-screen_height+a2)

  for i in range (0,n):
    if a[d*i+7]!=1:
      a[d*i]=a[d*i]+a[d*i+2]
      a[d*i+1]=a[d*i+1]+a[d*i+3]
      vv=sqrt(a[d*i+2]**2+a[d*i+3]**2)
      if vv!=0:
        a[d*i+2]=a[d*i+2]*(1-mu/vv)
        a[d*i+3]=a[d*i+3]*(1-mu/vv)
      
      
      k1=int(a[d*i+1]/screen_height)
      k2=a[d*i+1]%screen_height
      
      a[d*i]=(a[d*i]%screen_width)*(-1)**k1
      a[d*i+1]=k2
      a[d*i+2]=a[d*i+2]*(-1)**k1
      
      vsum=vsum+vv
      
      #Collisions   
      for j in range (i+1,n):
        if a[d*j+7]!=1:
          n1=(a[d*i]-a[d*j])
          n2=(a[d*i+1]-a[d*j+1])
          nn=n1*n1+n2*n2
          if nn<4*radius*radius:
            if nn !=0:
              v1x=a[d*i+2]
              v1y=a[d*i+3]
              v2x=a[d*j+2]
              v2y=a[d*j+3]        
              v3x=n1*v1x+n2*v1y
              v3y=-n2*v1x+n1*v1y
              v4x=n1*v2x+n2*v2y
              v4y=-n2*v2x+n1*v2y              
              v5x=0.5*((1-e)*v3x+(1+e)*v4x)
              v6x=0.5*((1-e)*v4x+(1+e)*v3x)              
              v7x=(n1*v5x-n2*v3y)/nn
              v7y=(n2*v5x+n1*v3y)/nn
              v8x=(n1*v6x-n2*v4y)/nn
              v8y=(n2*v6x+n1*v4y)/nn
              a[d*i+2]=v7x
              a[d*i+3]=v7y
              a[d*j+2]=v8x
              a[d*j+3]=v8y 
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
          n1=(a[d*i]-a[d*j]-screen_width)
          n2=(a[d*i+1]-a[d*j+1])
          nn=n1*n1+n2*n2
          if nn<4*radius*radius:
            if nn !=0:
              v1x=a[d*i+2]
              v1y=a[d*i+3]
              v2x=a[d*j+2]
              v2y=a[d*j+3]        
              v3x=n1*v1x+n2*v1y
              v3y=-n2*v1x+n1*v1y
              v4x=n1*v2x+n2*v2y
              v4y=-n2*v2x+n1*v2y              
              v5x=0.5*((1-e)*v3x+(1+e)*v4x)
              v6x=0.5*((1-e)*v4x+(1+e)*v3x)              
              v7x=(n1*v5x-n2*v3y)/nn
              v7y=(n2*v5x+n1*v3y)/nn
              v8x=(n1*v6x-n2*v4y)/nn
              v8y=(n2*v6x+n1*v4y)/nn
              a[d*i+2]=v7x
              a[d*i+3]=v7y
              a[d*j+2]=v8x
              a[d*j+3]=v8y 
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
          n1=(a[d*i]-a[d*j]+screen_width)
          n2=(a[d*i+1]-a[d*j+1])
          nn=n1*n1+n2*n2
          if nn<4*radius*radius:
            if nn !=0:
              v1x=a[d*i+2]
              v1y=a[d*i+3]
              v2x=a[d*j+2]
              v2y=a[d*j+3]        
              v3x=n1*v1x+n2*v1y
              v3y=-n2*v1x+n1*v1y
              v4x=n1*v2x+n2*v2y
              v4y=-n2*v2x+n1*v2y              
              v5x=0.5*((1-e)*v3x+(1+e)*v4x)
              v6x=0.5*((1-e)*v4x+(1+e)*v3x)              
              v7x=(n1*v5x-n2*v3y)/nn
              v7y=(n2*v5x+n1*v3y)/nn
              v8x=(n1*v6x-n2*v4y)/nn
              v8y=(n2*v6x+n1*v4y)/nn
              a[d*i+2]=v7x
              a[d*i+3]=v7y
              a[d*j+2]=v8x
              a[d*j+3]=v8y 
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
        
          n1=(a[d*i]-a[d*j])
          n2=(a[d*i+1]-a[d*j+1]+screen_height)
          nn=n1*n1+n2*n2
          if nn<4*radius*radius:
            if nn !=0:
              v1x=a[d*i+2]
              v1y=a[d*i+3]
              v2x=a[d*j+2]
              v2y=a[d*j+3]        
              v3x=n1*v1x+n2*v1y
              v3y=-n2*v1x+n1*v1y
              v4x=n1*v2x+n2*v2y
              v4y=-n2*v2x+n1*v2y              
              v5x=0.5*((1-e)*v3x+(1+e)*v4x)
              v6x=0.5*((1-e)*v4x+(1+e)*v3x)              
              v7x=(n1*v5x-n2*v3y)/nn
              v7y=(n2*v5x+n1*v3y)/nn
              v8x=(n1*v6x-n2*v4y)/nn
              v8y=(n2*v6x+n1*v4y)/nn
              a[d*i+2]=v7x
              a[d*i+3]=v7y
              a[d*j+2]=v8x
              a[d*j+3]=v8y 
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
          n1=(a[d*i]-a[d*j])
          n2=(a[d*i+1]-a[d*j+1]-screen_height)
          nn=n1*n1+n2*n2
          if nn<4*radius*radius:
            if nn !=0:
              v1x=a[d*i+2]
              v1y=a[d*i+3]
              v2x=a[d*j+2]
              v2y=a[d*j+3]        
              v3x=n1*v1x+n2*v1y
              v3y=-n2*v1x+n1*v1y
              v4x=n1*v2x+n2*v2y
              v4y=-n2*v2x+n1*v2y              
              v5x=0.5*((1-e)*v3x+(1+e)*v4x)
              v6x=0.5*((1-e)*v4x+(1+e)*v3x)              
              v7x=(n1*v5x-n2*v3y)/nn
              v7y=(n2*v5x+n1*v3y)/nn
              v8x=(n1*v6x-n2*v4y)/nn
              v8y=(n2*v6x+n1*v4y)/nn
              a[d*i+2]=v7x
              a[d*i+3]=v7y
              a[d*j+2]=v8x
              a[d*j+3]=v8y 
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
        
      #Pocket
      if (a[d*i]-cx)**2+(a[d*i+1]-cy)**2<4*radius**2 and i!=n-1:
        a[d*i+7]=1
        if i<(n/2)-1:
          sr=sr+1
        elif i<n-2:
          sb=sb+1
        else:
          if gameover==0:
            gameover=1
            if player==0:
              if sb==n/2-1:
                print("Blue wins.")
              else:
                print("Red wins.")
            if player==1:
              if sr==n/2-1:
                print("Red wins.")
              else:
                print("Blue wins.")
              
      if ffwd==0 or counter==0:
        c=[a[d*i+4],a[d*i+5],a[d*i+6],1]
        colstring = ctorgba(c)
        color(colstring)
        spot(a[d*i]+shiftx,a[d*i+1]+shifty,radius)
        spot(a[d*i]+shiftx+screen_width,a[d*i+1]+shifty,radius)
        spot(a[d*i]+shiftx-screen_width,a[d*i+1]+shifty,radius)
        spot(a[d*i]+shiftx,a[d*i+1]+shifty+screen_height,radius)
        spot(a[d*i]+shiftx,a[d*i+1]+shifty-screen_height,radius)
        spot(a[d*i]+shiftx+screen_width,a[d*i+1]+shifty+screen_height,radius)
        spot(a[d*i]+shiftx+screen_width,a[d*i+1]+shifty-screen_height,radius)
        spot(a[d*i]+shiftx-screen_width,a[d*i+1]+shifty+screen_height,radius)
        spot(a[d*i]+shiftx-screen_width,a[d*i+1]+shifty-screen_height,radius)
  
  
  if vsum>0.1:
    gamestate=1
  else:
    gamestate=0
    for i in range(0,n):
      a[d*i+2]=0
      a[d*i+3]=0
コード例 #36
0
ファイル: art-demo.py プロジェクト: adam1984/tealight-files
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 Adam!")

lastx = None
lasty = None
hue = 0

def handle_mousemove(x,y):
  global lastx, lasty, hue
  
  line(lastx or x, lasty or y, x, y)
  circle(lastx or x, lasty or y, x)
  
  #color("hsl(%d,100%%,50%%)" % hue)
  color("rgba(400,9,0,0.7)" % hue)
  
  box(lastx or x, lasty or y, x, y)
コード例 #37
0
def uncover(boxX, boxY):
    global score
    global ingame
    global mine
    if get(mine, boxX, boxY) == 1:
        color('red')
        box(boxX * 60, boxY * 60, 50, 50)
        ingame = 0
        color("white")
        box(0, 600, 500, 50)
        color("black")
        text(0, 600, "Final score: " + str(score))
        text(500, 600, "You Lost!")
        findMines()
    if get(mine, boxX, boxY) == 0:
        color('white')
        box(boxX * 60, boxY * 60, 50, 50)
        setbox(mine, boxX, boxY, 2)
        end = getSurroundingMines(boxX, boxY)
        score = getscore()
        color("white")
        box(0, 600, 500, 50)
        color("black")
        text(0, 600, "Score: " + str(score))
        if score == 85:
            score = 100
            ingame = 0
            color("white")
            box(0, 600, 500, 50)
            color("black")
            text(0, 600, "Final score: " + str(score))
            text(500, 600, "You WIN!")
        if end == 0:
            if boxX < 9:
                if boxY < 9:
                    if boxX > 0:
                        if boxY > 0:
                            uncover(boxX + 1, boxY)
                            uncover(boxX - 1, boxY)
                            uncover(boxX, boxY + 1)
                            uncover(boxX, boxY - 1)
            if boxX < 9:
                if boxY == 9:
                    if boxX > 0:
                        uncover(boxX + 1, boxY)
                        uncover(boxX - 1, boxY)
                        uncover(boxX, boxY - 1)
            if boxX < 9:
                if boxY == 0:
                    if boxX > 0:
                        uncover(boxX + 1, boxY)
                        uncover(boxX - 1, boxY)
                        uncover(boxX, boxY + 1)
            if boxY < 9:
                if boxX == 9:
                    if boxY > 0:
                        uncover(boxX + 1, boxY)
                        uncover(boxX - 1, boxY)
                        uncover(boxX, boxY - 1)
            if boxY < 9:
                if boxX == 0:
                    if boxY > 0:
                        uncover(boxX, boxY + 1)
                        uncover(boxX, boxY - 1)
                        uncover(boxX + 1, boxY)
            if boxX == 0:
                if boxY == 9:
                    uncover(boxX, boxY - 1)
                    uncover(boxX + 1, boxY)
            if boxX == 9:
                if boxY == 0:
                    uncover(boxX, boxY + 1)
                    uncover(boxX - 1, boxY)
            if boxX == 0:
                if boxY == 0:
                    uncover(boxX, boxY + 1)
                    uncover(boxX + 1, boxY)
            if boxX == 9:
                if boxY == 9:
                    uncover(boxX, boxY - 1)
                    uncover(boxX - 1, boxY)
コード例 #38
0
def handle_frame():
  global sr, sb, gameend, e3, redcount, bluecount
  if gameend==0:
    
    sleep(20)
    color("white")
    box(0,0,screen_width,screen_height)
    color("black")
    circle(screen_width/2,screen_height/2,domain+radius)
    color("rgba(255,0,0,1)")
    circle(screen_width/2-domain/2,screen_height/2,hipporadius)
    color("rgba(255,0,255,1)")
    circle(screen_width/2,screen_height/2-domain/2,hipporadius)
    color("rgba(255,100,0,1)")
    circle(screen_width/2,screen_height/2+domain/2,hipporadius)
    color("rgba(0,0,255,1)")
    circle(screen_width/2+domain/2,screen_height/2,hipporadius)
    
    for i in range (0,4*n+1):
      #a[d*i+8]=-a[d*i]/1000
      #a[d*i+9]=-a[d*i+1]/1000
      a[d*i]=a[d*i]+a[d*i+2]
      a[d*i+1]=a[d*i+1]+a[d*i+3]
      
      
      a1=a[d*i]-screen_width/2
      a2=a[d*i+1]-screen_height/2
      aa=sqrt(a1*a1+a2*a2)
      a[d*i+8]=-mu*a[d*i+2]-g*a1/aa
      a[d*i+9]=-mu*a[d*i+3]-g*a2/aa
    
      a[d*i+2]=a[d*i+2]*1+a[d*i+8]
      a[d*i+3]=a[d*i+3]*1+a[d*i+9]
     
    
    for i in range (0,4*n+1):
      c=[a[d*i+4],a[d*i+5],a[d*i+6],1]
      colstring = ctorgba(c)
      color(colstring)
      spot(a[d*i],a[d*i+1],radius)
    if i==4*n:
      color("white")
      text(a[d*i]-3,a[d*i+1]-11,"!")
    for i in range (0,4*n+1):
      for j in range (i+1,4*n+1):
        n1=(a[d*i]-a[d*j])
        n2=(a[d*i+1]-a[d*j+1])
        nn=n1*n1+n2*n2
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        v2x=a[d*j+2]
        v2y=a[d*j+3]
        if nn<4*radius*radius:
          if nn !=0:
            if a[d*i+7]==0 and a[d*i+7]==0:
              a[d*i+2]=((n2*n2-e*n1*n1)*v1x-(1+e)*n1*n2*v1y)/nn
              a[d*i+3]=(-(1+e)*n1*n2*v1x+(n1*n1-e*n2*n2)*v1y)/nn
              a[d*j+2]=((n2*n2-n1*n1)*v2x-2*n1*n2*v2y)/nn
              a[d*j+3]=(-2*n1*n2*v2x+(n1*n1-n2*n2)*v2y)/nn
              a[d*i]=a[d*i]+(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*i+1]=a[d*i+1]+(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*j]=a[d*j]-(0+radius-sqrt(nn)/2)*n1/sqrt(nn)
              a[d*j+1]=a[d*j+1]-(0+radius-sqrt(nn)/2)*n2/sqrt(nn)
              a[d*i+7]=0
              a[d*j+7]=0
      if a[d*i+7]!=0:
        a[d*i+7]=a[d*i+7]-1
    #print(i,domain*domain,(a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2))
              
      if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)>domain*domain and a[d*i]<screen_width:
        #print(i)
        n1=-(a[d*i]-screen_width/2)
        n2=-(a[d*i+1]-screen_height/2)
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        nn=n1*n1+n2*n2
        a[d*i+2]=((n2*n2-e2*n1*n1)*v1x-(1+e2)*n1*n2*v1y)/nn
        a[d*i+3]=(-(1+e2)*n1*n2*v1x+(n1*n1-e2*n2*n2)*v1y)/nn
        a[d*i]=a[d*i]+(0-domain+sqrt(nn))*n1/sqrt(nn)
        a[d*i+1]=a[d*i+1]+(0-domain+sqrt(nn))*n2/sqrt(nn)
      hcx=a[d*i]-screen_width/2+domain/2
      hcy=a[d*i+1]-screen_height/2
      if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo1==1:
        n1=hcx
        n2=hcy
        nn=n1*n1+n2*n2
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
        a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
        a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
        a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      if (a[d*i]-screen_width/2+domain/2)*(a[d*i]-screen_width/2+domain/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)<hipporadius*hipporadius and hippo1==1:
        a[d*i]=screen_width+100
        a[d*i+1]=screen_height+100
        a[d*i+2]=0
        a[d*i+3]=0
        team=int(i/n)
        if team==0:
          sr=sr-1
          bluecount=bluecount-1
        elif team==1:
          sr=sr-1
          bluecount=bluecount-1
        elif team==2:
          sr=sr+3
          redcount=redcount-1
        elif team==3:
          sr=sr-1
          redcount=redcount-1
        elif team==4:
          sr=-100
          gameend=1
          print("Blue team wins!")
      hcx=a[d*i]-screen_width/2
      hcy=a[d*i+1]-screen_height/2+domain/2
      if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo2==1:
        n1=hcx
        n2=hcy
        nn=n1*n1+n2*n2
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
        a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
        a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
        a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2+domain/2)*(a[d*i+1]-screen_height/2+domain/2)<hipporadius*hipporadius and hippo2==1:
        a[d*i]=1000000
        a[d*i+1]=1000000
        a[d*i+2]=0
        a[d*i+3]=0
        team=int(i/n)
        if team==0:
          sr=sr
          bluecount=bluecount-1
        elif team==1:
          sb=sb+1
          bluecount=bluecount-1
        elif team==2:
          sr=sr
          redcount=redcount-1
        elif team==3:
          sr=sr
          redcount=redcount-1
        elif team==4:
          sb=-100
          gameend=1
          print("Red team wins!")
          
      hcx=a[d*i]-screen_width/2
      hcy=a[d*i+1]-screen_height/2-domain/2
      if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo3==1:
        n1=hcx
        n2=hcy
        nn=n1*n1+n2*n2
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
        a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
        a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
        a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
      if (a[d*i]-screen_width/2)*(a[d*i]-screen_width/2)+(a[d*i+1]-screen_height/2-domain/2)*(a[d*i+1]-screen_height/2-domain/2)<hipporadius*hipporadius and hippo3==1:
        a[d*i]=1000000
        a[d*i+1]=1000000
        a[d*i+2]=0
        a[d*i+3]=0
        team=int(i/n)
        if team==0:
          sr=sr
          bluecount=bluecount-1
        elif team==1:
          sr=sr
          bluecount=bluecount-1
        elif team==2:
          sr=sr
          redcount=redcount-1
        elif team==3:
          sr=sr+1
          redcount=redcount-1
        elif team==4:
          sr=-100
          gameend=1
          print("Blue team wins!")
      hcx=a[d*i]-screen_width/2-domain/2
      hcy=a[d*i+1]-screen_height/2
      if hcx*hcx+hcy*hcy>hipporadius*hipporadius and hcx*hcx+hcy*hcy<(hipporadius+radius)*(hipporadius+radius) and hippo4==1:
        n1=hcx
        n2=hcy
        nn=n1*n1+n2*n2
        v1x=a[d*i+2]
        v1y=a[d*i+3]
        a[d*i+2]=((n2*n2-e3*n1*n1)*v1x-(1+e3)*n1*n2*v1y)/nn
        a[d*i+3]=(-(1+e3)*n1*n2*v1x+(n1*n1-e3*n2*n2)*v1y)/nn
        a[d*i]=a[d*i]+(0+radius+hipporadius-sqrt(nn))*n1/sqrt(nn)
        a[d*i+1]=a[d*i+1]+(0+radius+hipporadius-sqrt(nn))*n2/sqrt(nn)
        
      if (a[d*i]-screen_width/2-domain/2)*(a[d*i]-screen_width/2-domain/2)+(a[d*i+1]-screen_height/2)*(a[d*i+1]-screen_height/2)<hipporadius*hipporadius and hippo4==1:
        a[d*i]=1000000
        a[d*i+1]=1000000
        a[d*i+2]=0
        a[d*i+3]=0
        team=int(i/n)
        if team==0:
          sb=sb+3
          bluecount=bluecount-1
        elif team==1:
          sb=sb-1
          bluecount=bluecount-1
        elif team==2:
          sb=sb-1
          redcount=redcount-1
        elif team==3:
          sb=sb-1
          redcount=redcount-1
        elif team==4:
          sb=-100
          gameend=1
          print("Red team wins!")
    
    if hippo1==1:
      color("rgba(255,0,0,1)")
      spot(screen_width/2-domain/2,screen_height/2,hipporadius)
      color("white")
      spot(screen_width/2-domain/2+hipporadius/3,screen_height/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2-domain/2+hipporadius/3,screen_height/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2-domain/2+1.2*hipporadius/3,screen_height/2+hipporadius/3,hipporadius/10)
      spot(screen_width/2-domain/2+1.2*hipporadius/3,screen_height/2-hipporadius/3,hipporadius/10)
    if hippo2==1:
      color("rgba(255,0,255,1)")
      spot(screen_width/2,screen_height/2-domain/2,hipporadius)
      color("white")
      spot(screen_width/2+hipporadius/3,screen_height/2-domain/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2-hipporadius/3,screen_height/2-domain/2+hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2+hipporadius/3,screen_height/2-domain/2+1.2*hipporadius/3,hipporadius/10)
      spot(screen_width/2-hipporadius/3,screen_height/2-domain/2+1.2*hipporadius/3,hipporadius/10)
    if hippo3==1:
      color("rgba(255,100,0,1)")
      spot(screen_width/2,screen_height/2+domain/2,hipporadius)
      color("white")
      spot(screen_width/2-hipporadius/3,screen_height/2+domain/2-hipporadius/3,hipporadius/5)
      spot(screen_width/2+hipporadius/3,screen_height/2+domain/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2-hipporadius/3,screen_height/2+domain/2-1.2*hipporadius/3,hipporadius/10)
      spot(screen_width/2+hipporadius/3,screen_height/2+domain/2-1.2*hipporadius/3,hipporadius/10)
    if hippo4==1:
      color("rgba(0,0,255,1)")
      spot(screen_width/2+domain/2,screen_height/2,hipporadius)
      color("white")
      spot(screen_width/2+domain/2-hipporadius/3,screen_height/2+hipporadius/3,hipporadius/5)
      spot(screen_width/2+domain/2-hipporadius/3,screen_height/2-hipporadius/3,hipporadius/5)
      color("black")
      spot(screen_width/2+domain/2-1.2*hipporadius/3,screen_height/2+hipporadius/3,hipporadius/10)
      spot(screen_width/2+domain/2-1.2*hipporadius/3,screen_height/2-hipporadius/3,hipporadius/10)
 
    color("red")  
    text(10,screen_height-24,sr)
    color("blue")
    text(screen_width-100,10,sb)
    
    if redcount==0 or bluecount==0:
      gameend=1
      if sr>sb:
        print("Red team wins!")
      elif sb>sr:
        print("Blue team wins!")
      else:
        print("Draw!")
コード例 #39
0
ファイル: Minesweeper.py プロジェクト: AimeeH/tealight-files
def show_num(i,j,num):
  tx = startx + i*size
  ty = starty + j*size
  white(tx, ty)
  color("black")
  text(tx + size/7*3, ty + size/7*3, num)
コード例 #40
0
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(10, 10, "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)

    hue += 1

    lastx = x
コード例 #41
0
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(10, 10, "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)
  
  hue += 1
  
  lastx = x
  lasty = y