#By: Huseyin Ergisi, Ryan Gregory, Andrew Jeffery #GitHub: huseyinergisi, Rhino5651, TheAIAJ from tealight.art import * from tealight.net import connect, send connect("Connect4Multi") ####Variables#### font("80px Arial") text(275, 1030, "Connect 4") color("blue") box(50, 950, 800, -800) xArray = [100, 200, 300, 400, 500, 600, 700, 800] yArray = [900, 800, 700, 600, 500, 400, 300, 200] posArray = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] columnCounter = [0, 0, 0, 0, 0, 0, 0, 0] counter = 0 x1 = 100 y1 = 900 x2 = 150 y2 = 950 x3 = 50 y3 = 850
#By: Huseyin Ergisi, Ryan Gregory, Andrew Jeffery #GitHub: huseyinergisi, Rhino5651, TheAIAJ from tealight.art import * from tealight.net import connect, send connect("Connect4Multi") ####Variables#### font("80px Arial") text(275,1030,"Connect 4") color("blue") box(50,950,800,-800) xArray = [100, 200, 300, 400, 500, 600, 700, 800] yArray = [900, 800, 700, 600, 500, 400, 300, 200] posArray = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 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
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()
from tealight.net import(connect, send) connect('Dinosaurs.py') message = "Meerkat" send(message) def handle_message(message): print "You have one message: " + str(message)
from tealight.art import (color, line, spot, circle, box, image, text, background) from math import floor from tealight.art import (screen_width, screen_height) from github.amyble.art.toolbar import * from github.amyble.art.word import * from github.amyble.art.correct import * from tealight.net import connect, send connect("pictionary") global chosen_color chosen_color = "red" def initialPlayer2(): color("white") box(0, 0, screen_width, screen_height) color("black") #if (x < (len(palette)*25) and x > 10) and ((y > 35) and (y < 60)): # chosen_colour = palette[int(floor((x-10)/25))] def getChosen(startX,startY,currentX,currentY,length): if (currentX < (length*25) and currentX > startX) and ((currentY > startY) and (currentY < (startY+25))): return int(floor((currentX-startX)/25)) else: return "no"
from tealight.art import (color, line, spot, circle, box, image, text, background, screen_width, screen_height) from tealight.net import connect, send lastx = 0 lasty = 0 color("blue") connect("shared_whiteboard") 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}) def handle_mousedown(x, y): global lastx, lasty lastx = x lasty = y def handle_mousemove(x, y, button): global lastx, lasty if button == "left": line(lastx, lasty, x, y)
from tealight.art import (color, line, spot, circle, box, image, text, background, screen_width, screen_height) from tealight.net import connect, send lastx = 0 lasty = 0 color("blue") connect("shared_whiteboard") 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}) def handle_mousedown(x,y): global lastx, lasty lastx = x lasty = y 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
from tealight.net import connect, send connect("chat.py") def handle_message(message): print "recieved message" + message
from tealight.net import connect, send connect ("networkfiddle2") def handle_message(message): print message
from github.amyble.art.toolbar import * from github.amyble.art.word import * from tealight.net import connect, send global stopCount def inBox(boundXMin, boundXMax, boundYMin, boundYMax, x, y): if ((x > boundXMin) and (x < boundXMax)) and ((y > boundYMin) and (y < boundYMax)): return "true" else: return "false" stopCount = "false" connect("pictionary") palette = ["red", "blue", "green", "purple", "yellow", "black", "pink", "grey"] global chosen_color chosen_color = "red" def reset(): color("white") box(0, 0, screen_width, screen_height) color("black") def initialPlayer1(): reset()
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})
from tealight.net import connect, send from tealight.utils import age connect("myapp") def handle_message(msg): print "Received: " + msg print age()
from math import sqrt def go(x,y): line(pos["x"], pos["y"], x,y) pos["x"] = x pos["y"] = y def handle_mousemove(x,y): go(x,y) send(pos) def handle_message(message): go(message["x"], message["y"]) connect("my_thing") data = [1,1] for i in range(0,10): data.append(data[-2] + data[-1]) print data def factorise(n): for i in range(2, int(sqrt(n))+1): if n % i == 0: print i factorise(n / i)