-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html~
executable file
·666 lines (478 loc) · 12.9 KB
/
index.html~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<title>ASSIGNMENT 4</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<meta name="generator" content="Org-mode"/>
<meta name="generated" content="2012-03-26 13:46:28 EDT"/>
<meta name="author" content="SOMAY JAIN 201101054"/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color:lightblue; font-weight:normal }
.target { }
.timestamp { color: grey }
.timestamp-kwd { color: CadetBlue }
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: courier, monospace;
font-size: 90%;
overflow:auto;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
/*]]>*/-->
</style>
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*/-->
</script>
</head><body>
<h1 class="title">ASSIGNMENT 4</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Title :: </a></li>
<li><a href="#sec-2">2 Name and Roll Number :: </a></li>
<li><a href="#sec-3">3 Code Organisation :: </a>
<ul>
<li><a href="#sec-3.1">3.1 Game :: </a></li>
<li><a href="#sec-3.2">3.2 Instructions :: </a></li>
</ul>
</li>
<li><a href="#sec-4">4 Class decomposition :: </a>
<ul>
<li><a href="#sec-4.1">4.1 Classes :: </a></li>
<li><a href="#sec-4.2">4.2 Use of this class :: </a></li>
<li><a href="#sec-4.3">4.3 Methods present :: </a>
<ul>
<li><a href="#sec-4.3.1">4.3.1 addscreen :: </a></li>
<li><a href="#sec-4.3.2">4.3.2 definecolors :: </a></li>
<li><a href="#sec-4.3.3">4.3.3 drawrobot :: </a></li>
<li><a href="#sec-4.3.4">4.3.4 drawenemy :: </a></li>
<li><a href="#sec-4.3.5">4.3.5 addelements :: </a></li>
<li><a href="#sec-4.3.6">4.3.6 check :: </a></li>
<li><a href="#sec-4.3.7">4.3.7 main :: </a></li>
<li><a href="#sec-4.3.8">4.3.8 result :: </a></li>
<li><a href="#sec-4.3.9">4.3.9 run :: </a></li>
<li><a href="#sec-4.3.10">4.3.10 inst :: </a></li>
</ul></li>
</ul>
</li>
<li><a href="#sec-5">5 Advantages :: </a>
<ul>
<li><a href="#sec-5.1">5.1 Use of methods :: </a></li>
<li><a href="#sec-5.2">5.2 Use of classes :: </a></li>
<li><a href="#sec-5.3">5.3 Reusability :: </a></li>
</ul>
</li>
<li><a href="#sec-6">6 Miscellaneous :: </a>
<ul>
<li><a href="#sec-6.1">6.1 Program flow :: </a></li>
<li><a href="#sec-6.2">6.2 Logic :: </a></li>
</ul>
</li>
<li><a href="#sec-7">7 Extra features :: </a></li>
<li><a href="#sec-8">8 Screenshots :: </a></li>
</ul>
</div>
</div>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">1 Title :: </h2>
<div id="text-1">
<p>
Report on Robot Bomb Defuser Game.
</p>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">2 Name and Roll Number :: </h2>
<div id="text-2">
<ul>
<li>
Somay Jain
</li>
<li>
201101054
</li>
</ul>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">3 Code Organisation :: </h2>
<div id="text-3">
<p>
I have made following 2 modules-
</p>
</div>
<div id="outline-container-3.1" class="outline-3">
<h3 id="sec-3.1">3.1 Game :: </h3>
<div id="text-3.1">
<ul>
<li>
This has the source code which has most of the functions.
</li>
<li>
It governs how the robot movement is implemented, how diffuse codes and mines, bomb are placed.
</li>
<li>
It also takes care of how levels are implemented.
</li>
</ul>
</div>
</div>
<div id="outline-container-3.2" class="outline-3">
<h3 id="sec-3.2">3.2 Instructions :: </h3>
<div id="text-3.2">
<ul>
<li>
This module takes care of the instructions printed on the starting page of the game.
</li>
<li>
It tells the player the rules and the controls in the beginning of the game.
</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">4 Class decomposition :: </h2>
<div id="text-4">
</div>
<div id="outline-container-4.1" class="outline-3">
<h3 id="sec-4.1">4.1 Classes :: </h3>
<div id="text-4.1">
<ul>
<li>
There is one encapsulated class in the main game module.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.2" class="outline-3">
<h3 id="sec-4.2">4.2 Use of this class :: </h3>
<div id="text-4.2">
<ul>
<li>
This class is made because it makes the main code encapsulated. The user running the game cannot change the values of variables.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3" class="outline-3">
<h3 id="sec-4.3">4.3 Methods present :: </h3>
<div id="text-4.3">
</div>
<div id="outline-container-4.3.1" class="outline-4">
<h4 id="sec-4.3.1">4.3.1 addscreen :: </h4>
<div id="text-4.3.1">
<ul>
<li>
This method adds a blank window in the terminal with the x, y coordinates, width and height as specified in the class variables.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.2" class="outline-4">
<h4 id="sec-4.3.2">4.3.2 definecolors :: </h4>
<div id="text-4.3.2">
<ul>
<li>
This method configures colors to be used.
</li>
<li>
The colors defined in this method can be used in other methods also.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.3" class="outline-4">
<h4 id="sec-4.3.3">4.3.3 drawrobot :: </h4>
<div id="text-4.3.3">
<ul>
<li>
This method adds the robot with a specefic shape in the middle of the window.
</li>
<li>
The shape of the robot can be changed by changing this method.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.4" class="outline-4">
<h4 id="sec-4.3.4">4.3.4 drawenemy :: </h4>
<div id="text-4.3.4">
<ul>
<li>
Similar to drawrobot, this draws the enemy robot on the coordinates specified in the method's arguments.
</li>
<li>
Shape and position of the enemy robot can be changed by changing this method.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.5" class="outline-4">
<h4 id="sec-4.3.5">4.3.5 addelements :: </h4>
<div id="text-4.3.5">
<ul>
<li>
This method places the bomb, diffuse codes and mines(onwards level 2) in the terminal window on unique coordinates.
</li>
<li>
It also adds the robot and the enemy robot(onwards level 2) by calling the modules drawenemy and drawrobot.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.6" class="outline-4">
<h4 id="sec-4.3.6">4.3.6 check :: </h4>
<div id="text-4.3.6">
<ul>
<li>
This method checks if the robot has hit the bomb or a diffuse code or a mine/bullet.
</li>
<li>
If it hits the bomb, the method returns -1.
</li>
<li>
If it hits the diffuse code, it increases the count and returns the count.
</li>
<li>
If it hits the mine or a bullet, it returns -2.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.7" class="outline-4">
<h4 id="sec-4.3.7">4.3.7 main :: </h4>
<div id="text-4.3.7">
<ul>
<li>
This is the main method where most of the other methods are called.
</li>
<li>
It takes care of all operations in a single level of the game.
</li>
<li>
Wherever the robot is moved, it redraws the robot on the new location.
</li>
<li>
This method also takes care of the pause and exit option in the game. When resumed, the game continues from the last stage before pausing.
</li>
<li>
Also, the movement of bullets is also taken care by this method.
</li>
<li>
For a particular level, it returns 'lost' variable, which contains the information that the player wins or loses the present level.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.8" class="outline-4">
<h4 id="sec-4.3.8">4.3.8 result :: </h4>
<div id="text-4.3.8">
<ul>
<li>
This method asks the player if he wants to play the next level if he wins the current level.
</li>
<li>
It returns either 'y' or 'n', depending on whether the player wants to play the next level or not.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.9" class="outline-4">
<h4 id="sec-4.3.9">4.3.9 run :: </h4>
<div id="text-4.3.9">
<ul>
<li>
This method calls the main method as many times as required (till levels are less than 5 and the player keeps on winning and wants to play the next level)
</li>
<li>
It also shows the final score and status of the level on completion of a level.
</li>
</ul>
</div>
</div>
<div id="outline-container-4.3.10" class="outline-4">
<h4 id="sec-4.3.10">4.3.10 inst :: </h4>
<div id="text-4.3.10">
<ul>
<li>
This method present in the module instructions, prints the instructions on starting the game.
</li>
<li>
The instructions contain the game rules and the controls of the game.
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5">5 Advantages :: </h2>
<div id="text-5">
</div>
<div id="outline-container-5.1" class="outline-3">
<h3 id="sec-5.1">5.1 Use of methods :: </h3>
<div id="text-5.1">
<ul>
<li>
The use of methods for achieving small tasks made the code readable and understandable.
</li>
<li>
It made debugging very easy.
</li>
<li>
By using methods, repeatition of pieces of code does not take place.
</li>
</ul>
</div>
</div>
<div id="outline-container-5.2" class="outline-3">
<h3 id="sec-5.2">5.2 Use of classes :: </h3>
<div id="text-5.2">
<ul>
<li>
With the use of classes, the code is encapsulated and hence, the player cannot change any parameters in the game.
</li>
</ul>
</div>
</div>
<div id="outline-container-5.3" class="outline-3">
<h3 id="sec-5.3">5.3 Reusability :: </h3>
<div id="text-5.3">
<ul>
<li>
We can use methods such as addscreen, definecolors, drawrobot, drawenemy, check, etc to design a game with a slightly different logic.
</li>
<li>
With slight changes in the 'main' method, we can design a game for a different GUI as well.
</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-6" class="outline-2">
<h2 id="sec-6">6 Miscellaneous :: </h2>
<div id="text-6">
</div>
<div id="outline-container-6.1" class="outline-3">
<h3 id="sec-6.1">6.1 Program flow :: </h3>
<div id="text-6.1">
<ul>
<li>
For each level, the window is made using the addscreen method.
</li>
<li>
Colors are configured for the window made using definecolors method.
</li>
<li>
According to the level the player is in, the elements are added in the window at random positions.
</li>
<li>
After this initialisation, the keyboard presses are recorded and acted upon by the while loop in the 'main' method.
</li>
<li>
When the user presses ESC or hits the wall/mine/bomb, this loop is broken and the procedure is repeated depending on whether the player won or lost, and if he wants to play the next level or not.
</li>
</ul>
</div>
</div>
<div id="outline-container-6.2" class="outline-3">
<h3 id="sec-6.2">6.2 Logic :: </h3>
<div id="text-6.2">
<ul>
<li>
The logic resides in the 'main' method.
</li>
<li>
When the player presses any of the arrow keys, the new location of the robot is decided and it is redrawn there.
</li>
<li>
Also, the characters present on the new coordinates are acquired and feeded to the check method.
</li>
<li>
Depending on the output of the check method, level is continued or stopped.
</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-7" class="outline-2">
<h2 id="sec-7">7 Extra features :: </h2>
<div id="text-7">
<ul>
<li>
Extra features are included onwards level 2.
</li>
<li>
Extra features include -
<ul>
<li>
Mines (number of mines increase on advancing levels)
</li>
<li>
Enemy robots and the bullets shot by these enemy robots.
</li>
<li>
As the diffuse codes are obtained, the speed of the robot increases.
</li>
<li>
Speed also increases on advancing the levels.
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-8" class="outline-2">
<h2 id="sec-8">8 Screenshots :: </h2>
<div id="text-8">
</div>
</div>
<div id="postamble"><p class="author"> Author: SOMAY JAIN 201101054
<a href="mailto:somay@ubuntu"><somay@ubuntu></a>
</p>
<p class="date"> Date: 2012-03-26 13:46:28 EDT</p>
<p>HTML generated by org-mode 6.21b in emacs 23</p>
</div></body>
</html>