예제 #1
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    send({"x1": lastx, "y1": lasty, "x2": x, "y2": y}, True)
    lastx = x
    lasty = y
예제 #2
0
def handle_mouseup(x, y):
    global turn, columnCounter
    i = -1
    if 50 < x <= 150:
        i = 0
    elif 150 < x <= 250:
        i = 1
    elif 250 < x <= 350:
        i = 2
    elif 350 < x <= 450:
        i = 3
    elif 450 < x <= 550:
        i = 4
    elif 550 < x <= 650:
        i = 5
    elif 650 < x <= 750:
        i = 6
    elif 750 < x <= 850:
        i = 7
    elif x < 50:
        i = 0

    if turn == 1:
        None
    elif turn == 0:
        color("yellow")

    if i <= 7 and columnCounter[i] < 8:
        DrawSpot(i, columnCounter[i], turn)
        win(turn, posArray)
        message = [columnCounter, posArray, turn]
        send(message, False)
        turn = (turn + 1) % 2
예제 #3
0
def handle_mouseup(x, y):
  global turn, columnCounter
  i = -1
  if 50 < x <= 150:
    i = 0
  elif 150 < x <= 250:
    i = 1
  elif 250 < x <= 350:
    i = 2
  elif 350 < x <= 450:
    i = 3
  elif 450 < x <= 550:
    i = 4
  elif 550 < x <= 650:
    i = 5
  elif 650 < x <= 750:
    i = 6
  elif 750 < x <= 850:
    i = 7
  elif x < 50:
    i = 0
    
  if turn == 1:
    None
  elif turn ==0:
    color("yellow")
    
  if i <= 7 and columnCounter[i] < 8:
    DrawSpot(i, columnCounter[i], turn)
    win(turn, posArray)
    message = [columnCounter, posArray, turn]
    send(message, False)
    turn = (turn + 1) % 2
예제 #4
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        line(lastx, lasty, x, y)
        send({"x1": lastx, "y1": lasty, "x2": x, "y2": y})
        lastx = x
        lasty = y
예제 #5
0
def handle_mousemove(x, y, button):
    global lastx, lasty
    if button == "left":
        color(chosen_color)
        line(lastx, lasty, x, y)
        send({
            "type": "line",
            "x1": lastx,
            "y1": lasty,
            "x2": x,
            "y2": y,
            "color": chosen_color
        })
        lastx = x
        lasty = y
예제 #6
0
columnCounter = [0, 0, 0, 0, 0, 0, 0, 0]

counter = 0

x1 = 100
y1 = 900
x2 = 150
y2 = 950
x3 = 50
y3 = 850

turn = 0

message = [columnCounter, posArray, turn]

send(message, False)


def handle_message(message):
    global counter
    columnCounter = message[0]
    posArray = message[1]
    turn = message[2]

    for y in range(0, 8):
        for x in range(0, 8):
            if posArray[y][x] == 1:
                color("yellow")
                spot(xArray[x], yArray[y], 40)
            elif posArray[y][x] == 2:
                color("red")
예제 #7
0
from tealight.net import(connect, send)

connect('Dinosaurs.py')
message = "Meerkat"
send(message)

def handle_message(message):
  print "You have one message: " + str(message)
예제 #8
0
def authenticated_send(data, to, type):
  data = {"to": to, "type": type, "payload": data, "user_id": userId}
  send(data)
  print "Just sent", data
예제 #9
0
from tealight.net import connect, send
import tealight.utils
import random
userId= int(tealight.utils.now()) +random.randint(0,1000000)
connect("racetracksix")
send("connected")
#def regisrtation_handler(message):
  #for i in range (0, carNumber):
  #call draw car function and increment placement
  #horizontally? also change colour
def authenticated_send(data, to, type):
  data = {"to": to, "type": type, "payload": data, "user_id": userId}
  send(data)
  print "Just sent", data
  
  
authenticated_send(userId, "server", "registration")

authenticated_send(tealight.utils.now(), "server", "heartbeat")
def client_handle_frame():
  authenticated_send(tealight.utils.now(), "server", "heartbeat")
  lastSent = tealight.utils.now()
예제 #10
0
def handle_mousemove(x,y):
  go(x,y)
  send(pos)
def fill(colour):
  color(colour)
  for x in range(screen_width):
    line(x, 0, x, screen_height)
    send({"x1": x, "y1": 0, "x2": x, "y2": screen_height})
예제 #12
0
from tealight.net import connect, send
connect("networkfiddle2")
send ('hi' )
def handle_message(message):
  print message
  
예제 #13
0
def handle_mousemove(x,y):
  print "MM"
  send({"x":x, "y":y}, True)
예제 #14
0
from tealight.net import connect, send

def handle_connected():
  print "Connected"
  
def handle_message(message):
  print "Message!"
  
  print message["x"]

def handle_mousemove(x,y):
  print "MM"
  send({"x":x, "y":y}, True)

connect("net_test")
send({"x":1, "y":2})
예제 #15
0
columnCounter = [0, 0, 0, 0, 0, 0, 0, 0]

counter = 0

x1 = 100
y1 = 900
x2 = 150
y2 = 950
x3 = 50
y3 = 850

turn = 0

message = [columnCounter, posArray, turn]
          
send(message, False)

def handle_message(message):
  global counter
  columnCounter = message[0]
  posArray = message[1]
  turn = message[2]
    
  for y in range(0, 8):
    for x in range(0, 8):
      if posArray[y][x] == 1:
        color("yellow")
        spot(xArray[x], yArray[y], 40)
      elif posArray[y][x] == 2:
        color("red")
        spot(xArray[x], yArray[y], 40)
예제 #16
0
def fill(colour):
    color(colour)
    for x in range(screen_width):
        line(x, 0, x, screen_height)
        send({"x1": x, "y1": 0, "x2": x, "y2": screen_height})
예제 #17
0
def handle_mousedown(x,y,button):
  global stopMinX, stopMaxX, stopMinY, stopMaxY
  if inBox(stopMinX,stopMaxX,stopMinY,stopMaxY,x,y) == "true":
    send({"type": "stop"})