Skip to content

Commit b0947f8

Browse files
author
Robert Simai
committed
.
1 parent d69f88f commit b0947f8

File tree

1 file changed

+0
-109
lines changed

1 file changed

+0
-109
lines changed

array.py

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
rotate = 1
4242

4343
# the matrix
44-
<<<<<<< HEAD
4544
z = []
4645

4746
# the defender
@@ -52,18 +51,6 @@
5251

5352
# printout matrix
5453
m = []
55-
=======
56-
z=[]
57-
58-
# the defender
59-
y=[]
60-
61-
# the shots underway
62-
s=[]
63-
64-
# printout matrix
65-
m=[]
66-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
6754

6855
char = 'q'
6956
shipcount = 0
@@ -78,26 +65,17 @@
7865
# new terminal setting unbuffered
7966
new_term[3] = (new_term[3] & ~termios.ICANON & ~termios.ECHO)
8067

81-
<<<<<<< HEAD
8268

83-
=======
84-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
8569
# switch to normal terminal on exit
8670
def set_normal_term():
8771
termios.tcsetattr(fd, termios.TCSAFLUSH, old_term)
8872

89-
<<<<<<< HEAD
9073

91-
=======
92-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
9374
# switch to unbuffered terminal
9475
def set_curses_term():
9576
termios.tcsetattr(fd, termios.TCSAFLUSH, new_term)
9677

97-
<<<<<<< HEAD
9878

99-
=======
100-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
10179
# poll the keyboard without blocking
10280
def kbhit():
10381
dr, dw, de = select([sys.stdin], [], [], 0)
@@ -110,30 +88,20 @@ def kbhit():
11088
termios.tcflush(sys.stdin, termios.TCIOFLUSH)
11189
return
11290

113-
<<<<<<< HEAD
11491

115-
=======
116-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
11792
# output in cols x rows
11893
def printout():
11994
check_hits()
12095
os.system('clear')
121-
<<<<<<< HEAD
12296
for a in range(0, rows):
12397
out = ''
12498
for b in range(0, cols):
125-
=======
126-
for a in range(0,rows):
127-
out = ''
128-
for b in range(0,cols):
129-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
13099
out += m[((cols)*a+b)]
131100
print out
132101
print_defender()
133102
print "Shots:", shotcount, "Ships left:", shipcount, "of", shipcountorig
134103
print "Left: \"" + lkey + "\"", " Right: \"" + rkey + "\"", " Fire: \"" + skey + "\""
135104

136-
<<<<<<< HEAD
137105

138106
# print defender base line
139107
def print_defender():
@@ -150,33 +118,13 @@ def create_defender():
150118
y.insert(dcol, defender)
151119

152120

153-
=======
154-
# print defender base line
155-
def print_defender():
156-
out = ''
157-
for b in range(0,cols):
158-
out += y[b]
159-
print out
160-
161-
# create the defender base line
162-
def create_defender():
163-
for a in range(0,cols-1):
164-
y.append(nodefender)
165-
y.insert(dcol, defender)
166-
167-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
168121
# create the matrix, ships and shots
169122
def create_matrix():
170123
global shipcount
171124
global m
172125
global s
173-
<<<<<<< HEAD
174126
for a in range(0, rows):
175127
for b in range(0, cols):
176-
=======
177-
for a in range(0,rows):
178-
for b in range(0,cols):
179-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
180128
if (a < fillrows) and (b/fillup == int(b/fillup)):
181129
z.append(ship)
182130
shipcount += 1
@@ -187,16 +135,10 @@ def create_matrix():
187135
global shipcountorig
188136
shipcountorig = shipcount
189137

190-
<<<<<<< HEAD
191138

192139
# check if left or right has been reached, add a line and change direction
193140
def check_out():
194141
for a in range(0, rows):
195-
=======
196-
# check if left or right has been reached, add a line and change direction
197-
def check_out():
198-
for a in range(0,rows):
199-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
200142
pos1 = a*cols+cols-1
201143
pos2 = a*cols
202144
if ((z[pos1] == ship) and (rotate == 1)) or ((z[pos2] == ship) and (rotate == -1)):
@@ -209,7 +151,6 @@ def check_out():
209151
else:
210152
move_left()
211153

212-
<<<<<<< HEAD
213154

214155
# step to the right
215156
def move_right():
@@ -218,21 +159,12 @@ def move_right():
218159
z.pop(rows*cols-1)
219160

220161

221-
=======
222-
# step to the right
223-
def move_right():
224-
global z
225-
z.insert(0,noship)
226-
z.pop(rows*cols-1)
227-
228-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
229162
# step to the left
230163
def move_left():
231164
global z
232165
z.pop(0)
233166
z.append(noship)
234167

235-
<<<<<<< HEAD
236168

237169
# move down by one line
238170
def move_down():
@@ -242,15 +174,6 @@ def move_down():
242174
z.pop(cols*rows)
243175

244176

245-
=======
246-
# move down by one line
247-
def move_down():
248-
for a in range(0,cols):
249-
global z
250-
z.insert(0,noship)
251-
z.pop(cols*rows)
252-
253-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
254177
def defender_left():
255178
if y[0] == defender:
256179
return
@@ -260,10 +183,7 @@ def defender_left():
260183
global dcol
261184
dcol -= 1
262185

263-
<<<<<<< HEAD
264186

265-
=======
266-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
267187
def defender_right():
268188
if y[cols-1] == defender:
269189
return
@@ -273,15 +193,11 @@ def defender_right():
273193
global dcol
274194
dcol += 1
275195

276-
<<<<<<< HEAD
277196

278-
=======
279-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
280197
def trigger_shot():
281198
s[(rows-1)*cols+dcol] = shot
282199
global shotcount
283200
shotcount += 1
284-
<<<<<<< HEAD
285201

286202

287203
def shots_up():
@@ -294,18 +210,6 @@ def shots_up():
294210
def check_hits():
295211
global shipcount
296212
for i in range(0, cols*rows):
297-
=======
298-
299-
def shots_up():
300-
for i in range(0,cols):
301-
s.pop(0)
302-
s.append(' ')
303-
304-
# check hits and merge for printout
305-
def check_hits():
306-
global shipcount
307-
for i in range(0,cols*rows):
308-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
309213
if s[i] == shot and z[i] == ship:
310214
s[i] = ' '
311215
z[i] = noship
@@ -319,11 +223,7 @@ def check_hits():
319223

320224
# check end
321225
def check_end():
322-
<<<<<<< HEAD
323226
for i in range(0, cols):
324-
=======
325-
for i in range(0,cols):
326-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
327227
if z[(rows-1)*cols+i] == ship:
328228
print
329229
print "Game over! You missed", shipcount, "ship(s)!"
@@ -351,11 +251,7 @@ def check_end():
351251
check_out()
352252
shots_up()
353253
printout()
354-
<<<<<<< HEAD
355254
for w in range(0, 12):
356-
=======
357-
for w in range(0,15):
358-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
359255
kbhit()
360256
if char:
361257
if char == lkey:
@@ -366,11 +262,6 @@ def check_end():
366262
printout()
367263
if char == skey:
368264
trigger_shot()
369-
<<<<<<< HEAD
370265

371266
time.sleep(0.005)
372-
=======
373-
374-
time.sleep(0.02)
375-
>>>>>>> 46e79a7f5e0d7f5b5bcbf3bc59ec25d113d594f4
376267
check_end()

0 commit comments

Comments
 (0)