mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-07 19:02:37 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
7
07_Basketball/README.md
Normal file
7
07_Basketball/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Basketball
|
||||
|
||||
As published in Basic Computer Games (1978)
|
||||
https://www.atariarchives.org/basicgames/showpage.php?page=12
|
||||
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
196
07_Basketball/basketball.bas
Normal file
196
07_Basketball/basketball.bas
Normal file
@@ -0,0 +1,196 @@
|
||||
5 PRINT TAB(31);"BASKETBALL"
|
||||
7 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
8 PRINT:PRINT:PRINT
|
||||
10 PRINT "THIS IS DARTMOUTH COLLEGE BASKETBALL. YOU WILL BE DARTMOUTH"
|
||||
20 PRINT " CAPTAIN AND PLAYMAKER. CALL SHOTS AS FOLLOWS: 1. LONG"
|
||||
30 PRINT " (30 FT.) JUMP SHOT; 2. SHORT (15 FT.) JUMP SHOT; 3. LAY"
|
||||
40 PRINT " UP; 4. SET SHOT."
|
||||
60 PRINT "BOTH TEAMS WILL USE THE SAME DEFENSE. CALL DEFENSE AS"
|
||||
70 PRINT "FOLLOWS: 6. PRESS; 6.5 MAN-TO MAN; 7. ZONE; 7.5 NONE."
|
||||
72 PRINT "TO CHANGE DEFENSE, JUST TYPE 0 AS YOUR NEXT SHOT."
|
||||
76 INPUT "YOUR STARTING DEFENSE WILL BE";D:IF D<6 THEN 2010
|
||||
79 PRINT
|
||||
80 INPUT "CHOOSE YOUR OPPONENT";O$
|
||||
370 PRINT "CENTER JUMP"
|
||||
390 IF RND(1)> 3/5 THEN 420
|
||||
400 PRINT O$;" CONTROLS THE TAP."
|
||||
410 GOTO 3000
|
||||
420 PRINT "DARTMOUTH CONTROLS THE TAP."
|
||||
425 PRINT
|
||||
430 INPUT "YOUR SHOT";Z
|
||||
440 P=0
|
||||
445 IF Z<>INT(Z) THEN 455
|
||||
446 IF Z<0 OR Z>4 THEN 455
|
||||
447 GOTO 460
|
||||
455 PRINT "INCORRECT ANSWER. RETYPE IT. ";:GOTO 430
|
||||
460 IF RND(1)<.5 THEN 1000
|
||||
480 IF T<100 THEN 1000
|
||||
490 PRINT
|
||||
491 IF S(1)<>S(0) THEN 510
|
||||
492 PRINT:PRINT " ***** END OF SECOND HALF *****":PRINT
|
||||
493 PRINT "SCORE AT END OF REGULATION TIME:"
|
||||
494 PRINT " DARTMOUTH:";S(1);" ";O$;":";S(0)
|
||||
495 PRINT
|
||||
496 PRINT "BEGIN TWO MINUTE OVERTIME PERIOD"
|
||||
499 T=93
|
||||
500 GOTO 370
|
||||
510 PRINT " ***** END OF GAME *****"
|
||||
515 PRINT "FINAL SCORE: DARTMOUTH:";S(1);" ";O$;":";S(0)
|
||||
520 STOP
|
||||
600 PRINT
|
||||
610 PRINT " *** TWO MINUTES LEFT IN THE GAME ***"
|
||||
620 PRINT
|
||||
630 RETURN
|
||||
1000 ON Z GOTO 1040,1040
|
||||
1030 GOTO 1300
|
||||
1040 T=T+1
|
||||
1041 IF T=50 THEN 8000
|
||||
1042 IF T=92 THEN 1046
|
||||
1043 GOTO 1050
|
||||
1046 GOSUB 600
|
||||
1050 PRINT "JUMP SHOT"
|
||||
1060 IF RND(1)>.341*D/8 THEN 1090
|
||||
1070 PRINT "SHOT IS GOOD."
|
||||
1075 GOSUB 7000
|
||||
1085 GOTO 3000
|
||||
1090 IF RND(1)>.682*D/8 THEN 1200
|
||||
1100 PRINT "SHOT IS OFF TARGET."
|
||||
1105 IF D/6*RND(1)>.45 THEN 1130
|
||||
1110 PRINT "DARTMOUTH CONTROLS THE REBOUND."
|
||||
1120 GOTO 1145
|
||||
1130 PRINT "REBOUND TO ";O$
|
||||
1140 GOTO 3000
|
||||
1145 IF RND(1)>.4 THEN 1158
|
||||
1150 GOTO 1300
|
||||
1158 IF D=6 THEN 5100
|
||||
1160 PRINT "BALL PASSED BACK TO YOU. ";
|
||||
1170 GOTO 430
|
||||
1180 IF RND(1)>.9 THEN 1190
|
||||
1185 PRINT "PLAYER FOULED, TWO SHOTS."
|
||||
1187 GOSUB 4000
|
||||
1188 GOTO 3000
|
||||
1190 PRINT "BALL STOLEN. ";O$;"'S BALL."
|
||||
1195 GOTO 3000
|
||||
1200 IF RND(1)>.782*D/8 THEN 1250
|
||||
1210 PRINT "SHOT IS BLOCKED. BALL CONTROLLED BY ";
|
||||
1230 IF RND(1)>.5 THEN 1242
|
||||
1235 PRINT "DARTMOUTH."
|
||||
1240 GOTO 430
|
||||
1242 PRINT O$;"."
|
||||
1245 GOTO 3000
|
||||
1250 IF RND(1)>.843*D/8 THEN 1270
|
||||
1255 PRINT "SHOOTER IS FOULED. TWO SHOTS."
|
||||
1260 GOSUB 4000
|
||||
1265 GOTO 3000
|
||||
1270 PRINT "CHARGING FOUL. DARTMOUTH LOSES BALL."
|
||||
1280 GOTO 3000
|
||||
1300 T=T+1
|
||||
1301 IF T=50 THEN 8000
|
||||
1302 IF T=92 THEN 1304
|
||||
1303 GOTO 1305
|
||||
1304 GOSUB 600
|
||||
1305 IF Z=0 THEN 2010
|
||||
1310 IF Z>3 THEN 1700
|
||||
1320 PRINT "LAY UP."
|
||||
1330 IF 7/D*RND(1)>.4 THEN 1360
|
||||
1340 PRINT "SHOT IS GOOD. TWO POINTS."
|
||||
1345 GOSUB 7000
|
||||
1355 GOTO 3000
|
||||
1360 IF 7/D*RND(1)>.7 THEN 1500
|
||||
1370 PRINT "SHOT IS OFF THE RIM."
|
||||
1380 IF RND(1)>2/3 THEN 1415
|
||||
1390 PRINT O$;" CONTROLS THE REBOUND."
|
||||
1400 GOTO 3000
|
||||
1415 PRINT "DARTMOUTH CONTROLS THE REBOUND."
|
||||
1420 IF RND(1)>.4 THEN 1440
|
||||
1430 GOTO 1300
|
||||
1440 PRINT "BALL PASSED BACK TO YOU.";
|
||||
1450 GOTO 430
|
||||
1500 IF 7/D*RND(1)>.875 THEN 1600
|
||||
1510 PRINT "SHOOTER FOULED. TWO SHOTS."
|
||||
1520 GOSUB 4000
|
||||
1530 GOTO 3000
|
||||
1600 IF 7/D*RND(1)>.925 THEN 1630
|
||||
1610 PRINT "SHOT BLOCKED. ";O$;"'S BALL."
|
||||
1620 GOTO 3000
|
||||
1630 PRINT "CHARGING FOUL. DARTMOUTH LOSES THE BALL."
|
||||
1640 GOTO 3000
|
||||
1700 PRINT "SET SHOT."
|
||||
1710 GOTO 1330
|
||||
2010 INPUT "YOUR NEW DEFENSIVE ALLIGNMENT IS";D
|
||||
2030 IF D<6 THEN 2010
|
||||
2040 GOTO 425
|
||||
3000 P=1
|
||||
3005 T=T+1
|
||||
3008 IF T=50 THEN 8000
|
||||
3012 GOTO 3018
|
||||
3015 GOSUB 600
|
||||
3018 PRINT
|
||||
3020 Z1=10/4*RND(1)+1
|
||||
3030 IF Z1>2 THEN 3500
|
||||
3040 PRINT "JUMP SHOT."
|
||||
3050 IF 8/D*RND(1)>.35 THEN 3100
|
||||
3060 PRINT "SHOT IS GOOD."
|
||||
3080 GOSUB 6000
|
||||
3090 GOTO 425
|
||||
3100 IF 8/D*RND(1)>.75 THEN 3200
|
||||
3105 PRINT "SHOT IS OFF RIM."
|
||||
3110 IF D/6*RND(1)>.5 THEN 3150
|
||||
3120 PRINT "DARTMOUTH CONTROLS THE REBOUND."
|
||||
3130 GOTO 425
|
||||
3150 PRINT O$;" CONTROLS THE REBOUND."
|
||||
3160 IF D=6 THEN 5000
|
||||
3165 IF RND(1)>.5 THEN 3175
|
||||
3168 PRINT "PASS BACK TO ";O$;" GUARD."
|
||||
3170 GOTO 3000
|
||||
3175 GOTO 3500
|
||||
3200 IF 8/D*RND(1)>.9 THEN 3310
|
||||
3210 PRINT "PLAYER FOULED. TWO SHOTS."
|
||||
3220 GOSUB 4000
|
||||
3230 GOTO 425
|
||||
3310 PRINT "OFFENSIVE FOUL. DARTMOUTH'S BALL."
|
||||
3320 GOTO 425
|
||||
3500 IF Z1>3 THEN 3800
|
||||
3510 PRINT "LAY UP."
|
||||
3520 IF 7/D*RND(1)>.413 THEN 3600
|
||||
3530 PRINT "SHOT IS GOOD."
|
||||
3540 GOSUB 6000
|
||||
3550 GOTO 425
|
||||
3600 PRINT "SHOT IS MISSED."
|
||||
3610 GOTO 3110
|
||||
3800 PRINT "SET SHOT."
|
||||
3810 GOTO 3520
|
||||
4000 REM FOUL SHOOTING
|
||||
4010 IF RND(1)>.49 THEN 4050
|
||||
4020 PRINT "SHOOTER MAKES BOTH SHOTS."
|
||||
4030 S(1-P)=S(1-P)+2
|
||||
4040 GOSUB 6010
|
||||
4041 RETURN
|
||||
4050 IF RND(1)>.75 THEN 4100
|
||||
4060 PRINT "SHOOTER MAKES ONE SHOT AND MISSES ONE."
|
||||
4070 S(1-P)=S(1-P)+1
|
||||
4080 GOTO 4040
|
||||
4100 PRINT "BOTH SHOTS MISSED."
|
||||
4110 GOTO 4040
|
||||
5000 IF RND(1)>.75 THEN 5010
|
||||
5005 GOTO 3165
|
||||
5010 PRINT "BALL STOLEN. EASY LAY UP FOR DARTMOUTH."
|
||||
5015 GOSUB 7000
|
||||
5030 GOTO 3000
|
||||
5100 IF RND(1)>.6 THEN 5120
|
||||
5110 GOTO 1160
|
||||
5120 PRINT "PASS STOLEN BY ";O$;" EASY LAYUP."
|
||||
5130 GOSUB 6000
|
||||
5140 GOTO 425
|
||||
6000 S(0)=S(0)+2
|
||||
6010 PRINT "SCORE: ";S(1);"TO";S(0)
|
||||
6020 RETURN
|
||||
7000 S(1)=S(1)+2
|
||||
7010 GOSUB 6010
|
||||
7020 RETURN
|
||||
8000 PRINT:PRINT " ***** END OF FIRST HALF *****":PRINT
|
||||
8010 PRINT "SCORE: DARTMOUTH:";S(1);" ";O$;":";S(0)
|
||||
8015 PRINT
|
||||
8016 PRINT
|
||||
8020 GOTO 370
|
||||
9999 END
|
||||
3
07_Basketball/csharp/README.md
Normal file
3
07_Basketball/csharp/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)
|
||||
3
07_Basketball/java/README.md
Normal file
3
07_Basketball/java/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Oracle Java](https://openjdk.java.net/)
|
||||
3
07_Basketball/javascript/README.md
Normal file
3
07_Basketball/javascript/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells)
|
||||
9
07_Basketball/javascript/basketball.html
Normal file
9
07_Basketball/javascript/basketball.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>BASKETBALL</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="basketball.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
384
07_Basketball/javascript/basketball.js
Normal file
384
07_Basketball/javascript/basketball.js
Normal file
@@ -0,0 +1,384 @@
|
||||
// BASKETBALL
|
||||
//
|
||||
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
|
||||
//
|
||||
|
||||
function print(str)
|
||||
{
|
||||
document.getElementById("output").appendChild(document.createTextNode(str));
|
||||
}
|
||||
|
||||
function input()
|
||||
{
|
||||
var input_element;
|
||||
var input_str;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
input_element = document.createElement("INPUT");
|
||||
|
||||
print("? ");
|
||||
input_element.setAttribute("type", "text");
|
||||
input_element.setAttribute("length", "50");
|
||||
document.getElementById("output").appendChild(input_element);
|
||||
input_element.focus();
|
||||
input_str = undefined;
|
||||
input_element.addEventListener("keydown", function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
input_str = input_element.value;
|
||||
document.getElementById("output").removeChild(input_element);
|
||||
print(input_str);
|
||||
print("\n");
|
||||
resolve(input_str);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tab(space)
|
||||
{
|
||||
var str = "";
|
||||
while (space-- > 0)
|
||||
str += " ";
|
||||
return str;
|
||||
}
|
||||
|
||||
var s = [0, 0];
|
||||
var z;
|
||||
var d;
|
||||
var p;
|
||||
var your_turn;
|
||||
var game_restart;
|
||||
|
||||
function two_minutes()
|
||||
{
|
||||
print("\n");
|
||||
print(" *** TWO MINUTES LEFT IN THE GAME ***\n");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
function show_scores()
|
||||
{
|
||||
print("SCORE: " + s[1] + " TO " + s[0] + "\n");
|
||||
}
|
||||
|
||||
function score_computer()
|
||||
{
|
||||
s[0] = s[0] + 2;
|
||||
show_scores();
|
||||
}
|
||||
|
||||
function score_player()
|
||||
{
|
||||
s[1] = s[1] + 2;
|
||||
show_scores();
|
||||
}
|
||||
|
||||
function half_time()
|
||||
{
|
||||
print("\n");
|
||||
print(" ***** END OF FIRST HALF *****\n");
|
||||
print("SCORE: DARMOUTH: " + s[1] + " " + os + ": " + s[0] + "\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
function foul()
|
||||
{
|
||||
if (Math.random() <= 0.49) {
|
||||
print("SHOOTER MAKES BOTH SHOTS.\n");
|
||||
s[1 - p] = s[1 - p] + 2;
|
||||
show_scores();
|
||||
} else if (Math.random() <= 0.75) {
|
||||
print("SHOOTER MAKES ONE SHOT AND MISSES ONE.\n");
|
||||
s[1 - p] = s[1 - p] + 1;
|
||||
show_scores();
|
||||
} else {
|
||||
print("BOTH SHOTS MISSED.\n");
|
||||
show_scores();
|
||||
}
|
||||
}
|
||||
|
||||
function player_play()
|
||||
{
|
||||
if (z == 1 || z == 2) {
|
||||
t++;
|
||||
if (t == 50) {
|
||||
half_time();
|
||||
game_restart = 1;
|
||||
return;
|
||||
}
|
||||
if (t == 92)
|
||||
two_minutes();
|
||||
print("JUMP SHOT\n");
|
||||
if (Math.random() <= 0.341 * d / 8) {
|
||||
print("SHOT IS GOOD.\n");
|
||||
score_player();
|
||||
return;
|
||||
}
|
||||
if (Math.random() <= 0.682 * d / 8) {
|
||||
print("SHOT IS OFF TARGET.\n");
|
||||
if (d / 6 * Math.random() >= 0.45) {
|
||||
print("REBOUND TO " + os + "\n");
|
||||
return;
|
||||
}
|
||||
print("DARTMOUTH CONTROLS THE REBOUND.\n");
|
||||
if (Math.random() > 0.4) {
|
||||
if (d == 6) {
|
||||
if (Math.random() > 0.6) {
|
||||
print("PASS STOLEN BY " + os + " EASY LAYUP.\n");
|
||||
score_computer();
|
||||
return;
|
||||
}
|
||||
}
|
||||
print("BALL PASSED BACK TO YOU. ");
|
||||
your_turn = 1;
|
||||
return;
|
||||
}
|
||||
} else if (Math.random() <= 0.782 * d / 8) {
|
||||
print("SHOT IS BLOCKED. BALL CONTROLLED BY ");
|
||||
if (Math.random() <= 0.5) {
|
||||
print("DARTMOUTH.\n");
|
||||
your_turn = 1;
|
||||
return;
|
||||
}
|
||||
print(os + ".\n");
|
||||
return;
|
||||
} else if (Math.random() <= 0.843 * d / 8) {
|
||||
print("SHOOTER IS FOULED. TWO SHOTS.\n");
|
||||
foul();
|
||||
return;
|
||||
// In original code but lines 1180-1195 aren't used (maybe replicate from computer's play)
|
||||
// } else if (Math.random() <= 0.9 * d / 8) {
|
||||
// print("PLAYER FOULED, TWO SHOTS.\n");
|
||||
// foul();
|
||||
// return;
|
||||
} else {
|
||||
print("CHARGING FOUL. DARTMOUTH LOSES BALL.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
if (++t == 50) {
|
||||
half_time();
|
||||
game_restart = 1;
|
||||
return;
|
||||
}
|
||||
if (t == 92)
|
||||
two_minutes();
|
||||
if (z == 0) {
|
||||
your_turn = 2;
|
||||
return;
|
||||
}
|
||||
if (z <= 3)
|
||||
print("LAY UP.\n");
|
||||
else
|
||||
print("SET SHOT.\n");
|
||||
if (7 / d * Math.random() <= 0.4) {
|
||||
print("SHOT IS GOOD. TWO POINTS.\n");
|
||||
score_player();
|
||||
return;
|
||||
}
|
||||
if (7 / d * Math.random() <= 0.7) {
|
||||
print("SHOT IS OFF THE RIM.\n");
|
||||
if (Math.random() <= 2.0 / 3.0) {
|
||||
print(os + " CONTROLS THE REBOUND.\n");
|
||||
return;
|
||||
}
|
||||
print("DARMOUTH CONTROLS THE REBOUND.\n");
|
||||
if (Math.random() <= 0.4)
|
||||
continue;
|
||||
print("BALL PASSED BACK TO YOU.\n");
|
||||
your_turn = 1;
|
||||
return;
|
||||
}
|
||||
if (7 /d * Math.random() <= 0.875) {
|
||||
print("SHOOTER FOULED. TWO SHOTS.\n");
|
||||
foul();
|
||||
return;
|
||||
}
|
||||
if (7 /d * Math.random() <= 0.925) {
|
||||
print("SHOT BLOCKED. " + os + "'S BALL.\n");
|
||||
return;
|
||||
}
|
||||
print("CHARGING FOUL. DARTHMOUTH LOSES THE BALL.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function computer_play()
|
||||
{
|
||||
rebound = 0;
|
||||
while (1) {
|
||||
p = 1;
|
||||
if (++t == 50) {
|
||||
half_time();
|
||||
game_restart = 1;
|
||||
return;
|
||||
}
|
||||
print("\n");
|
||||
z1 = 10 / 4 * Math.random() + 1;
|
||||
if (z1 <= 2) {
|
||||
print("JUMP SHOT.\n");
|
||||
if (8 / d * Math.random() <= 0.35) {
|
||||
print("SHOT IS GOOD.\n");
|
||||
score_computer();
|
||||
return;
|
||||
}
|
||||
if (8 / d * Math.random() <= 0.75) {
|
||||
print("SHOT IS OFF RIM.\n");
|
||||
if (d / 6 * Math.random() <= 0.5) {
|
||||
print("DARMOUTH CONTROLS THE REBOUND.\n");
|
||||
return;
|
||||
}
|
||||
print(os + " CONTROLS THE REBOUND.\n");
|
||||
if (d == 6) {
|
||||
if (Math.random() <= 0.75) {
|
||||
print("BALL STOLEN. EASY LAP UP FOR DARTMOUTH.\n");
|
||||
score_player();
|
||||
continue;
|
||||
}
|
||||
if (Math.random() > 0.6) {
|
||||
print("PASS STOLEN BY " + os + " EASY LAYUP.\n");
|
||||
score_computer();
|
||||
return;
|
||||
}
|
||||
print("BALL PASSED BACK TO YOU. ");
|
||||
return;
|
||||
}
|
||||
if (Math.random() <= 0.5) {
|
||||
print("PASS BACK TO " + os + " GUARD.\n");
|
||||
continue;
|
||||
}
|
||||
} else if (8 / d * Math.random() <= 0.90) {
|
||||
print("PLAYER FOULED. TWO SHOTS.\n");
|
||||
foul();
|
||||
return;
|
||||
} else {
|
||||
print("OFFENSIVE FOUL. DARTMOUTH'S BALL.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
if (z1 > 3) {
|
||||
print("SET SHOT.\n");
|
||||
} else {
|
||||
print("LAY UP.\n");
|
||||
}
|
||||
if (7 / d * Math.random() <= 0.413) {
|
||||
print("SHOT IS GOOD.\n");
|
||||
score_computer();
|
||||
return;
|
||||
}
|
||||
print("SHOT IS MISSED.\n");
|
||||
// Spaguetti jump, better to replicate code
|
||||
if (d / 6 * Math.random() <= 0.5) {
|
||||
print("DARMOUTH CONTROLS THE REBOUND.\n");
|
||||
return;
|
||||
}
|
||||
print(os + " CONTROLS THE REBOUND.\n");
|
||||
if (d == 6) {
|
||||
if (Math.random() <= 0.75) {
|
||||
print("BALL STOLEN. EASY LAP UP FOR DARTMOUTH.\n");
|
||||
score_player();
|
||||
break;
|
||||
}
|
||||
if (Math.random() > 0.6) {
|
||||
print("PASS STOLEN BY " + os + " EASY LAYUP.\n");
|
||||
score_computer();
|
||||
return;
|
||||
}
|
||||
print("BALL PASSED BACK TO YOU. ");
|
||||
return;
|
||||
}
|
||||
if (Math.random() <= 0.5) {
|
||||
print("PASS BACK TO " + os + " GUARD.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main program
|
||||
async function main()
|
||||
{
|
||||
print(tab(31) + "BASKETBALL\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("THIS IS DARTMOUTH COLLEGE BASKETBALL. YOU WILL BE DARTMOUTH\n");
|
||||
print(" CAPTAIN AND PLAYMAKER. CALL SHOTS AS FOLLOWS: 1. LONG\n");
|
||||
print(" (30 FT.) JUMP SHOT; 2. SHORT (15 FT.) JUMP SHOT; 3. LAY\n");
|
||||
print(" UP; 4. SET SHOT.\n");
|
||||
print("BOTH TEAMS WILL USE THE SAME DEFENSE. CALL DEFENSE AS\n");
|
||||
print("FOLLOWS: 6. PRESS; 6.5 MAN-TO MAN; 7. ZONE; 7.5 NONE.\n");
|
||||
print("TO CHANGE DEFENSE, JUST TYPE 0 AS YOUR NEXT SHOT.\n");
|
||||
print("YOUR STARTING DEFENSE WILL BE");
|
||||
t = 0;
|
||||
p = 0;
|
||||
d = parseFloat(await input());
|
||||
if (d < 6) {
|
||||
your_turn = 2;
|
||||
} else {
|
||||
print("\n");
|
||||
print("CHOOSE YOUR OPPONENT");
|
||||
os = await input();
|
||||
game_restart = 1;
|
||||
}
|
||||
while (1) {
|
||||
if (game_restart) {
|
||||
game_restart = 0;
|
||||
print("CENTER JUMP\n");
|
||||
if (Math.random() > 3.0 / 5.0) {
|
||||
print("DARMOUTH CONTROLS THE TAP.\n");
|
||||
} else {
|
||||
print(os + " CONTROLS THE TAP.\n");
|
||||
computer_play();
|
||||
}
|
||||
}
|
||||
if (your_turn == 2) {
|
||||
print("YOUR NEW DEFENSIVE ALLIGNMENT IS");
|
||||
d = parseFloat(await input());
|
||||
}
|
||||
print("\n");
|
||||
while (1) {
|
||||
print("YOUR SHOT");
|
||||
z = parseInt(await input());
|
||||
p = 0;
|
||||
if (z != Math.floor(z) || z < 0 || z > 4)
|
||||
print("INCORRECT ANSWER. RETYPE IT. ");
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (Math.random() < 0.5 || t < 100) {
|
||||
game_restart = 0;
|
||||
your_turn = 0;
|
||||
player_play();
|
||||
if (game_restart == 0 && your_turn == 0)
|
||||
computer_play();
|
||||
} else {
|
||||
print("\n");
|
||||
if (s[1] == s[0]) {
|
||||
print("\n");
|
||||
print(" ***** END OF SECOND HALF *****\n");
|
||||
print("\n");
|
||||
print("SCORE AT END OF REGULATION TIME:\n");
|
||||
print(" DARTMOUTH: " + s[1] + " " + os + ": " + s[0] + "\n");
|
||||
print("\n");
|
||||
print("BEGIN TWO MINUTE OVERTIME PERIOD\n");
|
||||
t = 93;
|
||||
print("CENTER JUMP\n");
|
||||
if (Math.random() > 3.0 / 5.0)
|
||||
print("DARMOUTH CONTROLS THE TAP.\n");
|
||||
else
|
||||
print(os + " CONTROLS THE TAP.\n");
|
||||
} else {
|
||||
print(" ***** END OF GAME *****\n");
|
||||
print("FINAL SCORE: DARMOUTH: " + s[1] + " " + os + ": " + s[0] + "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
3
07_Basketball/pascal/README.md
Normal file
3
07_Basketball/pascal/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))
|
||||
3
07_Basketball/perl/README.md
Normal file
3
07_Basketball/perl/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Perl](https://www.perl.org/)
|
||||
3
07_Basketball/python/README.md
Normal file
3
07_Basketball/python/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Python](https://www.python.org/about/)
|
||||
3
07_Basketball/ruby/README.md
Normal file
3
07_Basketball/ruby/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Ruby](https://www.ruby-lang.org/en/)
|
||||
3
07_Basketball/vbnet/README.md
Normal file
3
07_Basketball/vbnet/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original BASIC source [downloaded from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Visual Basic .NET](https://en.wikipedia.org/wiki/Visual_Basic_.NET)
|
||||
Reference in New Issue
Block a user