Gambling

by Aryan Jain

A dice rolling gambling simulator where you bet money and try to double it.

gamblingdicecool gamedice rollinggamble
3, lose money\", { x:3, y: 14, color: color`5` })\n} \n\n\nstart()\n\nsetLegend(\n [ side1, bitmap`\n................\n................\n................\n...2222222222...\n...2222222222...\n...2222222222...\n...2220000222...\n...2220000222...\n...2220000222...\n...2220000222...\n...2222222222...\n...2222222222...\n...2222222222...\n................\n................\n................` ],\n [ side2, bitmap`\n................\n................\n................\n...2222222222...\n...2000222222...\n...2000222222...\n...2000222222...\n...2222222222...\n...2222222222...\n...2222220002...\n...2222220002...\n...2222220002...\n...2222222222...\n................\n................\n................` ],\n [ side3, bitmap`\n................\n................\n................\n...2222222222...\n...2222222002...\n...2222222002...\n...2222222222...\n...2222002222...\n...2222002222...\n...2222222222...\n...2002222222...\n...2002222222...\n...2222222222...\n................\n................\n................` ],\n [ side4, bitmap`\n................\n................\n................\n...2222222222...\n...2000220002...\n...2000220002...\n...2000220002...\n...2222222222...\n...2222222222...\n...2000220002...\n...2000220002...\n...2000220002...\n...2222222222...\n................\n................\n................` ],\n [ side5, bitmap`\n................\n................\n................\n...2222222222...\n...2002222002...\n...2002222002...\n...2222222222...\n...2222002222...\n...2222002222...\n...2222222222...\n...2002222002...\n...2002222002...\n...2222222222...\n................\n................\n................` ],\n [ side6, bitmap`\n................\n................\n................\n...2222222222...\n...2002002002...\n...2002002002...\n...2222222222...\n...2222222222...\n...2222222222...\n...2002002002...\n...2002002002...\n...2222222222...\n...2222222222...\n................\n................\n................` ],\n [bg, bitmap`\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000\n0000000000000000`]\n)\n\nsetSolids([])\n\nlet level = 0\nconst levels = [\n map`\n77777\n77777\n77777\n77777`\n]\n\n// Inputs\n\nfunction roll() {\n num = Math.floor(Math.random() * 6) + 1\n if (num <= 3) {\n money += bet\n } else {\n money -= bet\n }\n if (money <= 0) {\n clearText()\n clearDice()\n screen = 'lose'\n addText(\"You Are Broke\", { x: 3, y: 7, color: color`3` })\n addText(\"You LOSE\", { x: 3, y: 8, color: color`3` })\n addText(\"i to start again!\", { x: 2, y: 9, color: color`4` })\n return ''\n }\n show()\n return 'side'+roll\n}\nfunction clearDice() {\n faces.forEach(f => {\n getAll(f).forEach(s => s.remove())\n })\n}\nfunction show() {\n clearText()\n clearDice()\n screen = \"playing\"\n addText(\"D to roll/ A to quit\", { x: 0, y: 15, color: color`7` })\n addText(\"Money:\" + money, { x: 0, y: 0, color: color`4` })\n addText(\"Bet:\" + bet, { x: 0, y: 1, color: color`7` })\n addText(\"roll:\" + num, { x: 0, y: 2, color: color`7` })\n if (num != \"N/A\"){\n addSprite(2, 2, faces[num-1])\n } \n \n}\n\nonInput(\"i\", () => {\n if (screen === \"start\") {\n screen = \"playing\"\n show()\n \n } else{\n screen = \"start\"\n start()\n }\n})\nonInput(\"w\", () => {\n if (screen === \"playing\" && bet < money) {\n clearText()\n bet += 1\n show()\n \n } \n})\nonInput(\"s\", () => {\n if (screen === \"playing\" && bet > 1) {\n clearText()\n bet -= 1\n show()\n \n } \n})\nonInput(\"d\", () => {\n if (screen === \"playing\"){\n roll()\n }\n})\nonInput(\"a\", () => {\n clearDice()\n clearText()\n screen = 'win'\n addText(\"You WIN with:\", { x: 3, y: 7, color: color`7` })\n addText(money+\" dollars!\", { x: 3, y: 8, color: color`7` })\n addText(\"i to start again!\", { x: 1, y: 9, color: color`4` })\n})\n\nsetMap(levels[level])\n\nsetPushables({\n})\n\n\nafterInput(() => {\n \n})"],"gameName":[0,"Gambling"],"authorName":[0,"Aryan Jain"],"filename":[0,"Gambling"],"isLoggedIn":[0,false],"hearted":[0,false],"data-astro-cid-d4jrbbcn":[0,true]}ou WIN with:\", { x: 3, y: 7, color: color`7` })\n addText(money+\" dollars!\", { x: 3, y: 8, color: color`7` })\n addText(\"i to start again!\", { x: 1, y: 9, color: color`4` })\n})\n\nsetMap(levels[level])\n\nsetPushables({\n})\n\n\nafterInput(() => {\n \n})"],"gameName":[0,"Gambling"],"authorName":[0,"Aryan Jain"],"filename":[0,"Gambling"],"isLoggedIn":[0,false],"hearted":[0,false],"data-astro-cid-d4jrbbcn":[0,true]}" client="load" opts="{"name":"DesktopPlayer","value":true}","value":true}" await-children="">

Gambling

by Aryan Jain