-
Notifications
You must be signed in to change notification settings - Fork 4
/
Paint.py
155 lines (133 loc) · 6.11 KB
/
Paint.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#Canvas
import bs
import random
def bsGetAPIVersion():
return 4
def bsGetGames():
return [Paint]
def bsGetLevels():
return [bs.Level('Paint',
displayName='${GAME}',
gameType=Paint,
settings={},
previewTexName='courtyardPreview')]
class Dot(bs.Actor):
def __init__(self, position=(0,0,0), color=(0,0,0), radius=(.5)):
bs.Actor.__init__(self)
self._r1 = radius
if radius < 0: self._r1 = 0
self.position = position
self.color = color
n1 = bs.newNode('locator',attrs={'shape':'circle','position':position,
'color':self.color,'opacity':1,
'drawBeauty':True,'additive':True})
bs.animateArray(n1,'size',1,{0:[0.0],200:[self._r1*2.0]})
self._node = [n1]
class Artist(bs.PlayerSpaz):
def __init__(self, color=(1,1,1), highlight=(0.5,0.5,0.5), character="Spaz", sourcePlayer=None, startInvincible=True,
canAcceptPowerups=True, powerupsExpire=False, demoMode=False):
self._player = sourcePlayer
self.mode = 'Draw'
self.dotRadius = .5
self.red = True
self.blue = True
self.green = True
self.value = 1
self.color = [1.0,0.0,0.0]
bs.PlayerSpaz.__init__(self, color, highlight, character, sourcePlayer, powerupsExpire)
def onBombPress(self):
if self.mode == 'Draw':
self.dotRadius += .1
self.setScoreText("Radius: " + str(self.dotRadius), (1,1,1))
elif self.mode == "Color":
if self.color[0] >= 1:
if self.color[2] == 0: self.color[1] += .1
else: self.color[2] -= .1
if self.color[1] >= 1:
if self.color[0] == 0: self.color[2] += .1
else: self.color[0] -= .1
if self.color[2] >= 1:
if self.color[1] == 0: self.color[0] += .1
else: self.color[1] -= .1
for i in range(len(self.color)):
if self.color[i] < 0: self.color[i] = 0
if self.color[i] > 1: self.color[i] = 1
color = (self.color[0]*self.value, self.color[1]*self.value, self.color[2]*self.value)
self.setScoreText("COLOR", color)
def onPunchPress(self):
if self.mode == 'Draw':
self.dotRadius -= .1
if self.dotRadius < .05: self.dotRadius = 0
self.setScoreText("Radius: " + str(self.dotRadius), (1,1,1))
elif self.mode == "Color":
if self.color[0] >= 1:
if self.color[1] == 0: self.color[2] += .1
else: self.color[1] -= .1
if self.color[1] >= 1:
if self.color[2] == 0: self.color[0] += .1
else: self.color[2] -= .1
if self.color[2] >= 1:
if self.color[0] == 0: self.color[1] += .1
else: self.color[0] -= .1
for i in range(len(self.color)):
if self.color[i] < 0: self.color[i] = 0
if self.color[i] > 1: self.color[i] = 1
color = (self.color[0]*self.value, self.color[1]*self.value, self.color[2]*self.value)
self.setScoreText("COLOR", color)
def onJumpPress(self):
if self.mode == 'Draw':
color = (self.color[0]*self.value, self.color[1]*self.value, self.color[2]*self.value)
pos = (self.node.positionCenter[0], self.node.positionCenter[1]-2, self.node.positionCenter[2])
dot = Dot(position=pos, color = color, radius=self.dotRadius)
elif self.mode == "Color":
self.value += .1
if self.value > 1 : self.value = 0
self.setScoreText("Value: " + str(round(self.value,2)), (self.color[0]*self.value, self.color[1]*self.value, self.color[2]*self.value))
def onPickUpPress(self):
if self.mode == 'Draw': self.mode = 'Color'
elif self.mode == "Color": self.mode = "Draw"
self.setScoreText(self.mode + " Mode", (1,1,1))
class Paint(bs.CoopGameActivity):
@classmethod
def getName(cls):
return 'Paint'
@classmethod
def getScoreInfo(cls):
return {'scoreType':'points'}
@classmethod
def getDescription(cls,sessionType):
return 'Create a masterpiece.'
@classmethod
def getSupportedMaps(cls,sessionType):
return ['Doom Shroom']
@classmethod
def supportsSessionType(cls,sessionType):
return True if issubclass(sessionType,bs.CoopSession) else False
def __init__(self, settings):
bs.CoopGameActivity.__init__(self, settings)
self.info = bs.NodeActor(bs.newNode('text',
attrs={'vAttach': 'bottom',
'hAlign': 'center',
'vrDepth': 0,
'color': (0,.2,0),
'shadow': 1.0,
'flatness': 1.0,
'position': (0,0),
'scale': 0.8,
'text': "Created by MattZ45986 on Github",
}))
def onTransitionIn(self):
bs.CoopGameActivity.onTransitionIn(self,music='ForwardMarch')
def onBegin(self):
bs.CoopGameActivity.onBegin(self)
def spawnPlayerSpaz(self,player,position=(0,5,-3),angle=None):
name = player.getName()
color = player.color
highlight = player.highlight
spaz = Artist(color=color,
highlight=highlight,
character=player.character,
sourcePlayer=player)
player.setActor(spaz)
player.actor.connectControlsToPlayer()
spaz.handleMessage(bs.StandMessage((0,3,0),90))