Skip to content

Commit 81203c0

Browse files
committed
Add comparison operators
1 parent 95fd305 commit 81203c0

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

block.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
7171
decimals = decimals2
7272
self.value = random.randint(int(self.getInputValue("from")) * 10 ** decimals, int(self.getInputValue("to")) * 10 ** decimals) / 10 ** decimals
7373
return self.value
74+
elif self.opcode == "operator_equals": # () = ()
75+
self.value = self.getInputValue("operand1") == self.getInputValue("operand2")
76+
return self.value
77+
elif self.opcode == "operator_lt": # () < ()
78+
self.value = self.getInputValue("operand1") < self.getInputValue("operand2")
79+
return self.value
80+
elif self.opcode == "operator_gt": # () > ()
81+
self.value = self.getInputValue("operand1") > self.getInputValue("operand2")
82+
return self.value
7483
elif self.opcode == "motion_xposition": # x position
7584
self.value = self.target.x
7685
return self.value
@@ -81,18 +90,21 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
8190
newX, newY = pygame.mouse.get_pos()
8291
newX = newX - config.screenWidth // 2
8392
self.value = newX
84-
return newX
93+
return self.value
8594
elif self.opcode == "sensing_mousey": # mouse y
8695
newX, newY = pygame.mouse.get_pos()
8796
newY = newY - config.screenWidth // 2
8897
self.value = newY
89-
return newY
98+
return self.value
9099
elif self.opcode == "sensing_keypressed": # key pressed?
91-
return KEY_MAPPING[self.getMenuValue("key_option")] in eventContainer.keys
100+
self.value = KEY_MAPPING[self.getMenuValue("key_option")] in eventContainer.keys
101+
return self.value
92102
elif self.opcode == "operator_not": # not <>
93-
return not self.target.blocks[self.getBlockInputValue("operand")].evaluateBlockValue(eventContainer)
103+
self.value = not self.target.blocks[self.getBlockInputValue("operand")].evaluateBlockValue(eventContainer)
104+
return self.value
94105
elif self.opcode == "sensing_mousedown": # mouse down?
95-
return pygame.mouse.get_pressed()[0]
106+
self.value = pygame.mouse.get_pressed()[0]
107+
return self.value
96108

97109
# Returns block input value
98110
def getBlockInputValue(self, inputId):

0 commit comments

Comments
 (0)