Skip to content

Commit

Permalink
Add comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Secret-chest committed Dec 30, 2022
1 parent 95fd305 commit 81203c0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions block.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
decimals = decimals2
self.value = random.randint(int(self.getInputValue("from")) * 10 ** decimals, int(self.getInputValue("to")) * 10 ** decimals) / 10 ** decimals
return self.value
elif self.opcode == "operator_equals": # () = ()
self.value = self.getInputValue("operand1") == self.getInputValue("operand2")
return self.value
elif self.opcode == "operator_lt": # () < ()
self.value = self.getInputValue("operand1") < self.getInputValue("operand2")
return self.value
elif self.opcode == "operator_gt": # () > ()
self.value = self.getInputValue("operand1") > self.getInputValue("operand2")
return self.value
elif self.opcode == "motion_xposition": # x position
self.value = self.target.x
return self.value
Expand All @@ -81,18 +90,21 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
newX, newY = pygame.mouse.get_pos()
newX = newX - config.screenWidth // 2
self.value = newX
return newX
return self.value
elif self.opcode == "sensing_mousey": # mouse y
newX, newY = pygame.mouse.get_pos()
newY = newY - config.screenWidth // 2
self.value = newY
return newY
return self.value
elif self.opcode == "sensing_keypressed": # key pressed?
return KEY_MAPPING[self.getMenuValue("key_option")] in eventContainer.keys
self.value = KEY_MAPPING[self.getMenuValue("key_option")] in eventContainer.keys
return self.value
elif self.opcode == "operator_not": # not <>
return not self.target.blocks[self.getBlockInputValue("operand")].evaluateBlockValue(eventContainer)
self.value = not self.target.blocks[self.getBlockInputValue("operand")].evaluateBlockValue(eventContainer)
return self.value
elif self.opcode == "sensing_mousedown": # mouse down?
return pygame.mouse.get_pressed()[0]
self.value = pygame.mouse.get_pressed()[0]
return self.value

# Returns block input value
def getBlockInputValue(self, inputId):
Expand Down

0 comments on commit 81203c0

Please sign in to comment.