-
Notifications
You must be signed in to change notification settings - Fork 3
/
Ping.py
64 lines (45 loc) · 1.43 KB
/
Ping.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
try:
import cfg
if cfg.DEBUG_MODE:
from master import pg
from master import go
from master import gi
import defs as df
except ModuleNotFoundError:
import game.PingPongRebound.cfg as cfg
from game.PingPongRebound.master import go
from game.PingPongRebound.master import gi
import game.PingPongRebound.defs as df
class Ping( gi.Game ):
type = "Ping"
divide_sides = True
score_mode = df.GOALS
width = 2048
height = 1024
size_f = 768
factor_rack = 0.9
factor_wall = 0.6
gravity = 0.333
racket_count = 2
score_count = 2
iPosR1 = ( int( width * ( 1 / 3 )), int( height - gi.Game.size_b ), "x" )
iPosR2 = ( int( width * ( 2 / 3 )), int( height - gi.Game.size_b ), "x" )
iPosB1 = ( int( width * ( 1 / 2 )), int( height * ( 1 / 4 )))
posS1 = ( int( width * ( 1 / 2 )), int( height * ( 1 / 4 )), 1, 1, -1, -1)
posS2 = ( int( width * ( 1 / 2 )), int( height * ( 1 / 4 )), 1, 1, 1, -1)
posN1 = ( int( width * ( 1 / 4 )), int( height * ( 1 / 2 )))
posN2 = ( int( width * ( 3 / 4 )), int( height * ( 1 / 2 )))
lines = [
[( 0.5, 0 ), ( 0.5, 1 ), 1 ],
[( 0, 0 ), ( 0, 1 ), 2 ],
[( 1, 0 ), ( 1, 1 ), 2 ],
[( 0, 0 ), ( 1, 0 ), 2 ]]
def checkGoals( self, ball ):
if ball.getBottom() > self.height:
# checking who scored
if ball.getPosX() <= self.width / 2:
self.ballEvent( ball, df.GOALS, 2 )
else:
self.ballEvent( ball, df.GOALS, 1 )
if self.connector != None:
self.connector.update_scores( self.scores )