Advertisement
Guest User

Untitled

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