Skip to content

Commit

Permalink
Add diagonal bouncing ball example
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroldo de Oliveira Pinheiro committed Oct 26, 2024
1 parent 36ef602 commit bb0897f
Showing 1 changed file with 272 additions and 1 deletion.
273 changes: 272 additions & 1 deletion src/components/blockly-toolbox-ball-movement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,277 @@
</category>

<category name="Diagonally bouncing ball" colour="#ff8800">
<block type="controls_if">
<value name="IF0">
<block type="logic_negate">
<value name="BOOL">
<block type="variables_get">
<field name="VAR">Ball Y Speed</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables_set">
<field name="VAR">Ball X Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR">Ball Y Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<next>
<block type="sprite_ball_set">
<field name="VAR">ballx</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">80</field>
</shadow>
</value>
<next>
<block type="sprite_ball_set">
<field name="VAR">bally</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">64</field>
</shadow>
</value>
<next>
<block type="sprite_ball_set">
<field name="VAR">ballheight</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">3</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
<next>
<block type="controls_if">
<mutation else="1"></mutation>
<value name="IF0">
<block type="variables_get">
<field name="VAR">Even Frame</field>
</block>
</value>
<statement name="DO0">
<block type="variables_set">
<field name="VAR">Even Frame</field>
<value name="VALUE">
<block type="logic_boolean">
<field name="BOOL">FALSE</field>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set">
<field name="VAR">Even Frame</field>
<value name="VALUE">
<block type="logic_boolean">
<field name="BOOL">TRUE</field>
</block>
</value>
</block>
</statement>
<next>
<block type="controls_if">
<mutation else="1"></mutation>
<value name="IF0">
<block type="variables_get">
<field name="VAR">Even Frame</field>
</block>
</value>
<statement name="DO0">
<block type="controls_if">
<value name="IF0">
<block type="collision_get">
<field name="VAR0">ball</field>
<field name="VAR1">playfield</field>
</block>
</value>
<statement name="DO0">
<block type="simple_sound_set">
<field name="AUDC">1</field>
<field name="AUDF">16</field>
<field name="AUDV">7</field>
<field name="DURATION">5</field>
<field name="CHANNEL">0</field>
<next>
<block type="controls_if">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_compare">
<field name="OP">EQ</field>
<value name="A">
<block type="variables_get">
<field name="VAR">Ball Y Speed</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables_set">
<field name="VAR">Ball Y Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set">
<field name="VAR">Ball Y Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</statement>
<next>
<block type="sprite_ball_change">
<field name="VAR">bally</field>
<value name="DELTA">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="variables_get">
<field name="VAR">Ball Y Speed</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
<next>
<block type="sprite_ball_change">
<field name="VAR">ballx</field>
<value name="DELTA">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="variables_get">
<field name="VAR">Ball X Speed</field>
</block>
</value>
</block>
</next>
</block>
</statement>
<statement name="ELSE">
<block type="controls_if">
<value name="IF0">
<block type="collision_get">
<field name="VAR0">ball</field>
<field name="VAR1">playfield</field>
</block>
</value>
<statement name="DO0">
<block type="simple_sound_set">
<field name="AUDC">1</field>
<field name="AUDF">15</field>
<field name="AUDV">7</field>
<field name="DURATION">5</field>
<field name="CHANNEL">0</field>
<next>
<block type="controls_if">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_compare">
<field name="OP">EQ</field>
<value name="A">
<block type="variables_get">
<field name="VAR">Ball X Speed</field>
</block>
</value>
<value name="B">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables_set">
<field name="VAR">Ball X Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">255</field>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set">
<field name="VAR">Ball X Speed</field>
<value name="VALUE">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
</block>
</statement>
<next>
<block type="sprite_ball_change">
<field name="VAR">ballx</field>
<value name="DELTA">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="variables_get">
<field name="VAR">Ball X Speed</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
<next>
<block type="sprite_ball_change">
<field name="VAR">bally</field>
<value name="DELTA">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="variables_get">
<field name="VAR">Ball Y Speed</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</category>

</category>

0 comments on commit bb0897f

Please sign in to comment.