samples/03_rendering_sprites/04_color_and_rotation/app/main.rb
def calc_wrap state

  # car returns to left side of screen if it disappears on right side of screen
  # sprite.width refers to tile's size, which is multipled by scale (4) to make it bigger
  state.x = -state.sprite.width * state.sprite.scale if state.x - 20 > 1280

  # car wraps around to right side of screen if it disappears on the left side
  state.x = 1280 if state.x + state.sprite.width * state.sprite.scale + 20 < 0

  # car wraps around to bottom of screen if it disappears at the top of the screen
  # if you subtract 520 pixels instead of 20 pixels, the car takes longer to reappear (try it!)
  state.y = 0    if state.y - 20 > 720 # if 20 pixels less than car's y position is greater than vertical scope

  # car wraps around to top of screen if it disappears at the bottom of the screen
  state.y = 720  if state.y + state.sprite.height * state.sprite.scale + 20 < 0
end
# The screen's dimensions are 1280x720. If the car goes out of scope,
# it loops back around on the screen.
The screen's dimensions are 1280x720. If the car goes out of scope,
it loops back around on the screen.
The screen ' s dimensions are 1280x720 . If the car goes out of scope it loops back around on the screen .
def calc_wrap state
  state.x = -state.sprite.width * state.sprite.scale if state.x - 20 > 1280
  state.x = 1280 if state.x + state.sprite.width * state.sprite.scale + 20 < 0
  state.y = 0    if state.y - 20 > 720 
  state.y = 720  if state.y + state.sprite.height * state.sprite.scale + 20 < 0
end
def calc_wrap state state . x = - state . sprite . width * state . sprite . scale if state . x - 20 > 1280 state . x = 1280 if state . x + state . sprite . width * state . sprite . scale + 20 < 0 state . y = 0 if state . y - 20 > 720 state . y = 720 if state . y + state . sprite . height * state . sprite . scale + 20 < 0 end
The screen's dimensions are 1280x720.
The screen ' s dimensions are 1280x720 .
# car returns to left side of screen if it disappears on right side of screen # sprite.width refers to tile's size, which is multipled by scale (4) to make it bigger # car wraps around to right side of screen if it disappears on the left side # car wraps around to bottom of screen if it disappears at the top of the screen # if you subtract 520 pixels instead of 20 pixels, the car takes longer to reappear (try it!) # if 20 pixels less than car's y position is greater than vertical scope # car wraps around to top of screen if it disappears at the bottom of the screen
state