Continued using the Pyret game

Thursday, July 13, 2017
There was some thing missing through out my data . When we were using the big bang formal I need to add wrapping in the text.


W.big-bang(0,[list:
W.on-tick(move-airplane-wrapping-x-on-tick),
W.to-draw(place-airplane-x)])
 But I need to add this formula in the before I would but the big bang wrapping. 
fun move-airplane-wrapping-x-on-tick(x):
  num-modulo(move-airplane-x-on-tick(x),WIDTH)
end
Then the plan will be able to to go around the page.Now in order for the airplane to go across the page. we would need to add a new structure to hold the pair of data. you would change the position of the airplane. Since the airplane is going though the x-axis. We need it to go though the x and y axis. Therefore we need to define a new structure to hold this pair of data:
data Posn:
  | posn(x, y)
end
This would revise the World State meaning that the Posn: would represent that x an y position on the airplane in the screen. Since we are using the move-airplane-wrapping-x-on-tick. We need it to have a current y-value 
We will be using that function that is

AIRPLANE-Y-MOVE = 3
Let’s write some test cases for the new function. Here’s one:
check:
  move-airplane-xy-on-tick(posn(10, 10)) is posn(20, 13)
end
Another way to write the test would be:
check:
  p = posn(10, 10)
  move-airplane-xy-on-tick(p) is
    posn(move-airplane-wrapping-x-on-tick(p.x),
      move-airplane-y-on-tick(p.y))
end
Now  we need to define the move-airplane-xy-on-tick. You should end up with something like this:
fun move-airplane-xy-on-tick(w):
  posn(move-airplane-wrapping-x-on-tick(w.x),
    move-airplane-y-on-tick(w.y))
end
Note that we have reused the existing function for the x-axis and, correspondingly, created a helper for the y-axix:
fun move-airplane-y-on-tick(y):
  y + AIRPLANE-Y-MOVE
Then we draw the background using this coding
fun place-airplane-xy(w): I.place-image(AIRPLANE, w.x, w.y, BACKGROUND) end

INIT-POS = posn(0, 0)

W.big-bang(INIT-POS, [list:
    W.on-tick(move-airplane-xy-on-tick),
    W.to-draw(place-airplane-xy)])
Then we are going to have the plane going across unfortunately the my computer isn't working every well so I'm just explaining what I will be doing ones I get the computer fix.

















Comments