Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.11 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>Document</title>
  9. <style>
  10. @font-face {
  11. font-family: czcionka;
  12. src: url(fonts/PressStart2P.ttf);
  13. }
  14.  
  15. font {
  16. color: rgb(165, 162, 178);
  17. }
  18.  
  19. * {
  20. font-family: czcionka;
  21. /* background-color: rgb(57, 57, 57); */
  22. background-color: black;
  23. color: lightgrey;
  24. }
  25.  
  26. p {
  27. color: lightgrey;
  28. }
  29.  
  30. #plansza {
  31. height: 160px;
  32. width: 256px;
  33. background-repeat: no-repeat;
  34. background-size: cover;
  35. border: 2px outset white;
  36. }
  37.  
  38. button {
  39. color: white;
  40. }
  41.  
  42. #inter {
  43. width: 800px;
  44. position: relative;
  45. }
  46.  
  47. #divInfo {}
  48.  
  49. #voc {
  50. position: absolute;
  51. z-index: 1;
  52. width: 98%;
  53. }
  54.  
  55. input[type=text] {
  56. color: white;
  57. border: 1px solid black;
  58. outline: none;
  59. }
  60.  
  61. #kompas {
  62. position: absolute;
  63. left: 350px;
  64. top: 60px;
  65. height: 160px;
  66. width: 256px;
  67. background-size: 100%;
  68. background-image: url('img/kompass.bmp');
  69. background-repeat: no-repeat;
  70.  
  71. }
  72.  
  73. #S {
  74. position: absolute;
  75. bottom: 20px;
  76. left: 120px;
  77. }
  78.  
  79. #W {
  80. position: absolute;
  81. top: 25px;
  82. left: -10px;
  83. }
  84.  
  85. #N {
  86. position: absolute;
  87. left: 115px;
  88. top: -22px;
  89. }
  90.  
  91. #E {
  92. position: absolute;
  93. right: -10px;
  94. top: 25px;
  95. }
  96. </style>
  97. <script>
  98. var caps = true
  99.  
  100. function _It(id, przedmiot, flaga, nazwa) {
  101. this.id = id;
  102. this.przedmiot = przedmiot;
  103. this.flaga = flaga;
  104. this.nazwa = nazwa;
  105. }
  106.  
  107. function _Location(miejsce, grafika, tlo, moze, przedmiot) {
  108. this.miejsce = miejsce;
  109. this.grafika = grafika;
  110. this.tlo = tlo
  111. this.moze = moze
  112. this.element = null;
  113. this.item = []
  114. this.przedmiot = przedmiot;
  115. // this.init = function () {
  116. // var div = document.createElement("div");
  117. // div.className = "location";
  118. // this.element = div;
  119. // document.getElementById("plansza").appendChild(div);
  120. // }
  121. // this.init();
  122. }
  123. var zmien = 0
  124. var strona
  125. var c = []
  126. var kierunki = ["S", "W", "N", "E"]
  127. var czy = false
  128.  
  129. document.addEventListener("DOMContentLoaded", function (event) {
  130. var ekwipunek = []
  131. var kompas = document.createElement("div")
  132. kompas.setAttribute("id", "kompas")
  133. document.body.appendChild(kompas)
  134. for (var i = 0; i < 4; i++) {
  135. var pe = document.createElement("p")
  136. pe.setAttribute("id", kierunki[i])
  137. kompas.append(pe)
  138. }
  139. function ustawKompas(kierunek) {
  140. for (var i = 0; i < 4; i++) {
  141. document.getElementById(kierunki[i]).innerHTML = ""
  142. }
  143. setTimeout(function () {
  144. document.getElementById(kierunek).innerHTML = kierunek
  145. }, 0);
  146. }
  147. przedmioty = {
  148. "10": ["10", "a KEY", 1, "KEY"],
  149. "11": ["11", "an AXE", 1, "AXE"],
  150. "12": ["12", "STICKS", 1, "STICKS"],
  151. "13": ["13", "sheeplegs", 0, "sheeplegs"],
  152. "14": ["14", "MUSHROOMS", 1, "MUSHROOMS"],
  153. "15": ["15", "MONEY", 1, "MONEY"],
  154. "16": ["16", "a BARREL", 1, "BARREL"],
  155. "17": ["17", "a sheeptrunk", 0, "sheeptrunk"],
  156. "18": ["18", "BERRIES", 1, "BERRIES"],
  157. "19": ["19", "WOOL", 1, "WOOL"],
  158. "20": ["20", "a sheepskin", 0, "sheepskin"],
  159. "21": ["21", "a BAG", 1, "BAG"],
  160. "22": ["22", "a RAG", 1, "RAG"],
  161. "23": ["23", "a sheephead", 0, "sheephead"],
  162. "24": ["24", "a SPADE", 1, "SPADE"],
  163. "25": ["25", "SULPHUR", 1, "SULPHUR"],
  164. "26": ["26", "a solid poison", 0, "solid poison"],
  165. "27": ["27", "a BUCKET", 1, "BUCKET"],
  166. "28": ["28", "TAR", 1, "TAR"],
  167. "29": ["29", "a liquid poison", 0, "liquid poison"],
  168. "30": ["30", "a dead dragon", 0, "dead dragon"],
  169. "31": ["31", "a STONE", 1, "STONE"],
  170. "32": ["32", "a FISH", 1, "FISH"],
  171. "33": ["33", "a KNIFE", 1, "KNIFE"],
  172. "34": ["34", "a DRAGONSKIN", 1, "DRAGONSKIN"],
  173. "35": ["35", "a dragonskin SHOES", 1, "SHOES"],
  174. "36": ["36", "a PRIZE", 1, "PRIZE"]
  175. },
  176. zaleznosci = {
  177. "10": ["10", "56", "11", "You opened a tool shed and took an axe"],
  178. "11": ["11", "67", "12", "You cut sticks for sheeplegs"],
  179. "12": ["12", "43", "13", "You prepared legs for your fake sheep", "OK"],
  180. "14": ["14", "34", "15", "The tavern owner paid you money"],
  181. "15": ["15", "37", "16", "The cooper sold you a new barrel"],
  182. "16": ["16", "43", "17", "You made a nice sheeptrunk", "OK"],
  183. "18": ["18", "36", "19", "The butcher gave you wool"],
  184. "19": ["19", "43", "20", "You prepared skin for your fake sheep", "OK"],
  185. "21": ["21", "57", "22", "You used your tools to make a rag"],
  186. "22": ["22", "43", "23", "You made a fake sheephead", "OK"],
  187. "24": ["24", "11", "25", "You are digging... (timeout) and digging... (timeout) That's enough sulphur for you"],
  188. "25": ["25", "43", "26", "You prepared a solid poison", "OK"],
  189. "27": ["27", "21", "28", "You got a bucket full of tar"],
  190. "28": ["28", "43", "29", "You prepared a liquid poison", "OK"],
  191. "final": ["final", "43", "37", "Your fake sheep is full of poison and ready to be eaten by the dragon"],
  192. "37": ["37", "43", "30", "The dragon noticed your gift... (timeout) The dragon ate your sheep and died! "], //- podmiana grafiki na lokacji(martwy smok)!
  193. "33": ["33", "43"/* + zabity smok*/, "34", "You cut a piece of dragon's skin"],
  194. "34": ["34", "57", "35", "You used your tools to make shoes"],
  195. "35": ["35", "41", "36", "The King is impressed by your shoes"],
  196. "36": ["36", "0", "0", "ŁINER"]
  197. }
  198. game = {
  199. board: [
  200. [
  201. new _Location("You are inside a brimstone mine", "img/11.gif", "rgb(235,211,64)", [right = 1, left = 0, up = 0, down = 0], []),
  202. new _Location("You are at the entrance to the mine", "img/12.gif", "rgb(89,93,87)", [right = 1, left = 1, up = 0, down = 0], []),
  203. new _Location("A hill", "img/13.gif", "rgb(117,237,243)", [right = 1, left = 1, up = 0, down = 1], [przedmioty["31"]]),
  204. new _Location("Some bushes", "img/14.gif", "rgb(202,230,51)", [right = 1, left = 1, up = 0, down = 0], []),
  205. new _Location("An old deserted hut", "img/15.gif", "rgb(220,204,61)", [right = 1, left = 1, up = 0, down = 0], [przedmioty["27"]]),
  206. new _Location("The edge of a forest", "img/16.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 0, down = 0], []),
  207. new _Location("A dark forest", "img/17.gif", "rgb(140,253,99)", [right = 0, left = 1, up = 0, down = 1], [przedmioty["31"]]),
  208. ],
  209. [
  210. new _Location("A man nearby making tar", "img/21.gif", "rgb(255,190,99)", [right = 1, left = 0, up = 0, down = 1], []),
  211. new _Location("A timber yard", "img/22.gif", "rgb(255,190,99)", [right = 1, left = 1, up = 0, down = 1], []),
  212. new _Location("You are by a roadside shrine", "img/23.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 1, down = 1], [przedmioty["10"]]),
  213. new _Location("You are by a small chapel", "img/24.gif", "rgb(212,229,36)", [right = 1, left = 1, up = 0, down = 0], []),
  214. new _Location("You are on a road leading to a wood", "img/25.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 0, down = 1], []),
  215. new _Location("You are in a forest", "img/26 i 65.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 0, down = 0], []),
  216. new _Location("You are in a deep forest", "img/27 i 67.gif", "rgb(140,253,99)", [right = 0, left = 1, up = 1, down = 0], [przedmioty["18"]]),
  217. ],
  218. [
  219. new _Location("You are by the Vistula River", "img/31.gif", "rgb(122,232,252)", [right = 1, left = 0, up = 1, down = 0], []),
  220. new _Location("You are by the Vistula River", "img/32.gif", "rgb(140,214,255)", [right = 0, left = 1, up = 1, down = 0], [przedmioty["32"]]),
  221. new _Location("You are on a bridge over river", "img/33.gif", "rgb(108,181,242)", [right = 0, left = 0, up = 1, down = 1], []),
  222. new _Location("You are by the old tavern", "img/34.gif", "rgb(255,189,117)", [right = 1, left = 0, up = 0, down = 0], []),
  223. new _Location("You are at the town's end", "img/35.gif", "rgb(255,190,99)", [right = 0, left = 1, up = 1, down = 1], []),
  224. new _Location("You are in a butcher's shop", "img/36.gif", "rgb(255,188,102)", [right = 0, left = 0, up = 0, down = 1], []),
  225. new _Location("You are in a cooper's house", "img/37.gif", "rgb(255,188,102)", [right = 0, left = 0, up = 0, down = 1], [])
  226. ],
  227. [
  228. new _Location("You are in the Wawel Castle", "img/41.gif", "rgb(255,176,141)", [right = 1, left = 0, up = 0, down = 0], []),
  229. new _Location("You are inside a dragon's cave", "img/42.gif", "rgb(198,205,193)", [right = 1, left = 0, up = 1, down = 0], []),
  230. new _Location("A perfect place to set a trap", "img/43.gif", "rgb(255,176,141)", [right = 0, left = 1, up = 1, down = 0], []),
  231. new _Location("You are by the water mill", "img/44.gif", "rgb(255,190,99)", [right = 1, left = 0, up = 0, down = 0], [przedmioty["21"]]),
  232. new _Location("You are at a main crossroad", "img/45.gif", "rgb(255,190,99)", [right = 1, left = 1, up = 1, down = 1], []),
  233. new _Location("You are on a town street", "img/46.gif", " rgb(255,190,99)", [right = 1, left = 1, up = 1, down = 0], []),
  234. new _Location("You are in a frontyard of your house", "img/47.gif", "rgb(255,190,99)", [right = 0, left = 1, up = 1, down = 1], [])
  235.  
  236. ],
  237. [
  238. null, null, null,
  239. new _Location("You are by a swift stream", "img/54.gif", "rgb(108,181,242)", [right = 1, left = 0, up = 0, down = 0], []),
  240. new _Location("You are on a street leading forest", "img/55.gif", "rgb(255,190,99)", [right = 0, left = 1, up = 1, down = 1], [przedmioty["33"]]),
  241. new _Location("You are in a woodcutter's backyard", "img/56.gif", "rgb(255,190,99)", [right = 0, left = 0, up = 0, down = 1], []),
  242. new _Location("You are in a shoemaker's house", "img/57.gif", " rgb(254,194,97)", [right = 0, left = 0, up = 1, down = 0], [])
  243. ],
  244. [
  245. null, null, null,
  246. new _Location("You are in a bleak funeral house", "img/64.gif", "rgb(254,194,97)", [right = 1, left = 0, up = 0, down = 0], [przedmioty["24"]]),
  247. new _Location("You are on a path leading to the wood", "img/26 i 65.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 1, down = 0], []),
  248. new _Location("You are at the edge of a forest", "img/66.gif", "rgb(167,245,63)", [right = 1, left = 1, up = 1, down = 0], []),
  249. new _Location("You are in a deep forest", "img/27 i 67.gif", "rgb(140,253,99)", [right = 0, left = 1, up = 0, down = 0], []),
  250. ]
  251.  
  252. ],
  253. player: {
  254. pos_x: 6, //6
  255. pos_y: 3, //3
  256. sprawdzGdzie: function () {
  257. c = []
  258. strona = []
  259. var tab = [right = 1, left = 1, up = 1, down = 1]
  260. var person = game.board[this.pos_y][this.pos_x]
  261. person.moze.forEach(function (s, i) {
  262. c.push(person.moze[i] == tab[i])
  263. })
  264.  
  265. document.getElementById("N").innerHTML = ""
  266.  
  267. if (c[0] == true) {
  268. strona.push("EAST")
  269. ustawKompas("E")
  270. }
  271. if (c[1] == true) {
  272. strona.push("WEST")
  273. ustawKompas("W")
  274. }
  275. if (c[2] == true) {
  276. strona.push("NORTH")
  277. ustawKompas("N")
  278. }
  279. if (c[3] == true) {
  280. strona.push("SOUTH")
  281. ustawKompas("S")
  282. }
  283. // console.log(strona)
  284. document.getElementById("pierwszy").innerHTML = "You can go " + strona
  285. return strona
  286. },
  287. report: function () {
  288.  
  289. },
  290. refreshkompas: function () {
  291.  
  292. },
  293. ustaw: function (p) {
  294. document.getElementById("plansza").style.backgroundImage = "url('" + p.grafika + "')";
  295. document.getElementById("plansza").style.backgroundColor = p.tlo
  296. document.getElementById("glownyText").innerHTML = p.miejsce
  297. },
  298. go: function (direction) {
  299. c = []
  300. strona = []
  301. // console.log(game.board)
  302. //console.log(game.board[this.pos_y][this.pos_x].moze)
  303. var tab = [right = 1, left = 1, up = 1, down = 1]
  304. var person = game.board[this.pos_y][this.pos_x]
  305. person.moze.forEach(function (s, i) {
  306. c.push(person.moze[i] == tab[i])
  307. })
  308. if (c[0] == true) {
  309. if (direction == "right" && this.pos_x < 6) {
  310. this.pos_x++;
  311. }
  312. }
  313. if (c[1] == true) {
  314. if (direction == "left" && this.pos_x > 0) {
  315. this.pos_x--;
  316. }
  317. }
  318. if (c[2] == true) {
  319. if (direction == "up" && this.pos_y > 0) {
  320. this.pos_y--;
  321. }
  322. }
  323. if (c[3] == true) {
  324. if (direction == "down" && this.pos_y < 6) {
  325. this.pos_y++;
  326. }
  327. }
  328. this.highlight();
  329. },
  330. highlight: function () {
  331. var person = game.board[this.pos_y][this.pos_x];
  332. this.ustaw(person)
  333. game.player.sprawdzPrzedmiot();
  334. game.player.sprawdzGdzie();
  335. game.player.report(person)
  336. },
  337. podnies: function (rzecz) {
  338. var person = game.board[this.pos_y][this.pos_x]
  339. var rzecz = rzecz
  340. console.log(rzecz)
  341. if (ekwipunek.length == 0) {
  342. if (person.przedmiot != undefined) {
  343. for (var i = 0; i < person.przedmiot.length; i++) {
  344. if (person.przedmiot[i][3] == rzecz && person.przedmiot[i][2] == 0) {
  345. document.getElementById("trzecie").innerHTML = " You can't carry it"
  346. }
  347. if (person.przedmiot[i][3] == rzecz && person.przedmiot[i][2] == 1) {
  348. ekwipunek[0] = person.przedmiot[i]
  349. person.przedmiot.splice(i, 1)
  350. document.getElementById("label").innerHTML = "You are taking " + ekwipunek[0][1]
  351. document.getElementById("trzecie").innerHTML = "You are carrying " + ekwipunek[0][1]
  352. break
  353. }
  354. if (person.przedmiot[i][3] != rzecz) {
  355. document.getElementById("label").innerHTML = "There isn't anything like that here"
  356. }
  357. }
  358. }
  359. } else {
  360. console.log("ss")
  361. document.getElementById("label").innerHTML = "You are carrying something"
  362. setTimeout(function () {
  363. document.getElementById("label").innerHTML = "What now?"
  364. document.getElementById("pole").value = ""
  365. document.getElementById("pole").disabled = false;
  366. }, 1000);
  367. }
  368. },
  369. wyrzuc: function (rzecz) {
  370. var person = game.board[this.pos_y][this.pos_x]
  371. var rzecz = rzecz
  372. var licz = 0
  373. for (var i = 0; i < person.przedmiot.length; i++) {
  374. if (person.przedmiot[i][2] == 1) {
  375. licz++
  376. }
  377. }
  378. if (licz < 3) {
  379. if (ekwipunek[0] != undefined) {
  380. if (ekwipunek[0][2] != 0) {
  381. if (ekwipunek[0][3] == rzecz) {
  382. person.przedmiot.push(ekwipunek[0])
  383. ekwipunek = []
  384. document.getElementById("label").innerHTML = "You are about to drop " + rzecz
  385. document.getElementById("trzecie").innerHTML = "You are carrying nothing"
  386. } else {
  387. document.getElementById("label").innerHTML = "You are not carrying it"
  388. }
  389. }
  390. } else if (ekwipunek.length == 0) {
  391. document.getElementById("label").innerHTML = "You are not carrying anything"
  392. }
  393. } else {
  394. document.getElementById("label").innerHTML = "You can't store any more here"
  395. }
  396. },
  397. sprawdzPrzedmiot: function () {
  398. var person = game.board[this.pos_y][this.pos_x]
  399. if (person.przedmiot != undefined) {
  400. var nazwy = ""
  401. for (var i = 0; i < person.przedmiot.length; i++) {
  402. nazwy += person.przedmiot[i][1] + ","
  403. }
  404. document.getElementById("drugi").innerHTML = "You see " + nazwy.substr(0, nazwy.length - 1)
  405. }
  406. if (person.przedmiot == 0) {
  407. document.getElementById("drugi").innerHTML = "You see nothing"
  408. }
  409. return nazwy.substr(0, nazwy.length - 1)
  410. },
  411. comam: function () {
  412. var person = game.board[this.pos_y][this.pos_x]
  413. },
  414. sprZaleznosci: function () {
  415. console.log((this.pos_y + 1).toString() + (this.pos_x + 1).toString())
  416. },
  417. uzyj: function (rzecz) {
  418. var person = game.board[this.pos_y][this.pos_x]
  419. var rzecz = rzecz
  420. if (ekwipunek.length == 0) {
  421. document.getElementById("label").innerHTML = "Musisz miec coś w ręce"
  422. setTimeout(function () {
  423. document.getElementById("label").innerHTML = "What now?"
  424. document.getElementById("pole").value = ""
  425. document.getElementById("pole").disabled = false;
  426. }, 3000);
  427. } else {
  428. if (ekwipunek[0][3] == rzecz) {
  429. if (zaleznosci[ekwipunek[0][0]][1] == (this.pos_y + 1).toString() + (this.pos_x + 1).toString()) {
  430. document.getElementById("label").innerHTML = zaleznosci[ekwipunek[0][0]][3]
  431. ekwipunek[0] = przedmioty[zaleznosci[ekwipunek[0][0]][2]]
  432. if (ekwipunek[0][2] == 0) {
  433. document.getElementById("trzecie").innerHTML = "You are carrying nothing"
  434. person.przedmiot.push(ekwipunek[0])
  435. ekwipunek = []
  436. } else if (ekwipunek[0][2] == 1) {
  437. document.getElementById("trzecie").innerHTML = "You are carrying " + ekwipunek[0][3]
  438. }
  439. setTimeout(function () {
  440. document.getElementById("label").innerHTML = "What now?"
  441. document.getElementById("pole").value = ""
  442. document.getElementById("pole").disabled = false;
  443. }, 3000);
  444. } else {
  445. document.getElementById("label").innerHTML = "Nothing happened"
  446. setTimeout(function () {
  447. document.getElementById("label").innerHTML = "What now?"
  448. document.getElementById("pole").value = ""
  449. document.getElementById("pole").disabled = false;
  450. }, 3000);
  451. }
  452. //LOKALIZACJA console.log((this.pos_y + 1).toString() + (this.pos_x + 1).toString())
  453. } else {
  454. document.getElementById("label").innerHTML = "You aren't carrying anything like that"
  455. setTimeout(function () {
  456. document.getElementById("label").innerHTML = "What now?"
  457. document.getElementById("pole").value = ""
  458. document.getElementById("pole").disabled = false;
  459. }, 1000);
  460. }
  461. }
  462. },
  463. }
  464. }
  465.  
  466. game.player.highlight();
  467. document.getElementById("pierwszy").innerHTML = "You can go " + strona
  468. });
  469.  
  470. function polecenia(co) {
  471. var co = co
  472.  
  473. if (co == "VOCABULARY" || co == "V") {
  474. var tekst = ["NORTH or N, SOUTH or S",
  475. "WEST or W, EAST or E",
  476. "TAKE (object) or T (object)",
  477. "DROP (object) or D (object)",
  478. "USE (object) or U (object)",
  479. "GOSSIPS or G, VOCABULARY or V",
  480. "Press any key"]
  481.  
  482. document.getElementById("info").style.zIndex = 0
  483. document.getElementById("voc").style.zIndex = 1
  484. document.getElementById("voc").style.display = "block";
  485. document.getElementById("voc").innerHTML = ""
  486. for (var i = 0; i < tekst.length; i++) {
  487. var p = document.createElement("p")
  488. p.innerHTML = tekst[i]
  489. document.getElementById("voc").append(p)
  490. }
  491.  
  492. window.addEventListener('keydown', function () {
  493. document.getElementById("voc").style.display = "none"
  494. document.getElementById("voc").style.zIndex = -1
  495. document.getElementById("info").style.zIndex = 1
  496. })
  497. }
  498.  
  499. if (co.substr(0, 3) == 'USE') {
  500. console.log(co.substr(4, co.length))
  501. game.player.uzyj(co.substr(4, co.length))
  502. }
  503. if (co.substr(0, 1) == 'U' && co.substr(1, 1) == " ") {
  504. console.log(co.substr(2, co.length))
  505. game.player.uzyj(co.substr(2, co.length))
  506. }
  507. if (co.substr(0, 4) == 'TAKE') {
  508. console.log(co.substr(5, co.length))
  509. game.player.podnies(co.substr(5, co.length))
  510. }
  511. if (co.substr(0, 1) == 'T' && co.substr(1, 1) == " ") {
  512. console.log(co.substr(2, co.length))
  513. game.player.podnies(co.substr(2, co.length))
  514. }
  515. if (co.substr(0, 4) == 'DROP') {
  516. console.log(co.substr(5, co.length))
  517. game.player.wyrzuc(co.substr(5, co.length))
  518. }
  519. if (co.substr(0, 1) == 'D' && co.substr(1, 1) == " ") {
  520. console.log(co.substr(2, co.length))
  521. game.player.wyrzuc(co.substr(2, co.length))
  522. }
  523. }
  524.  
  525. var myVar = setInterval(ffff, 0);
  526. function ffff() {
  527. document.getElementById("pole").focus()
  528. }
  529.  
  530. function cos(d, kaj) {
  531. var litera = d.value.toString()
  532. var zapis = litera
  533. var x = event.charCode || event.keyCode;
  534.  
  535. if (x == 13) {
  536. polecenia(litera)
  537. if (litera.substr(0, 1) != 'U' && litera.substr(0, 3) != 'USE' && litera.substr(0, 1) != 'D' && litera.substr(0, 4) != 'DROP' && litera.substr(0, 4) != 'TAKE' && litera.substr(0, 4) != "take" && litera.substr(0, 1) != "t" && litera.substr(0, 1) != "T" && litera.substr(0, 1) != "E" && litera.substr(0, 1) != "e" && litera.substr(0, 4) != "EAST" && litera.substr(0, 1) != "W" && litera.substr(0, 1) != "w" && litera.substr(0, 4) != "WEST" && litera.substr(0, 1) != "N" && litera.substr(0, 1) != "n" && litera.substr(0, 5) != "NORTH" && litera.substr(0, 1) != "S" && litera.substr(0, 1) != "s" && litera.substr(0, 5) != "SOUTH") {
  538. document.getElementById("label").innerHTML = "Try another word or V for vocabulary"
  539. document.getElementById("pole").disabled = true;
  540. document.getElementById("pole").value = ""
  541. }
  542.  
  543. if (litera.substr(0, 1) == "E" || litera.substr(0, 1) == "e" || litera.substr(0, 4) == "EAST" || litera.substr(0, 1) == "W" || litera.substr(0, 1) == "w" || litera.substr(0, 4) == "WEST" || litera.substr(0, 1) == "N" || litera.substr(0, 1) == "n" || litera.substr(0, 5) == "NORTH" || litera.substr(0, 1) == "S" || litera.substr(0, 1) == "s" || litera.substr(0, 5) == "SOUTH") {
  544. var kaj = strona
  545. for (var i = 0; i < kaj.length; i++) {
  546. if (kaj[i].indexOf("WEST") != 0) {
  547. document.getElementById("label").innerHTML = "You can't go that way"
  548. document.getElementById("pole").value = ""
  549. document.getElementById("pole").disabled = true;
  550. }
  551. if (kaj[i].indexOf("SOUTH") != 0) {
  552. document.getElementById("label").innerHTML = "You can't go that way"
  553. document.getElementById("pole").value = ""
  554. document.getElementById("pole").disabled = true;
  555. }
  556. if (kaj[i].indexOf("NORTH") != 0) {
  557. document.getElementById("label").innerHTML = "You can't go that way"
  558. document.getElementById("pole").value = ""
  559. document.getElementById("pole").disabled = true;
  560. }
  561. if (kaj[i].indexOf("EAST") != 0) {
  562. document.getElementById("label").innerHTML = "You can't go that way"
  563. document.getElementById("pole").value = ""
  564. document.getElementById("pole").disabled = true;
  565. }
  566. }
  567. }
  568.  
  569. setTimeout(function () {
  570. document.getElementById("label").innerHTML = "What now?"
  571. document.getElementById("pole").value = ""
  572. document.getElementById("pole").disabled = false;
  573. }, 1000);
  574. return litera
  575. }
  576. }
  577. function sprawdz(kl) {
  578. var x = cos(event.target)
  579. var direction
  580.  
  581. if (event.which == 20)
  582. caps = false
  583. else {
  584. caps = true
  585. }
  586. console.log(event.key)
  587.  
  588. if (event.key == "Enter") return;
  589. document.getElementById("pole").onkeypress = function (e) {
  590. if (event.key == "Enter") return;
  591. e.preventDefault()
  592. if (e.shiftKey != caps)
  593. this.value += e.key.toUpperCase()
  594. else
  595. this.value += e.key.toLowerCase()
  596. //console.log(caps,e.shiftKey,e.key,this.value)
  597. }
  598.  
  599.  
  600. strona.forEach(function (z) {
  601. if ("EAST" == z) {
  602. if (x == "E" || x == "e" || x == "EAST") {
  603. direction = 'right'
  604. document.getElementById("label").innerHTML = "You are going east..."
  605. document.getElementById("pole").value = ""
  606. document.getElementById("pole").disabled = true;
  607. }
  608. }
  609. if ("WEST" == z) {
  610. if (x == "W" || x == "w" || x == "WEST") {
  611. direction = 'left'
  612. document.getElementById("label").innerHTML = "You are going west..."
  613. document.getElementById("pole").value = ""
  614. document.getElementById("pole").disabled = true;
  615. }
  616. }
  617. if ("NORTH" == z) {
  618. if (x == "N" || x == "n" || x == "NORTH") {
  619. direction = 'up'
  620. document.getElementById("label").innerHTML = "You are going north..."
  621. document.getElementById("pole").value = ""
  622. document.getElementById("pole").disabled = true;
  623. }
  624. }
  625. if ("SOUTH" == z) {
  626. if (x == "S" || x == "s" || x == "SOUTH") {
  627. direction = 'down'
  628. document.getElementById("label").innerHTML = "You are going south..."
  629. document.getElementById("pole").value = ""
  630. document.getElementById("pole").disabled = true;
  631. }
  632. }
  633. })
  634. return game.player.go(direction)
  635. }
  636. function tab(el) {
  637.  
  638. if (event.which == 9) {
  639. event.preventDefault();
  640. }
  641.  
  642.  
  643.  
  644. }
  645. </script>
  646. </head>
  647.  
  648. <body>
  649. <p id="glownyText">Cos tu bedzie</p>
  650. <div id="plansza"></div>
  651. <div id="voc"></div>
  652. <div id="info" tabindex="0">
  653. <p id="pierwszy">You can go </p>
  654. <p id="drugi">You see nothing </p>
  655. <p id="trzecie">You are carrying nothing </p>
  656. <p>&nbsp;</p>
  657. <div id="inter">
  658. <label id="label">What now?</label><input type="text" id="pole" spellcheck="true" autofocus
  659. onblur="cos(this)" onkeypress="sprawdz(this)" onkeydown="tab(this)">
  660. <!-- <p id="czwarte">&nbsp;</p> -->
  661. </div>
  662. <!--
  663. <input type="text" id="pole" autofocus onblur="cos(this)"
  664. onkeypress="sprawdz(this)" onkeydown="tab(this)"> -->
  665. </div>
  666. </body>
  667.  
  668. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement