-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.py
executable file
·72 lines (61 loc) · 2 KB
/
load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from EDsend import *
import pygame
from pygame.locals import *
from multicasting import *
import time
channel="DREAM_CAST"
class start(multicast):
def __init__(self):
super(start,self).__init__(timeout)
self.stream_message=[]
try:
self.discover_bcast_mesg()
except ConnectingError as c:
logging.info("\n ConnectingError has occured ")
print "Displaying the Player's uuid and ip "
for keys in self.players_uids:
print keys,':',self.players_uids[keys]
print '****************************************'
logging.info("Initialising Screen :D")
pygame.init()
self.scr=pygame.display.set_mode((700,700))
pygame.display.set_caption('Project Tic-Tac toe')
self.load=pygame.image.load('loading.png').convert()
self.scr.blit(self.load,(0,0))
pygame.display.flip()
self.join_game()
def join_game(self):
global channel
which_player=raw_input('Choose Player name: ')#since all the comps are goint to be together,players can discuss amongst themselves and discuss which player no they want
id=which_player[-1]
string=self.uid+' '+id
self.players_ids[self.uid]=id
try:
self.communication(string)
except ConnectingError as c:
if c.val==2:
print c.mesg
pass
self.load=pygame.Surface((700,300))
self.load=self.load.convert()
self.load.fill((250,250,250))
#pygame.display.flip()
self.coordinate1=350
self.coordinate2=20
#INITIALISING FONTS ---PYGAME
font=pygame.font.Font(None,24)
if self.channel=="DREAM_CAST":
print 'displaying the uids and player ids\n'
for keys in self.players_ids:
print keys,':',self.players_ids[keys]
text=font.render("{0}:{1} @ channel:DREAM_CAST".format(keys,self.players_ids[keys]),1,(0,0,255))
textpos=text.get_rect(center=(self.coordinate1,self.coordinate2))
self.coordinate2+=50
textpos.centerx=self.load.get_rect().centerx
self.load.blit(text,textpos)
self.scr.blit(self.load,(0,0))
pygame.display.flip()
time.sleep(2)
def __del__(self):
self.close()
logging.info("Closing socket")