Game Development Reference
In-Depth Information
amplitude = 55
frequency = 0.6
speed = frequency
function sineScroll(time)
y = (amplitude * math.sin(frequency * time * 2 * math.pi) )
return y
end
To make the object move, you would also need to manipulate the x position. With every call of this
function, you'd alter the x value by either increasing it or decreasing it by the frequency (speed). To
understand better how the amplitude and frequency would affect the output, you can play with the
board[i] = {}
for j=1, N do
board[i][j] = false
end
end
function allowedAt(x,y)
for i=1, N do
if board[x][i] == true or board[i][y] == true then
return false
end
end
return true
end
This can be expanded to solve other problems like the N-Queen, or the N-Rook.
Using Arrays to Output Large Amounts of Text Using Templates
The children's poem “There Was an Old Lady Who Swallowed a Fly,” in which a woman swallows
increasingly larger animals to catch the previously swallowed one, is a good example to rebuild using
arrays. We have a series of animals that she swallowed and each has a corresponding output line.
 
Search WWH ::




Custom Search