about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--js/canvas/game.js2
-rw-r--r--perl/game.pl66
2 files changed, 67 insertions, 1 deletions
diff --git a/js/canvas/game.js b/js/canvas/game.js
index 04519c8..ea05b7f 100644
--- a/js/canvas/game.js
+++ b/js/canvas/game.js
@@ -90,4 +90,4 @@ function gameLoop() {
 }
 
 // start the game loop
-requestAnimationFrame(gameLoop);
+requestAnimationFrame(gameLoop);
\ No newline at end of file
diff --git a/perl/game.pl b/perl/game.pl
new file mode 100644
index 0000000..a6bcb00
--- /dev/null
+++ b/perl/game.pl
@@ -0,0 +1,66 @@
+%rooms = (
+  entrance => {
+    description => "You enter a dimly lit room with a heavy wooden door to the north and a narrow hallway to the east.",
+    exits => { north => "hallway", east => "storage" },
+    items => [],
+  },
+  hallway => {
+    description => "The hallway stretches to the north and south. A faint light flickers at the end of the south corridor.",
+    exits => { north => "bedroom", south => "livingRoom" },
+    items => [],
+  },
+  bedroom => {
+    description => "The bedroom is cozy and inviting. A large bed dominates the room, and a dresser stands against the wall.",
+    exits => { south => "hallway" },
+    items => [],
+  },
+  livingRoom => {
+    description => "The living room is spacious and warmly lit. A comfortable couch sits in front of a fireplace, and a large bookshelf lines the wall.",
+    exits => { north => "hallway" },
+    items => [],
+  },
+  kitchen => {
+    description => "The kitchen is well-equipped with modern appliances and a large dining table. A faint glow emanates from a flashlight on the countertop.",
+    exits => { south => "livingRoom" },
+    items => ["flashlight"],
+  },
+  backyard => {
+    description => "The backyard is a tranquil oasis with lush greenery and a towering oak tree. A gentle breeze rustles the leaves, creating a peaceful atmosphere.",
+    exits => { north => "kitchen" },
+    items => [],
+  },
+);
+
+
+$currentRoom = $rooms{entrance};
+@inventory = ();
+
+do {
+  print $currentRoom->{description} . "\n";
+
+  $input = <STDIN>;
+  chomp($input);
+
+  if ($input eq "leave") {
+    exit;
+  } elsif ($input eq "inventory") {
+    print "Inventory: " . join(", ", @inventory) . "\n";
+  } elsif ($input =~ /^take\s+(\w+)/) {
+    $itemName = $1;
+    if (grep { $_ eq $itemName } @{$currentRoom->{items}}) {
+      push @inventory, $itemName;
+      splice @{$currentRoom->{items}}, grep { $_ eq $itemName } 1;
+      print "You picked up the $itemName.\n";
+    } else {
+      print "There is no $itemName in this room.\n";
+    }
+  } elsif ($input eq "help") {
+    print "Available commands: north, south, east, west, inventory, take item, leave\n";
+  } else {
+    if (exists $currentRoom->{exits}->{$input}) {
+      $currentRoom = $rooms{$currentRoom->{exits}->{$input}};
+    } else {
+      print "Invalid direction. Please enter a valid direction or type 'help' for assistance or 'leave' to end the exploration.\n";
+    }
+  }
+} while (1);
9430e995a64956b36331ce3629b9'>f07bb12f ^
34a60763 ^
c776804d ^
f07bb12f ^

34a60763 ^
f07bb12f ^



34a60763 ^





f07bb12f ^









34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

f07bb12f ^

34a60763 ^

f07bb12f ^






c9383c72 ^
f07bb12f ^




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