簡易的文字遊戲

Description

Description

國立暨南國際大學  應用材料及光電工程學系  學士班一年級

作者:詹敬、陳駿翔、蔡昀卲、陳俊融、張皓筑、謝誠哲

指導教授:曹永忠 博士

 

概述:

這是一款文字探險遊戲,透過每個選項的選擇,搭配Arduino開發板,創作出簡單且易懂的遊戲。

創作理念:

既簡單又省錢,也能使大家輕鬆融入遊戲,體驗與接觸Arduino。

運用材料

arduino uno 開發版*1

Arduino 程式碼 //writer: tsai1010 const byte buzzer = 5; const byte buttonPin = 2; //選擇選項ex: 0.=> 按零下, 1. => 按一下, 2. => 按兩下 const byte buttonPin2 = 3;//確定選擇: 選擇好選項之後再按 void setup(){pinMode(buttonPin,INPUT);pinMode(buttonPin2,INPUT);pinMode(buzzer,OUTPUT);pinMode(12,OUTPUT);pinMode(13,OUTPUT); Serial.begin(9600); Serial.println(F(“第一章”)); delay(800); Serial.println(F(“你在一個陌生的房間醒來,微弱的月光從一旁的小窗戶透了進來,\n昏暗的房間裡除了牆角擺著的桌椅之外只剩下一盞小窗戶和一扇門。\n你決定:0.走去開門 1.走向窗戶 2.走向桌椅”)); } void loop() { char word1[] = “你站上椅子並看向窗外,窗戶開了一個小縫,\n你嘗試將窗戶打開但它似乎已經變形卡死了,於此同時\n你發現窗戶的縫中有一把鑰匙,可是縫隙實在太窄了,\n手無法伸進去,連手指都只能免強擠進去。\n你決定: 0.用手指勾鑰匙 1.用美工刀勾鑰匙”; char word2[] = “你站上椅子並看向窗外,窗戶開了一個小縫,\n你嘗試將窗戶打開但它似乎已經變形卡死了,於此同時\n你發現窗戶的縫中有一把鑰匙,可是縫隙實在太窄了,\n手無法伸進去,連手指都只能免強擠進去。\n你決定:0.用手指勾鑰匙”; boolean buttonstate = LOW; boolean buttonstate2 = LOW; for(byte a = 0;a > -2;){buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW);if(a==0&&buttonstate2==LOW{digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);Serial.println(F(“你走到門前轉動門把卻發現門鎖住了。\n你決定: 0.走向窗戶 1.走向桌椅”));buttonstate2=HIGH;digitalWrite(12,LOW); for(byte a = 0;a > -2;){buttonstate=digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstateHIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2==LOW){Serial.println(F(“由於窗戶在較高處,你無法直接看到外面。\n你決定: 0.走向桌椅”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;){ buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“老舊的桌椅上佈滿了灰塵,椅子上放著一把美工刀,刀下壓著一張紙條\n你決定: 0.拿起美工刀 1.拿起紙條”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;){ buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstat=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.拿起紙張”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;){ buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(word1);buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW);for(bytea = 0;a>-2;) { buttonstate =digitalRead(buttonPin); buttonstate2=digitalRead(buttonPin2);if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a = 0;} continue; } } if(a==1&& buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 =HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate=digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } }if(a==2) {a=0;} continue; } }if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”));buttonstate2 = HIGH; delay(200); for(byte a = 0;a>-2;){buttonstate=digitalRead(buttonPin);buttonstate2=digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(word1);buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW);for(bytea = 0;a>-2;){buttonstate=digitalRead(buttonPin);buttonstate2=digitalRead(buttonPin2);if(buttonstate==LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } }if(a==1){a=0;}continue;}}if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; }}if(a==1&&buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.拿起美工刀”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;){ buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(word1);buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW);for(bytea= 0;a>-2;){buttonstate=digitalRead(buttonPin);buttonstate2=digitalRead(buttonPin2);if(buttonstate==LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} } } if(a==1 && buttonstate2 ==LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } }if(a==2{a=0;}continue;}}if(a==1&& buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate= HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate =HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(word2); buttonstate2 = HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate= HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate =HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a = 0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2==LOW){Serial.println(F(“老舊的桌椅上佈滿了灰塵,椅子上放著一把美工刀,刀下壓著一張紙條。\n你決定: 0.拿起美工刀 1.拿起紙條\n”)); buttonstate2 = HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;){ buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate= HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate =HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.拿起紙張”));buttonstate2 = HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate= HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate =HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate =digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate= HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate =HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(word1); buttonstate2 =HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate=digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW){Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;){buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW){a++;buttonstate=HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);}buttonstate=HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”));buttonstate2=HIGH;digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.拿起美工刀”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.print(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a = 0;} continue; } } if(a==2) {a = 0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } if(a==2) {a=0;} continue; } } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2==LOW) {Serial.println(F(“由於窗戶在較高處,你無法直接看到外面。\n你決定: 0.走向門口 1.走向桌椅”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2==LOW) {Serial.println(F(“你走到門前轉動門把卻發現門鎖住了。\n你決定: 0.走向桌椅”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“老舊的桌椅上佈滿了灰塵,椅子上放著一把美工刀,刀下壓著一張紙條\n你決定: 0.拿起美工刀 1.拿起紙條”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.拿起紙張”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; delay(200); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.拿起美工刀”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2==LOW) {Serial.println(F(“老舊的桌椅上佈滿了灰塵,椅子上放著一把美工刀,刀下壓著一張紙條。\n你決定: 0.拿起美工刀 1.拿起紙條”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.拿起紙張”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.拿起美工刀”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2 && buttonstate2==LOW) {Serial.println(F(“老舊的桌椅上佈滿了灰塵,椅子上放著一把美工刀,刀下壓著一張紙條\n你決定: 0.拿起美工刀 1.拿起紙條”)); buttonstate2 = HIGH; delay(200); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2==LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.拿起紙張”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜。\”\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2==LOW) {Serial.println(F(“紙條的背面有著潦草的字跡寫著:\”藍色的憂鬱凝結了夜色,紅色的憤怒打破了平靜\”\n你決定: 0.拿起美工刀”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a > -2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“鋒利的刀片,就像新的一樣,和桌椅形成強烈的對比,\n你將美工刀收進口袋。\n你決定: 0.將椅子拉到窗邊 1.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word1); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你決定: 0.用美工刀撬開門鎖”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷,你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你小心翼翼地取出鑰匙\n你決定: 0.用鑰匙打開門 1.用美工刀撬開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.用鑰匙打開門”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“你順利的把門打開!!”));} if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1 && buttonstate2 == LOW) {Serial.println(F(“你不小心將刀片弄斷\n你決定: 0.將椅子拉到窗邊”)); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(word2); buttonstate2 = HIGH; digitalWrite(12,HIGH);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);delay(100);digitalWrite(5,HIGH);delay(100);digitalWrite(5,LOW);digitalWrite(12,LOW); for(byte a = 0;a>-2;) { buttonstate = digitalRead(buttonPin); buttonstate2 = digitalRead(buttonPin2); if(buttonstate == LOW) {a++;buttonstate = HIGH;digitalWrite(13,HIGH);digitalWrite(5,HIGH);delay(200);} buttonstate = HIGH;digitalWrite(13,LOW);digitalWrite(5,LOW); if(a==0 && buttonstate2 == LOW) {Serial.println(F(“很不幸的,你不小心把鑰匙推出窗外。\n你失去了所有逃生的機會!!”));} if(a==1) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==1) {a=0;} continue; } } if(a==2) {a=0;} continue; } } if(a==3) {a=0;} continue; } }

結論:

在創作編寫程式時,一直在思考與調整程式碼的編寫方式及排序,寫出來的那一刻是真的很開心,能和大家共享這份喜悅。同時也從中學習到了不少知識與經驗。期望往後能有更多的機會來嘗試與接觸這類的東西。

 

(MakerPRO 編輯部代發)

MakerPRO編輯部

MakerPRO編輯部

MakerPRO.cc為華人圈最專注於Maker創新創業、物聯網及共享經濟報導及共筆發表的專業媒體,不論是趨勢分析與評論,或創新實作文章,在華文創新創業媒體領域都具有重要的影響力。
MakerPRO編輯部

Latest posts by MakerPRO編輯部 (see all)

    Contact

    Contact
    • Category
      Arduino
    • Tags
      暨大

    Project簡述

    Project簡述
    • 簡述
      這是一款文字探險遊戲,透過每個選項的選擇,搭配Arduino開發板,創作出簡單且易懂的遊戲。
    • 作者
      詹敬、陳駿翔、蔡昀卲、陳俊融、張皓筑、謝誠哲

    您的姓名 〈需填寫〉

    您的電子郵件信箱 〈需填寫〉

    主旨

    您的信件內容