🎮ArcadeLab

Shamrocks and Shenanigans

by UltraNinja96
364 lines9.6 KB
▶ Play

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Shamrocks and Shenanigans</title>
<style>
*{box-sizing:border-box}
body{margin:0;background:#101710;color:#e9dfbd;font-family:Georgia,serif}
header{text-align:center;padding:12px;background:#172719;border-bottom:2px solid #a18a55}
h1{font-size:27px;letter-spacing:4px;margin:4px}
header p{margin:4px;letter-spacing:3px}
#layout{display:flex;flex-wrap:wrap;gap:12px;padding:12px;max-width:1250px;margin:auto}
#gamebox{flex:1 1 650px;min-width:280px}
canvas{width:100%;background:#526c3d;border:3px solid #b6a071;display:block}
#sidebar{flex:1 1 230px;background:#202a20;padding:15px;border:1px solid #8c7950}
h2{font-size:17px;color:#d9c58b;border-bottom:1px solid #81734d;padding-bottom:7px}
.stat{display:flex;justify-content:space-between;margin:9px 0}
button{background:#465c39;color:#f2e6c6;border:1px solid #b5a16e;padding:9px;margin:3px;cursor:pointer;font-family:Georgia}
button:hover{background:#657c4c}
#dialogue{background:#171d17;padding:13px;min-height:100px;line-height:1.5;margin-top:10px;border:1px solid #655c3e}
#journal{font-size:13px;line-height:1.7}
#controls{font-size:12px;color:#c9bd99;margin:8px 0}
</style>
</head>
<body>

<header>
<h1>SHAMROCKS AND SHENANIGANS</h1>
<p>IRELAND · 1911</p>
</header>

<div id="layout">
<div id="gamebox">
<canvas id="game" width="900" height="560"></canvas>
<div id="controls">
WASD / ARROWS: Move &nbsp; E: Talk / Interact
</div>
<div id="dialogue">
<strong>LIAM:</strong> Ireland has become a dangerous place.
Find the others. We need to stick together.
</div>
</div>

<aside id="sidebar">
<h2>LIAM'S RECORD</h2>
<div class="stat"><span>Wanted bounty</span><b>€10,000</b></div>
<div class="stat"><span>Money</span><b id="money">€45</b></div>
<div class="stat"><span>Health</span><b>100%</b></div>
<div class="stat"><span>Gang members</span><b id="gangcount">0/5</b></div>

<h2>MISSION JOURNAL</h2>
<div id="journal">
<strong>THE LAST OF THE SIX</strong><br>
Find the five scattered members of your gang.<br><br>
1. Find Malik.<br>
2. Find Finn.<br>
3. Find Seán.<br>
4. Find Cormac.<br>
5. Find Ned.
</div>

<h2>YOUR GANG</h2>
<div id="members">
Malik — Missing<br>
Finn — Missing<br>
Liam — You<br>
Seán — Missing<br>
Cormac — Missing<br>
Ned — Missing
</div>

<h2>WORLD</h2>
<p id="location">Location: Countryside</p>
<button onclick="showMap()">Show map information</button>
<button onclick="saveGame()">Save progress</button>
</aside>
</div>

<script>
const canvas=document.getElementById("game");
const ctx=canvas.getContext("2d");

const W=2000,H=1400;
const player={x:250,y:250,speed:3.2};
let money=45;
let found=0;
let keys={};
let horse=false;
let clues=0;
let wanted=0;

const companions=[
{name:"Malik",x:510,y:300,role:"THE RIFLEMAN",
desc:"Malik has always been the dependable one. He has been hiding in an abandoned farmhouse.",
talk:"Malik: Liam? I thought the police had caught you. The old gang is finished. But I'm not leaving you behind.",
colour:"#604b36"},
{name:"Finn",x:800,y:600,role:"THE SMALL MAN",
desc:"Finn is staying in a small village cottage.",
talk:"Finn: Took you long enough! I've heard some things about the raid. Someone knew exactly where we were.",
colour:"#777064"},
{name:"Seán",x:1300,y:300,role:"TWO HANDS, NO FEAR",
desc:"Seán has been seen around the village pub.",
talk:"Seán: I knew you'd show up eventually. Sit down. There's something you need to know about that night.",
colour:"#b9ad8b"},
{name:"Cormac",x:1550,y:850,role:"THE BRUISER",
desc:"Cormac is hiding out near the old stone bridge.",
talk:"Cormac: They took everything. Money, horses, the lot. But they didn't get me. Good to see you, Liam.",
colour:"#625b4a"},
{name:"Ned",x:650,y:1050,role:"TROUBLE FINDS ME",
desc:"Ned has somehow ended up near an abandoned castle.",
talk:"Ned: Ah, Liam! You look terrible. I know a little something about the people who betrayed us...",
colour:"#8b6845"}
];

const buildings=[
{x:300,y:420,w:150,h:110,name:"THE CROWN PUB"},
{x:750,y:180,w:150,h:110,name:"VILLAGE INN"},
{x:1150,y:900,w:170,h:110,name:"FARMHOUSE"},
{x:1500,y:200,w:120,h:160,name:"OLD CHURCH"},
{x:200,y:1000,w:180,h:120,name:"ABANDONED CASTLE"}
];

const clueItems=[
{x:400,y:800,found:false},
{x:950,y:400,found:false},
{x:1200,y:1150,found:false},
{x:1700,y:650,found:false}
];

let trees=[];
for(let i=0;i<160;i++){
trees.push({x:Math.random()*W,y:Math.random()*H});
}

function dialogue(text){
document.getElementById("dialogue").innerHTML=
"<strong>"+text.split(":")[0]+":</strong>"+text.substring(text.indexOf(":")+1);
}

function draw(){
ctx.fillStyle="#536d40";
ctx.fillRect(0,0,W,H);

// Fields
for(let x=0;x<W;x+=300){
ctx.fillStyle="#637c49";
ctx.fillRect(x,0,140,H);
}

// River
ctx.fillStyle="#496e70";
ctx.beginPath();
ctx.moveTo(0,700);
ctx.bezierCurveTo(450,550,750,950,1200,760);
ctx.bezierCurveTo(1500,620,1700,820,2000,700);
ctx.lineTo(2000,800);
ctx.bezierCurveTo(1700,920,1500,720,1200,860);
ctx.bezierCurveTo(750,1050,450,650,0,800);
ctx.fill();

// Trees
trees.forEach(t=>{
ctx.fillStyle="#263e28";
ctx.beginPath();
ctx.arc(t.x,t.y,16,0,Math.PI*2);
ctx.fill();
ctx.fillStyle="#3c5932";
ctx.beginPath();
ctx.arc(t.x-5,t.y-6,10,0,Math.PI*2);
ctx.fill();
});

// Roads
ctx.strokeStyle="#9a8963";
ctx.lineWidth=36;
ctx.beginPath();
ctx.moveTo(0,350);
ctx.lineTo(500,350);
ctx.lineTo(900,500);
ctx.lineTo(1400,500);
ctx.lineTo(1800,900);
ctx.stroke();

ctx.strokeStyle="#c4ad7c";
ctx.lineWidth=2;
ctx.stroke();

// Buildings
buildings.forEach(b=>{
ctx.fillStyle="#77705a";
ctx.fillRect(b.x,b.y,b.w,b.h);
ctx.fillStyle="#46392d";
ctx.beginPath();
ctx.moveTo(b.x-12,b.y);
ctx.lineTo(b.x+b.w/2,b.y-35);
ctx.lineTo(b.x+b.w+12,b.y);
ctx.fill();
ctx.fillStyle="#e0cf9e";
ctx.font="15px Georgia";
ctx.fillText(b.name,b.x,b.y+b.h+20);
ctx.fillStyle="#352c23";
ctx.fillRect(b.x+b.w/2-12,b.y+b.h-40,24,40);
});

// Clues
clueItems.forEach(c=>{
if(!c.found){
ctx.fillStyle="#e5d29b";
ctx.fillRect(c.x-8,c.y-8,16,16);
ctx.fillText("✉",c.x-8,c.y-13);
}
});

// Horse
ctx.fillStyle="#39291d";
ctx.fillRect(330,260,50,30);
ctx.fillStyle="#17120d";
ctx.fillRect(365,240,16,25);
ctx.fillStyle="#e8d4a1";
ctx.font="14px Georgia";
ctx.fillText(horse?"Your horse":"Horse",325,230);

// Companions
companions.forEach(c=>{
if(c.found)return;
ctx.fillStyle=c.colour;
ctx.fillRect(c.x-12,c.y-22,24,40);
ctx.fillStyle="#211d17";
ctx.beginPath();
ctx.arc(c.x,c.y-27,12,0,Math.PI*2);
ctx.fill();
ctx.fillStyle="#fff0c9";
ctx.font="16px Georgia";
ctx.fillText(c.name,c.x-25,c.y-42);
});

// Liam
ctx.fillStyle="#211c17";
ctx.fillRect(player.x-12,player.y-12,24,35);
ctx.fillStyle="#17130f";
ctx.fillRect(player.x-17,player.y-24,34,7);
ctx.fillRect(player.x-10,player.y-35,20,13);
ctx.fillStyle="#e2d2a8";
ctx.font="12px Georgia";
ctx.fillText("LIAM",player.x-15,player.y+40);
}

function drawScreen(){
ctx.clearRect(0,0,900,560);
ctx.save();
ctx.translate(-camera.x,-camera.y);
draw();
ctx.restore();
}

let camera={x:0,y:0};

function update(){
if(keys.w||keys.ArrowUp)player.y-=player.speed;
if(keys.s||keys.ArrowDown)player.y+=player.speed;
if(keys.a||keys.ArrowLeft)player.x-=player.speed;
if(keys.d||keys.ArrowRight)player.x+=player.speed;

player.x=Math.max(20,Math.min(W-20,player.x));
player.y=Math.max(20,Math.min(H-20,player.y));

camera.x=Math.max(0,Math.min(W-900,player.x-450));
camera.y=Math.max(0,Math.min(H-560,player.y-280));

const locations=[
{n:"The Village",x:500,y:350},
{n:"The Old Castle",x:200,y:1000},
{n:"The Countryside",x:1000,y:700},
{n:"The Church",x:1500,y:200}
];
let nearest=locations.sort((a,b)=>
Math.hypot(player.x-a.x,player.y-a.y)-
Math.hypot(player.x-b.x,player.y-b.y))[0];
document.getElementById("location").innerText=
"Location: "+nearest.n;
}

function interact(){
let near=false;

for(let c of companions){
if(!c.found&&Math.hypot(player.x-c.x,player.y-c.y)<65){
c.found=true;
found++;
dialogue(c.talk);
document.getElementById("gangcount").innerText=found+"/5";
document.getElementById("members").innerHTML=
companions.map(m=>m.name+" — "+(m.found?"Reunited":"Missing")).join("<br>")+
"<br>Liam — You";
document.getElementById("journal").innerHTML=
"<strong>THE LAST OF THE SIX</strong><br>"+
found+" of 5 companions reunited.<br><br>"+
companions.filter(m=>!m.found).map(m=>"Find "+m.name+".").join("<br>");
if(found===5){
dialogue("LIAM: All six of us. Together again. But we still have unfinished business.");
document.getElementById("journal").innerHTML=
"<strong>MISSION COMPLETE</strong><br>The gang has reunited. The truth behind the raid remains a mystery.";
}
near=true;
break;
}
}

if(near)return;

for(let c of clueItems){
if(!c.found&&Math.hypot(player.x-c.x,player.y-c.y)<40){
c.found=true;
clues++;
money+=15;
dialogue("LIAM: A letter. Someone has been keeping records of the raid. I should hold onto this.");
document.getElementById("money").innerText="€"+money;
document.getElementById("journal").innerHTML+=
"<br>Clues discovered: "+clues+"/4";
return;
}
}

if(Math.hypot(player.x-355,player.y-260)<60){
horse=true;
dialogue("LIAM: At least they left my horse. Let's get moving.");
return;
}

dialogue("LIAM: Nothing useful around here.");
}

function showMap(){
dialogue("LIAM: We're somewhere in the Irish countryside. The village, castle and old farms are marked on my map.");
}

function saveGame(){
const data={
player,found,money,horse,clues,
companions:companions.map(c=>c.found),
clueItems:clueItems.map(c=>c.found)
};
localStorage.setItem("shamrocksSave",JSON.stringify(data));
dialogue("LIAM: Progress saved.");
}

window.addEventListener("keydown",e=>{
keys[e.key]=true;
if(e.key.toLowerCase()==="e")interact();
});
window.addEventListener("keyup",e=>keys[e.key]=false);

function loop(){
update();
drawScreen();
requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>

Game Source: Shamrocks and Shenanigans

Creator: UltraNinja96

Libraries: none

Complexity: complex (364 lines, 9.6 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: shamrocks-and-shenanigans-ultraninja96" to link back to the original. Then publish at arcadelab.ai/publish.