View difference between Paste ID: Qzc9W1Nd and 0pZHj6VY
SHOW: | | - or go back to the newest paste.
1
m = "1"
2
local pX = 10
3
local pY = 5
4
local sc = 0
5
run = true
6
beam = math.max(math.random(1,20),0)
7
local icolor = colors.white
8
local pcolor = colors.blue
9
local bcolor = colors.red
10
local reset = colors.black
11
term.setBackgroundColor(colors.brown)
12
term.clear()
13
term.setCursorPos(pX,pY)
14
term.setBackgroundColor(pcolor)
15
print(" ")
16
term.setBackgroundColor(colors.brown)
17
18
i = paintutils.loadImage("sprites/world/bworld")
19
paintutils.drawImage(i,1,1)
20
term.setCursorPos(1,5)
21
 iX = math.max(math.random(1,40),0)
22
iY = math.max(math.random(5,17),0)
23
term.setTextColor(colors.black)
24
term.setCursorPos(iX,iY)
25
term.setBackgroundColor(icolor)
26
print "I"
27
 i2X = math.max(math.random(1,40),0)
28
i2Y = math.max(math.random(5,17),0)
29
term.setTextColor(colors.black)
30
 term.setCursorPos(i2X,i2Y)
31
term.setBackgroundColor(icolor)
32
print "I"
33
term.setBackgroundColor(reset)
34
term.setTextColor(colors.white)
35
term.setBackgroundColor(colors.brown)
36
term.setCursorPos(1,1)
37
print "--------------------------------------------------"
38
print "|                Wellcome to Beams:              |"
39
print("|                  Score: " ..sc)
40
print "--------------------------------------------------"
41
term.setCursorPos(50,3)
42
print "|"
43
44
function db()
45
i = paintutils.loadImage("sprites/world/bworld")
46
paintutils.drawImage(i,1,1)
47
end
48
49
function reitem()
50
term.setTextColor(colors.black)
51
term.setCursorPos(iX,iY)
52
term.setBackgroundColor(icolor)
53
print "I"
54
term.setTextColor(colors.black)
55
 term.setCursorPos(i2X,i2Y)
56
term.setBackgroundColor(icolor)
57
print "I"
58
end
59
60
function rei()
61
 iX = math.max(math.random(1,40),0)
62
iY = math.max(math.random(5,17),0)
63
term.setTextColor(colors.black)
64
term.setCursorPos(iX,iY)
65
term.setBackgroundColor(icolor)
66
print "I"
67
 i2X = math.max(math.random(1,40),0)
68
i2Y = math.max(math.random(5,17),0)
69
term.setTextColor(colors.black)
70
 term.setCursorPos(i2X,i2Y)
71
term.setBackgroundColor(icolor)
72
print "I"
73
end
74
75
function drawLabel()
76
term.setBackgroundColor(reset)
77
term.setTextColor(colors.white)
78
term.setBackgroundColor(colors.brown)
79
term.setCursorPos(1,1)
80
print "--------------------------------------------------"
81
print "|                Wellcome to Beams:              |"
82
print("|                  Score: " ..sc)
83
print "--------------------------------------------------"
84
term.setCursorPos(50,3)
85
print "|"
86
term.setCursorPos(1,5)
87
term.setTextColor(colors.black)
88
end
89
90
91
function drawChar()
92
term.setCursorPos(pX,pY)
93
term.setBackgroundColor(pcolor)
94
print(" ")
95
term.setBackgroundColor(reset)
96
end
97
98
function check()
99
if pX == iX and pY == iY then
100
term.setCursorPos(iX,iY)
101
term.setBackgroundColor(reset)
102
print " "
103
term.setCursorPos(pX,pY)
104
term.setBackgroundColor(colors.blue)
105
print " "
106
sc = sc + 10
107
drawLabel()
108
sleep(0.5)
109
rei() 
110
 elseif pX == i2X and pY == i2Y then
111
 term.setCursorPos(i2X,i2Y)
112
term.setBackgroundColor(reset)
113
print " "
114
term.setCursorPos(pX,pY)
115
term.setBackgroundColor(colors.blue)
116
print " "
117
sc = sc + 10
118
drawLabel()
119
sleep(0.5)
120
rei()
121
end
122
end
123
124
function beeam()
125
ranb = math.max(math.random(1,10),0)
126
if ranb == 3 then
127
beam = math.max(math.random(5,17),0)
128
term.setCursorPos(54,beam)
129
sleep(0.1)
130
term.setCursorPos(pX,pY)
131
term.setBackgroundColor(colors.blue)
132
print " "
133
be = beam + 1
134
term.setCursorPos(1,1)
135
term.setTextColor(colors.white)
136
term.setBackgroundColor(colors.brown)
137
print("INCOMEING Line:  "..beam)
138
sleep(1.2)
139
term.setCursorPos(54,beam)
140
term.setBackgroundColor(colors.red)
141
term.setCursorPos(54,beam)
142
print " "
143
term.setBackgroundColor(colors.red)
144
print("================================================")
145
sleep(0.2)
146
term.setCursorPos(pX,pY)
147
term.setBackgroundColor(colors.blue)
148
print " "
149
if be == pY then
150
term.setBackgroundColor(colors.black)
151
term.clear()
152
term.setCursorPos(10,5)
153
term.setTextColor(colors.yellow)
154
print "Game Over"
155
term.setCursorPos(10,5)
156
print("Score: "..sc)
157
sleep(2)
158
run = false
159
return
160
else
161
term.setBackgroundColor(colors.brown)
162
term.clear()
163
db()
164
drawLabel()
165
term.setCursorPos(pX,pY)
166
term.setBackgroundColor(colors.blue)
167
print " "
168
169
 term.setCursorPos(iX,iY)
170
term.setBackgroundColor(icolor)
171
print "I"
172
 term.setCursorPos(i2X,i2Y)
173
term.setBackgroundColor(icolor)
174
print "I"
175
move()
176
term.setCursorPos(pX,pY)
177
term.setBackgroundColor(colors.blue)
178
print " "
179
return move()
180
end
181
end
182
end
183
184
185
function move()
186
while run == true do
187
local event, button = os.pullEventRaw("key")
188
term.setTextColor(colors.white)
189
term.setBackgroundColor(colors.black)
190
191
    if button == 200 then --up
192
	 if pY == 5 then
193
	term.setCursorPos(1,1)
194
	print "Cantmove"
195
	  event = os.pullEvent("key")
196
	 drawLabel()
197
	  move()
198
	 else
199
	 sleep(0.001)
200
db()
201
reitem()
202
drawLabel()
203
	 pY = pY - 1
204
	print " "
205
	
206
	drawChar()
207
	check()
208
	beeam()
209-
	move()
209+
210
	end
211
	
212
	if button == 208 then -- down
213
	 if pY == 18 then
214
	 term.setCursorPos(1,1)
215
	print "Cantmove"
216
	  event = os.pullEvent("key")
217
	 drawLabel()
218
	 else
219
	 sleep(0.001)
220
	 db()
221
reitem()
222
drawLabel()
223
	 	pY = pY + 1
224
		
225
		check()
226
		beeam()
227
drawChar()
228
	end
229
	end
230
	
231
	if button == 203 then -- left
232
	 if pX == 1 then
233
	 term.setCursorPos(1,1)
234
	print "Cantmove"
235
	 event = os.pullEvent("key")
236
	 drawLabel()
237
	 move()
238
	 else
239
	 sleep(0.001)
240
	 pX = pX - 1
241
db()
242
reitem()
243
drawLabel()
244
	 check()
245
	 	 beeam()
246
drawChar()
247
	end
248
	end
249
	
250
	if button == 205 then -- right
251
	 if pX == 51 then
252
	 term.setCursorPos(1,1)
253
	print "Cantmove"
254
	  event = os.pullEvent("key")
255
	 drawLabel()
256
	 move()
257
	 else
258
	 sleep(0.001)
259
db()
260
reitem()
261
drawLabel()
262
	 pX = pX + 1
263
	
264
	 check()
265
	  beeam()
266
	drawChar()
267
	end
268
	end
269
end
270
end
271-
	move()
271+