863氏を真似てみる。
例:右矢印キーで右へ動かす場合に、ルームからはみ出るのを防ぐようにする処理。

[Keyboard Event for <right> key]
   [if x is smaller than room_width] ※変数room_widthでルーム幅が分かる。厳密にはオブジェクトの基点によるから、調整が必要。
              ┃
              ▲ Start of a block
              ┃
   [Jump to given position (4,0) relative]
              ┃
              ▼ End of a block