Added move_backward blockly block.

This commit is contained in:
Martin Haye 2015-05-31 19:03:38 -07:00
parent 26e7e1b119
commit 6b51dff8b9
4 changed files with 36 additions and 5 deletions

View File

@ -51,6 +51,7 @@
<category name="Events"> <category name="Events">
<block type="events_set_map"></block> <block type="events_set_map"></block>
<block type="events_teleport"></block> <block type="events_teleport"></block>
<block type="events_move_backward"></block>
<block type="events_set_sky"></block> <block type="events_set_sky"></block>
<block type="events_set_ground"></block> <block type="events_set_ground"></block>
</category> </category>

View File

@ -125,6 +125,18 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Teleport the player to a given location and direction on this map.'); this.setTooltip('Teleport the player to a given location and direction on this map.');
} }
}; };
Blockly.Blocks['events_move_backward'] = {
init: function() {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Move backward");
this.setOutput(false);
this.setTooltip('Moves the player one step backward.');
}
};
Blockly.Blocks['events_set_sky'] = { Blockly.Blocks['events_set_sky'] = {
init: function() { init: function() {
this.setHelpUrl(Mythos.helpUrl); this.setHelpUrl(Mythos.helpUrl);

View File

@ -1398,6 +1398,7 @@ class PackPartitions
def vec_teleport = 0x315 def vec_teleport = 0x315
def vec_setPortrait = 0x318 def vec_setPortrait = 0x318
def vec_clrPortrait = 0x31B def vec_clrPortrait = 0x31B
def vec_moveBackward = 0x31E
def emitAuxString(str) def emitAuxString(str)
{ {
@ -1522,6 +1523,8 @@ class PackPartitions
packSetGround(blk); break packSetGround(blk); break
case 'events_teleport': case 'events_teleport':
packTeleport(blk); break packTeleport(blk); break
case 'events_move_backward':
packMoveBackward(blk); break
case 'graphics_set_portrait': case 'graphics_set_portrait':
packSetPortrait(blk); break packSetPortrait(blk); break
case 'graphics_clr_portrait': case 'graphics_clr_portrait':
@ -1791,6 +1794,16 @@ class PackPartitions
emitCodeByte(0x30) // DROP emitCodeByte(0x30) // DROP
} }
def packMoveBackward(blk)
{
assert blk.field.size() == 0
//println " Move backward"
emitCodeByte(0x54) // CALL
emitCodeWord(vec_moveBackward)
emitCodeByte(0x30) // DROP
}
def makeInit(mapName, scripts, xRange, yRange) def makeInit(mapName, scripts, xRange, yRange)
{ {
//println " Script: special 'init'" //println " Script: special 'init'"

View File

@ -891,8 +891,13 @@ def moveForward()
// If not blocked, render at the new position. // If not blocked, render at the new position.
if val > 0 if val > 0
if !mapIs3D
render()
needRender = FALSE
else
needRender = TRUE needRender = TRUE
fin fin
fin
// If we're on a new map tile, clear text from script(s) on the old tile. // If we're on a new map tile, clear text from script(s) on the old tile.
if val >= 2 and textDrawn if val >= 2 and textDrawn
@ -1113,10 +1118,6 @@ end
// Get a key, and don't return until it's Y or N (or lower-case of those). Returns 1 for Y. // Get a key, and don't return until it's Y or N (or lower-case of those). Returns 1 for Y.
def getYN() def getYN()
byte key byte key
if needRender
render()
needRender = FALSE
fin
while TRUE while TRUE
key = getUpperKey() key = getUpperKey()
if key == 'Y' if key == 'Y'
@ -1294,6 +1295,10 @@ def setCallbacks()
// $31B // $31B
callbacks.27 = $4c callbacks.27 = $4c
callbacks:28 = @clrPortrait callbacks:28 = @clrPortrait
// $31E
callbacks.30 = $4c
callbacks:31 = @moveBackward
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////