-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallange_accepted.py
76 lines (63 loc) · 2.13 KB
/
challange_accepted.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
72
73
74
75
76
import socket
import sys
import pygame
pygame.init()
from hardcoded import Layout
import images
from client import *
from parent_server import GameServer
FPS = 60
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
def check_for_internet_conection():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(('8.8.8.8', 0))
return s.getsockname()[0]
except OSError:
return None
def init_graphics():
logo = pygame.transform.scale(images.images["logo"], (32, 32))
pygame.display.set_icon(logo)
pygame.display.set_caption("Challenge Accepted", "Challenge Accepted")
# if __name__ == "__main__":
#
# s = GameServer(localaddr=('10.0.201.111', 22022))
# s.current_game = kick_ball.Game(5)
# s.Launch()
# host = '10.0.201.111'
# port = 22022
# c = Client(host, int(port))
ingame = False
LAYOUTS = Layout.load_layouts()
current_left_layout = "start"
current_right_layout = None
def start_conntrol():
if LAYOUTS[current_left_layout].connect_to_server_button.clicked:
globals()["current_right_layout"] = "connect_to_server"
if LAYOUTS[current_left_layout].connect_to_server_button.clicked:
globals()["current_right_layout"] = "create_server"
if LAYOUTS[current_left_layout].connect_to_server_button.clicked:
sys.exit()
def start_server_controll():
if LAYOUTS[current_left_layout].connect_to_server_button.clicked:
globals()["current_left_layout"] = "game"
globals()["current_right_layout"] = None
if __name__ == "__main__":
init_graphics()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
while True:
events = pygame.event.get()
if ingame:
continue
else:
screen.fill((55, 155, 255))
if current_left_layout is not None:
LAYOUTS[current_left_layout].update_elements(events)
LAYOUTS[current_left_layout].draw(screen)
if current_right_layout is not None:
LAYOUTS[current_right_layout].update_elements(events)
LAYOUTS[current_right_layout].draw(srceen)
pygame.display.update()
# c.Loop()
# sleep(0.01)