-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.py
35 lines (28 loc) · 1.05 KB
/
events.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
import sys
import pygame
from pygame.locals import *
from controls import PCControls
from globalvars import *
class PCEvents(PCControls):
def __init__(self):
self.ctrls = PCControls()
def handle(self, screen, netw):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.exit()
if not get_clikd_btn() and event.type == MOUSEBUTTONDOWN:
set_clikd_btn(self.ctrls.button_clicked(event.pos))
if event.type == KEYDOWN:
if event.key == pygame.K_c and \
pygame.key.get_mods() & pygame.KMOD_CTRL:
self.exit()
if (get_clikd_btn() == 'cam' and not (
get_possock() or get_camsock())):
netw.connect_to_server()
set_clikd_btn(None)
if (get_clikd_btn() == 'dc' and (
get_possock() or get_camsock())):
netw.disconnect_from_server()
set_clikd_btn(None)
def exit(self):
sys.exit()