feat: Add wolf and soldier mechanics to game

This commit is contained in:
Kacper Kostka (aider)
2025-04-02 11:57:44 +02:00
parent a002d4b017
commit 5d2a98b494
2 changed files with 47 additions and 1 deletions

View File

@@ -253,10 +253,26 @@ function drawCitizen(c) {
ctx.translate(canvas.width/2 + offsetX, canvas.height/2 + offsetY);
ctx.scale(scale, scale);
ctx.fillStyle = c.color;
// Different colors for different professions
if(c.profession === "Soldier") {
ctx.fillStyle = "#8B0000"; // Dark red for soldiers
} else {
ctx.fillStyle = c.color;
}
ctx.beginPath();
ctx.arc(c.x, c.y, 7, 0, Math.PI*2);
ctx.fill();
// Draw a sword for soldiers
if(c.profession === "Soldier") {
ctx.strokeStyle = "#DDD";
ctx.lineWidth = 1/scale;
ctx.beginPath();
ctx.moveTo(c.x + 5, c.y - 5);
ctx.lineTo(c.x + 12, c.y - 12);
ctx.stroke();
}
// Profession icon
let icon = "👤";
@@ -266,6 +282,7 @@ function drawCitizen(c) {
case "Merchant": icon = "💰"; break;
case "Doctor": icon = "💉"; break;
case "Teacher": icon = "📚"; break;
case "Soldier": icon = "⚔️"; break;
}
ctx.fillStyle = "#000";
@@ -304,6 +321,19 @@ function drawAnimal(a) {
ctx.fillStyle = "#000";
ctx.font = "10px sans-serif";
ctx.fillText("🐰", a.x+8, a.y+3);
} else if(a.type === "Wolf") {
ctx.fillStyle = "#444";
ctx.beginPath();
ctx.arc(a.x, a.y, 10, 0, Math.PI*2);
ctx.fill();
ctx.fillStyle = "#000";
ctx.font = "12px sans-serif";
ctx.fillText("🐺", a.x+8, a.y+3);
// Show hunger level for wolves
ctx.fillStyle = "#f00";
ctx.fillRect(a.x-10, a.y-15, 20 * (a.hunger/ANIMAL_HUNGER_MAX), 3);
}
ctx.restore();