39 lines
709 B
Lua
39 lines
709 B
Lua
function init()
|
|
setmode(1)
|
|
|
|
mountains = {}
|
|
local val = 2
|
|
for i=0,99 do
|
|
val = mid(1,val+rnd(3)-1,4)
|
|
mountains[i] = val
|
|
end
|
|
|
|
ox=0
|
|
end
|
|
|
|
function update()
|
|
cls()
|
|
draw_mountains()
|
|
|
|
if btn(KEY_RIGHT) then ox=(ox+1)%100 end
|
|
if btn(KEY_LEFT) then ox=(ox-1)%100 end
|
|
end
|
|
|
|
function draw_mountains()
|
|
color(COLOR_RED,COLOR_BLACK)
|
|
for i=0,39 do
|
|
local x=(ox+i)%100
|
|
for j=29-mountains[x],29 do
|
|
local chr="\143"
|
|
if j==29-mountains[x] then
|
|
if mountains[(x+1)%100] > mountains[x] then
|
|
print("\214",i,j-1) --chr="\214"
|
|
elseif mountains[(x+1)%100] < mountains[x] then
|
|
chr="\215"
|
|
end
|
|
end
|
|
print(chr,i,j)
|
|
end
|
|
end
|
|
end
|