Пример #1
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = (vx + ax)
  vy = vy + (ay + grav)
  while vx != 0:
   
  
    if vx<0:
      vx = vx+ mu
    else:
      vx = vx- mu
    
  
    x = x + vx 
    y = y + vy
  x = x + vx
  y = y + vy
  color("blue")
 
  spot(x,y,8)
  
  
Пример #2
0
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")
Пример #3
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    color("white")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x2 = x + vx
    y2 = y + vy

    if x2 < 0:
        x = -x2
        vx = -vx
    elif x2 > screen_width:
        x = screen_width * 2 - x2
        vx = -vx
    else:
        x = x2

    if y2 < 0:
        y = -y2
        vy = -vy
    elif y2 > screen_height:
        y = screen_height * 2 - y2
        vy = -vy
    else:
        y = y2

    color("blue")

    spot(x, y, 8)
Пример #4
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x2 = x + vx
  y2 = y + vy
  
  if x2 < 0:
    x=-x2
    vx=-vx
  elif x2 > screen_width:
    x=screen_width*2-x2
    vx=-vx
  else:
    x=x2
    
    
  if y2 < 0:
    y=-y2
    vy=-vy
  elif y2 > screen_height:
    y=screen_height*2-y2
    vy=-vy
  else:
    y=y2
  
  color("blue")
  
  spot(x,y,8)
Пример #5
0
def handle_frame(): 
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  
    
  vx = vx + ax
  vy = vy + ay
  
  
  #gravity
  vy = vy + gravity
  apply_gravity()
  
  #friction
  vx = apply_friction(vx)
  vy = apply_friction(vy)
  

  
  
  x = x + vx
  y = y + vy
  
  color("blue")
  
  spot(x,y,8)
  
  
Пример #6
0
def handle_frame():
    global x, y, vx, vy

    color("white")
    spot(x, y, 8)

    rx = x - screen_width / 2
    ry = y - screen_height / 2

    magsq = rx**2 + ry**2
    if magsq != 0:
        # normalise
        mag = sqrt(magsq)
        rx /= mag
        ry /= mag

        # apply inverse square rule
        rx *= g / magsq
        ry *= g / magsq

        vx -= rx / m
        vy -= ry / m

    x = x + vx
    y = y + vy

    color("blue")
    drawship(x, y, 0)
Пример #7
0
def handle_frame():
  global x,y,vx,vy
  
  color("white")
  spot(x,y,8)
  
  rx = x - screen_width / 2
  ry = y - screen_height / 2
  
  magsq = rx**2 + ry**2
  if magsq != 0:
    # normalise
    mag = sqrt(magsq)
    rx /= mag
    ry /= mag
    
    # apply inverse square rule
    rx *= g/magsq
    ry *= g/magsq
    
    vx -= rx / m
    vy -= ry / m
  
  x = x + vx
  y = y + vy
  
  color("blue")
  drawship(x, y, 0)
Пример #8
0
def handle_frame(): 
  global x,y,vx,vy,constant,n
  
  n = n + 1
  
  for i in range(0,len(x)):
      color("white")
      spot(x[i],y[i],2)
      
      vx[i] = vx[i] + constant[i]
      
      angle = math.atan2(-vy[i],vx[i]) + (math.pi / 2)
  
      fx =  1 * math.cos(angle)
      fy = -1 * math.sin(angle)
  
      vxa = vx[i] + fx
      vya = vy[i] + fy
  
      factor = math.sqrt(vx[i]**2 + vy[i]**2) / math.sqrt(vxa**2 + vya**2)
  
      vx[i] = vxa * factor
      vy[i] = vya * factor
  
  
      x[i] = x[i] + vx[i]
      y[i] = y[i] + vy[i]
  
  
      color("black")
      spot(x[i],y[i],2)
Пример #9
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = (vx*0.95) + ax
  vy = (vy*0.95) + ay + 0.1
  
  x = x + vx
  y = y + vy 
  
  color("blue")
  if x<=0 or x>=900:
    vx = -vx
    ax = (-0.8*ax)
  elif y<=0 or y>=1000:
    vy = -vy
    ay = (-0.8*ay)
  spot(x,y,8)
  
  

  
  
Пример #10
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  if 1000 < y:
    vy=-vy
  elif y < 1:
    vy=-vy
    
    
  if 910 < x:
    vx=-vx  
  elif x < 1:
    vx=-vx
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("blue")
  
  spot(x,y,8)
Пример #11
0
def DrawBomb(x,y):
  
  color("red")
  box(x*34+182,y*34+202,32,32)
  
  centrex = 199 + 34 * x
  centrey = 219 + 34 * y
  
  color("black")
  spot(centrex,centrey,10)
Пример #12
0
def handle_mousedown(x,y,button):
  global turn 
  if button == "left" and turn ==1:
    color("red")
    spot(x,y,45)
    turn =2
  elif button == "left" and turn ==2:
    color("yellow")
    spot (x,y,45)
    turn =1
Пример #13
0
def handle_mousedown(x,y):
  global Array_X
  global Array_y
  spot(x,y,10)
  Array_X = x
  Array_Y = y
  print x
  print y

  
  
Пример #14
0
def handle_keydown(keychar, keyval):
  global x,y
  x += 10
  y += 10
  
  
  
  
  
  spot(x,y,5)
  print keychar
Пример #15
0
def handle_mousedown(x, y,button):
 
  global score
  boxX = floor(x/60)
  boxY = floor(y/60)
  if boxX<10:
    if boxY<10:
      if ingame == 1:
        if button=="left":
          uncover(boxX, boxY)
        if button=="right"and get(mine, boxX, boxY)!=2:
          color("green")
          spot(boxX*60 +25 ,boxY*60 + 25,10)
Пример #16
0
 def AddPoint(self, px, py, pz):
   #Get fractional co-ords
   frac_px = float(px)/self.x_lim[1]
   frac_py = float(py)/self.y_lim[1]
   
   #Convert to pixels
   pixel_x = self.pos[0] + 0.5*(1.0+frac_px)*self.width[0]
   pixel_y = self.pos[1] + 0.5*(1.0+frac_py)*self.width[1]
   
   coloffset_z = 40
   col = [255-int(abs(pz)*coloffset_z), 0,0 + int(abs(pz)*coloffset_z), 0.1]
   color(coltostr(col))
   spot(pixel_x, pixel_y, 3)
Пример #17
0
def handle_mousedown(x, y, button):

    global score
    boxX = floor(x / 60)
    boxY = floor(y / 60)
    if boxX < 10:
        if boxY < 10:
            if ingame == 1:
                if button == "left":
                    uncover(boxX, boxY)
                if button == "right" and get(mine, boxX, boxY) != 2:
                    color("green")
                    spot(boxX * 60 + 25, boxY * 60 + 25, 10)
Пример #18
0
def handle_mousemove(x, y, button):
  ox = (x - 300) / 15
  oy = (y - 200) / 15
  
  if ox**2 + oy**2 > (50-20)**2:
    ratio = float(ox**2 + oy**2) / (50-20)**2
    ox /= ratio
    oy /= ratio
  
  color("white")
  spot(300, 200, 49)
  
  color("black")
  spot(300 + ox, 200 + oy, 20)
Пример #19
0
def drawcircle(player, x, y, grid):
  
  color(player)
  
  xloc = 125 + (x*80)
  yloc = 125 + (y*80)
  
  spot(xloc, yloc, 37.5)
  
  grid[x][y] = player
  
  for i in range(8):
    print grid[i]
  
  return grid
def handle_frame():
  global x,y,vx,vy,ax,ay
  color("white")
  box(0,0,screen_width,screen_height)
  color("black")
  spot(x, y, 20)
  
  
  vx = (vx+ax)*0.97
  vy = vy + ay +0.12
  if vy > 10:
    vy =10
  
  x = x + vx
  y = y + vy
Пример #21
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("blue")
  
  spot(x,y,8)
Пример #22
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    color("blue")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x = x + vx
    y = y + vy

    color("red")

    spot(x, y, 36)
Пример #23
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx =(vx + ax)
  vy =(vy + ay)
  
  x = (x + vx)
  y = (y + vy)
  
  color("blue")
  
  spot(x,y,8)
Пример #24
0
def drawcircle(player, x, y, grid):

    color(player)

    xloc = 125 + (x * 80)
    yloc = 125 + (y * 80)

    spot(xloc, yloc, 37.5)

    grid[x][y] = player

    for i in range(8):
        print grid[i]

    return grid
Пример #25
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    color("white")

    spot(x, y, 8)
    vx = (vx + ax)
    vy = (vy + ay)

    x = (x + vx)
    y = (y + vy)

    color("blue")

    spot(x, y, 8)
Пример #26
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")
Пример #27
0
def setgrid():
  
  x = 125
  y = 125
  color("white")

  for i in range(8):
    for j in range(8):
      spot(x,y,37.5)
      x += 80
    x = 125
    y += 80
  
  grid = [[0 for j in range(8)] for i in range(8)]
  
  return grid
Пример #28
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("red")
  
  spot (x,y,25)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("black")
  
  spot (x,y,25)
  
Пример #29
0
def setgrid():

    x = 125
    y = 125
    color("white")

    for i in range(8):
        for j in range(8):
            spot(x, y, 37.5)
            x += 80
        x = 125
        y += 80

    grid = [[0 for j in range(8)] for i in range(8)]

    return grid
Пример #30
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("yellow")
  
  spot(x,y,10)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("purple")
  
  spot(x,y,10)
  
  
def handle_mousedown(x,y,button):
  if button == "left":
   
   color("black")
  
   spot(x,y,8)
   x = 10 
   vx = (vx+ax)*0.97
   vy = vy + ay +0.12
   if vy > 10:
     vy =10
     x = x + vx
     y = y + vy
   if y >= 800:
     vy=-1*abs(0.4*vy)
   if y>805:
     y=805
Пример #32
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("green")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("purple")
  
  spot(x,y,8)
  
  
Пример #33
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("blue")
  
  if ay < 0.6:
    ay += (1 * 10 ** -3) #Gravity in -Y direction

  spot(x,y,8)
Пример #34
0
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
Пример #35
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  if x <= 50:
    vx = -vx
    ax = ax * 0.8
  
  color("blue")
  
  spot(x,y,8)
Пример #36
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay + gravity
  
  drag = - vy * 0.005
  vy += drag
  
  x = x + vx
  y = y + vy
  
  do_explosion()
  
  color("blue")
  
  spot(x,y,8)
Пример #37
0
def draw():
  color("blue")
  box(offset_x,offset_y,cell_size * cells_x,cell_size * cells_y)
  
  width = 20
  height = 8
  
  for i in range(0,cells_x):
    for j in range(0,cells_y):
  
      if boardArray [j][i] == 0:
        color("white")
      elif boardArray[j][i] == 1:
        color("red")
      elif boardArray[j][i] == 2:
        color("yellow")
      
      spot(offset_x + i * cell_size + cell_size/2, offset_y + j * cell_size + cell_size/2, cell_size *0.4)
  
  check_winner(boardArray)
Пример #38
0
def handle_frame():
  global x,y,vx,vy,ax,ay
  ay+=gravity
  if vx > 0:
    vx -= friction
  if vy > 0:
    vy -= friction
  
  color("white")
  
  spot(x,y,8)
  vx = vx + ax
  vy = vy + ay
  
  x = x + vx
  y = y + vy
  
  color("blue")
  
  spot(x,y,8)
Пример #39
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    color("white")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay + gravity

    drag = -vy * 0.005
    vy += drag

    x = x + vx
    y = y + vy

    do_explosion()

    color("blue")

    spot(x, y, 8)
Пример #40
0
def handle_frame():
    global x, y, vx, vy, ax, ay
    gravity = 0.001
    ay = ay + gravity

    friction = 0.001
    if ax < 0:
        vx = vx + ax + friction

    color("white")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x = x + vx
    y = y + vy

    color("blue")

    spot(x, y, 8)
Пример #41
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    color("white")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x = x + vx
    y = y + vy

    color("blue")

    spot(x, y, 8)

    if vx > 0:
        vx -= 0.05

    if vx < 0:
        vx += 0.05

    if vy > 0:
        vy -= 0.05

    if vy < 0:
        vy += 0.05

    vy += 0.1

    print 'x is ' + str(x)
    print 'y is ' + str(y)
    print 'screen width is ' + str(screen_width)

    if x >= screen_width or x <= 0:
        vx = -vx
        print '-vx'

    if y >= screen_height or y <= 0:
        vy = -vy
Пример #42
0
def handle_frame():
    global x, y, vx, vy, ax, ay

    ax = ax - 0.001 * (x - screen_width / 2)
    ay = ay - 0.001 * (y - screen_height / 2)
    if ax > 1 or ax < -1:
        ax = .1
    if ay > 1 or ay < -1:
        ay = .1

    color("white")

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x = x + vx
    y = y + vy

    color("blue")

    spot(x, y, 8)
Пример #43
0
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")
Пример #44
0
def handle_frame():
    global x, y, vx, vy, ax, ay, hue

    ax = ax - 0.01 * (x - (screen_width / 2))
    ay = ay - 0.01 * (y - (screen_height / 2))

    if ax > 0.01 or ax < 0.01:
        ax = 0.01

    if ay > 0.01 or ay < 0.01:
        ay = 0.01

    color("hsl(%d,100%%,50%%)" % hue)

    hue += 1

    spot(x, y, 8)
    vx = vx + ax
    vy = vy + ay

    x = x + vx
    y = y + vy
    if x > screen_width:
        vx = vx * -1

    if y > screen_height:
        vy = vy * -1

    if x < 0:
        vx = vx * -1

    if y < 0:
        vy = vy * -1

    color("hsl(%d,100%%,50%%)" % hue)

    spot(x, y, 8)
Пример #45
0
def handle_mouseup(x, y):
    color("blue")
    spot(x, y, 10)
Пример #46
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

from tealight.art import (screen_width, screen_height)

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

Пример #47
0
from tealight.art import (color, line, spot, circle, box, image, text, background)

color("blue")

spot(100,200,50)
circle(300,200,50)
box(450,150,100,100)
Пример #48
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

color("blue")

spot(300, 200, 25)
circle(300, 200, 50)
box(250, 250, 100, 100)
Пример #49
0
def DrawMark(x,y):
  color('blue')
  spot(x, y, 10, 10)
Пример #50
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

color("blue")

spot(300, 200, 20)
circle(300, 200, 50)
box(250, 150, 100, 100)
Пример #51
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

color("blue")

spot(300, 200, 30)
circle(300, 200, 50)
box(250, 300, 100, 100)
Пример #52
0
color("white")
box(180,200,546,546)

x = 182
y = 202

for Ycounter in range(0,16):
  for Xcounter in range(0,16):
    color("grey")
    box(x,y,32,32)
    x = x + 34
  y = y + 34
  x = 182

color("black")
spot(231,354,10)

color("white")
spot(227,349,2)

color("black")
line(231,342,231,339)

color("black")
line(231,366,231,369)

color("black")
line(242,354,245,354)

color("black")
line(220,354,217,354)
Пример #53
0
from tealight.art import (color, line, spot, circle, box, image, text, background)

color("blue")

spot(300,200,45)
circle(300,200,50)
box(250,150,100,100)
Пример #54
0
def ToolBoxThickness(x, y, thicknesses, w, h):
    for t in thicknesses:
        spot(x + w / 2, y + h / 2, t)
        rectangle(x, y, w, h)
        y = y + h
Пример #55
0
 def draw(self):
     color("red")
     spot(self.x, self.y, 25)
Пример #56
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

color("blue")

spot(300, 200, 50)
circle(300, 200, 50)
box(250, 300, 100, 100)
Пример #57
0
 def draw(self):
   spot(self.x, self.y, 25)
Пример #58
0
from tealight.art import (color, line, spot, circle, box, image, text, background)

color("blue")

spot(300,200,40)
circle(300,200,50)
box(250,250,100,100)