Skip to content

Commit 88703f9

Browse files
committed
Support for move steps block
1 parent afda389 commit 88703f9

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

assets/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"targets":[{"isStage":true,"name":"Stage","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"name":"xy-grid","bitmapResolution":1,"dataFormat":"svg","assetId":"4851f7b71585efa5d42cb3a0b2d5fadf","md5ext":"4851f7b71585efa5d42cb3a0b2d5fadf.svg","rotationCenterX":239.99996948242188,"rotationCenterY":180.00003051757812}],"sounds":[],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Cat 2","variables":{},"lists":{},"broadcasts":{},"blocks":{"?^q)qSDL?G9M_{|/iKKo":{"opcode":"event_whenflagclicked","next":"}l[bKZnw-AEF;s1PwWnH","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":300,"y":340},"}l[bKZnw-AEF;s1PwWnH":{"opcode":"control_forever","next":null,"parent":"?^q)qSDL?G9M_{|/iKKo","inputs":{"SUBSTACK":[2,"*p+AjP1@8x!|)0=-WRd0"]},"fields":{},"shadow":false,"topLevel":false},"*p+AjP1@8x!|)0=-WRd0":{"opcode":"motion_pointindirection","next":"GTgrP{t^I,0POk;iBL2|","parent":"}l[bKZnw-AEF;s1PwWnH","inputs":{"DIRECTION":[3,"_:Fh9,Ie4..HS/zo)#Tf",[8,"90"]]},"fields":{},"shadow":false,"topLevel":false},"_:Fh9,Ie4..HS/zo)#Tf":{"opcode":"operator_random","next":null,"parent":"*p+AjP1@8x!|)0=-WRd0","inputs":{"FROM":[1,[4,"-180"]],"TO":[1,[4,"180"]]},"fields":{},"shadow":false,"topLevel":false},"GTgrP{t^I,0POk;iBL2|":{"opcode":"control_wait","next":null,"parent":"*p+AjP1@8x!|)0=-WRd0","inputs":{"DURATION":[1,[5,"0.5"]]},"fields":{},"shadow":false,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"name":"cat 2","bitmapResolution":1,"dataFormat":"svg","assetId":"b19faf9c49fb425c52756c2b229f08cb","md5ext":"b19faf9c49fb425c52756c2b229f08cb.svg","rotationCenterX":128.79883,"rotationCenterY":36.221843067841604}],"sounds":[{"name":"meow2","assetId":"cf51a0c4088942d95bcc20af13202710","dataFormat":"wav","format":"","rate":44100,"sampleCount":26048,"md5ext":"cf51a0c4088942d95bcc20af13202710.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":-150,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"1.5.68","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"}}
1+
{"targets":[{"isStage":true,"name":"Stage","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"name":"xy-grid","bitmapResolution":1,"dataFormat":"svg","assetId":"4851f7b71585efa5d42cb3a0b2d5fadf","md5ext":"4851f7b71585efa5d42cb3a0b2d5fadf.svg","rotationCenterX":239.99996948242188,"rotationCenterY":180.00003051757812}],"sounds":[],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Cat 2","variables":{},"lists":{},"broadcasts":{},"blocks":{"?^q)qSDL?G9M_{|/iKKo":{"opcode":"event_whenflagclicked","next":"E-Dyij3.{[^4A?fod0s!","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":-220,"y":100},"E-Dyij3.{[^4A?fod0s!":{"opcode":"motion_gotoxy","next":"lnSU9#[EImmaQJ||MBIw","parent":"?^q)qSDL?G9M_{|/iKKo","inputs":{"X":[1,[4,"0"]],"Y":[1,[4,"0"]]},"fields":{},"shadow":false,"topLevel":false},"lnSU9#[EImmaQJ||MBIw":{"opcode":"motion_pointindirection","next":"}l[bKZnw-AEF;s1PwWnH","parent":"E-Dyij3.{[^4A?fod0s!","inputs":{"DIRECTION":[1,[8,"90"]]},"fields":{},"shadow":false,"topLevel":false},"}l[bKZnw-AEF;s1PwWnH":{"opcode":"control_forever","next":null,"parent":"lnSU9#[EImmaQJ||MBIw","inputs":{"SUBSTACK":[2,"x!I9(wZUPzO#C0bre9l6"]},"fields":{},"shadow":false,"topLevel":false},"A4WYwk!9Dx[W~4$:K!w!":{"opcode":"motion_movesteps","next":"_oV}B!t/:TwFCWcM!j^u","parent":"x!I9(wZUPzO#C0bre9l6","inputs":{"STEPS":[1,[4,"15"]]},"fields":{},"shadow":false,"topLevel":false},"_oV}B!t/:TwFCWcM!j^u":{"opcode":"motion_turnright","next":null,"parent":"A4WYwk!9Dx[W~4$:K!w!","inputs":{"DEGREES":[1,[4,"15"]]},"fields":{},"shadow":false,"topLevel":false},"x!I9(wZUPzO#C0bre9l6":{"opcode":"control_wait","next":"A4WYwk!9Dx[W~4$:K!w!","parent":"}l[bKZnw-AEF;s1PwWnH","inputs":{"DURATION":[1,[5,"0.25"]]},"fields":{},"shadow":false,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"name":"cat 2","bitmapResolution":1,"dataFormat":"svg","assetId":"b19faf9c49fb425c52756c2b229f08cb","md5ext":"b19faf9c49fb425c52756c2b229f08cb.svg","rotationCenterX":128.79883,"rotationCenterY":36.221843067841604}],"sounds":[{"name":"meow2","assetId":"cf51a0c4088942d95bcc20af13202710","dataFormat":"wav","format":"","rate":44100,"sampleCount":26048,"md5ext":"cf51a0c4088942d95bcc20af13202710.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"1.5.68","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"}}

block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def getBlockInputValue(self, inputId):
124124

125125
# Returns block input value
126126
def getInputValue(self, inputId, lookIn=(1, 1), eventContainer=eventContainer.EventContainer()):
127-
if self.inputs[inputId.upper()][lookIn[0]][0] in {4, 0, 5, 6}:
127+
if self.inputs[inputId.upper()][lookIn[0]][0] in {4, 0, 5, 6, 8}:
128128
return self.inputs[inputId.upper()][lookIn[0]][1] or 0
129129
elif self.inputs[inputId.upper()][0] == 3:
130130
blockLink = self.inputs[inputId.upper()][1]

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Project file name
2626
# If in test mode, set the Scratch project file to load.
27-
projectFileName: str = "projects/AbsoluteRotation.sb3"
27+
projectFileName: str = "projects/MoveSteps.sb3"
2828

2929
# Download cache size
3030
# Number of recent downloaded projects stored. 0 means infinity.

projects/MoveSteps.sb3

-11.7 KB
Binary file not shown.

scratch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ def execute(block, s, events=eventContainer.EventContainer()):
255255
elif opcode == "motion_pointindirection": # point in direction ()
256256
s.setRot(float(block.getInputValue("direction", eventContainer=events)))
257257

258+
elif opcode == "motion_movesteps": # move () steps
259+
offset = pygame.math.Vector2(float(block.getInputValue("steps", eventContainer=events)), 0)
260+
offset.rotate_ip(90 + s.direction)
261+
s.setXyDelta(-offset.x, -offset.y)
262+
258263
elif opcode == "control_wait": # wait () seconds
259264
block.screenRefresh = True
260265
if not block.waiting:

targetSprite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def setXy(self, x, y):
8181
y = scratch.HEIGHT / 2 + self.rect.height / 2 - 16
8282
elif y < scratch.HEIGHT / -2 - self.rect.height / 2 + 16:
8383
y = scratch.HEIGHT / -2 - self.rect.height / 2 + 16
84+
85+
# TODO make fencing compatible with rotation centre
8486
self.x = x
8587
self.y = y
8688
# print(_("debug-prefix"), _("new-sprite-position", x=x, y=y, name=self.name), file=sys.stderr)

0 commit comments

Comments
 (0)