View difference between Paste ID: 3Wah0Grp and KLHq0LFq
SHOW: | | - or go back to the newest paste.
1
local scroll = 0;
2
local jump = 0;
3
local char = ">";
4
local coins = 0;
5
local x,y = term.getSize()
6
local level = 1;
7
8
function newCoin(posX, posY)
9
	term.setCursorPos(posX - scroll, posY + jump)
10
	coin = "O";
11
	if posX  - scroll ~= x-1 then --
12
		if(posX - scroll == x/2 and posY + jump == y-10)then
13
			coins = coins+1
14
			coin = ""
15
		else
16
			write(coin)
17
		end
18
	end
19
end
20
21
function floor(param1)
22
	for i=1,x-1 do
23
		term.setCursorPos(i, y-9 + jump)
24
		write(param1)
25
	end
26
end
27
28
function newTeleporter(posX, posY, levelid, title)
29
	term.setCursorPos(posX - scroll, posY + jump)
30
	if posX  - scroll ~= x-1 then --
31
		if(posX - scroll == x/2 and posY + jump == y-10)then
32
			level = levelid
33
		else
34
			write(title)
35
		end
36
	end
37
end
38
39
function world()
40
	if(level == 1)then
41
		floor("A")
42
		for i = 1,5 do
43
			newCoin(x/2-i, y-14)
44
		end
45
		
46
		newTeleporter(x/2-3, y-10, 999, "X")
47
	elseif(level == 999)then
48
		floor("O")
49
		for i = 1,x-1 do
50
			newCoin(x/2-i, y-14)
51
		end
52
	end
53
end
54
55
function redraw()
56
	term.clear()
57
	term.setCursorPos(1,1)
58
	write("Coins: " ..coins.. " World: 0-" ..level)
59
	term.setCursorPos(x/2, y-10)
60
	write(char)
61
	
62
	world()
63
end
64
65
while true do
66
	redraw()
67
	local event, a, b = os.pullEvent();
68
	if(event == "char" and a == "a")then
69
		scroll = scroll-1
70
		char = "<"
71
	elseif(event == "char" and a == "d")then
72
		scroll = scroll+1
73
		char = ">"
74
	elseif(event == "key" and a == 57)then
75
		jump = 1
76
		for i=1,4 do
77
			sleep(0.1)
78
			jump = i
79
			redraw()
80
		end
81
		for i=1,4 do
82
			sleep(0.1)
83
			jump = jump-i
84
			redraw()
85
		end
86
		jump = 0
87
	end
88
end