Skip to content

Instantly share code, notes, and snippets.

@Sinthorion
Last active October 26, 2023 12:18
Show Gist options
  • Select an option

  • Save Sinthorion/e637f35d06f337fc2516be6497d4c829 to your computer and use it in GitHub Desktop.

Select an option

Save Sinthorion/e637f35d06f337fc2516be6497d4c829 to your computer and use it in GitHub Desktop.
Game written in Makefile. Run with `make -s start`. Run subsequent command with `make -s your.command`
clean: clean.room clean.object clean.item
clean.room:
rm -f *.room
clean.object:
rm -f *.object
clean.item:
rm -f *.item
start: clean room1
room1:
echo "You are standing in a small room. There is a locked door to another room. There is a table."
echo "You can:"
echo " - open.door"
echo " - examine.table"
touch door.object
touch table.object
examine.table: table.object
if [ ! -e key.item ]; then \
echo "There is a key on the table. You can take it (take.key)."; \
touch key.object; \
else \
echo "The table is empty"; \
fi
take.key: key.object
echo "You take the key."
rm key.object
touch key.item
open.door: door.object
if [ ! -e key.item ]; then \
echo "The door is locked. Maybe you need a key?"; \
else \
echo "You open the door with the key. You can now leave the room (leave.room)."; \
rm door.object; \
touch room2.room; \
fi
leave.room: room2
room2: room2.room clean.room clean.object
echo "Congratulations! You have escaped the room"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment