Monday, April 19, 2021

Twenty-six

 The brick wall, in Tiles1.lua, is not continuous. Been

revisiting the algorithm from Bird that scrolled the background:








The original background image is 1984 x 288. The screnn dimensions

requested are 800 x 600. By the terms of the algorithm, the image will

be drawn progressively from off-screen to the left until the offset reaches

800. This will then start all over. At a speed of 30 pixels per second, this should

take 26.6 seconds...







For the algorithm itself. What is initially drawn  is the image at 0, 0. On

redraw(dt) it is the value for the image minus that of bscroll. If we look

at what that is, it is scroll(initially 0) plus (0 * dt) ie an increaing value, that

of the scroll, The modulo operator is always at 0 because - up to 800 - the

denominator is larger than the numerator. the remainder is the scroll. At 800, 

the division value is 1, with remainder 0. This is where the image flips back to

HELLO! and the cycle begins again...




No comments: