Meta Description" name="description" />
<!DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Indian Farming Simulator 25 Mobile</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #222;
font-family: Arial, sans-serif;
color: white;
text-align: center;
user-select: none;
touch-action: manipulation;
}
h1 { margin: 5px 0; color: #4CAF50; font-size: 20px; }
#ui-panel {
width: 95%;
margin: 5px auto;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
background: #333;
padding: 8px;
border-radius: 5px;
font-size: 13px;
}
.stat { font-weight: bold; margin: 2px; }
#game-container {
position: relative;
width: 95%;
max-width: 600px;
height: 350px;
margin: 5px auto;
background-color: #7c6242;
border: 3px solid #555;
border-radius: 8px;
overflow: hidden;
}
canvas {
display: block;
width: 100%;
height: 100%;
background-color: #7c6242;
}
#mandi {
position: absolute;
top: 10px;
right: 10px;
width: 80px;
height: 60px;
background-color: #bfa15f;
border: 2px dashed #ffeb3b;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
color: #333;
font-size: 11px;
}
.btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 5px 10px;
font-size: 12px;
cursor: pointer;
border-radius: 4px;
font-weight: bold;
}
/* Mobile Touch Controls */
#controls {
display: grid;
grid-template-columns: repeat(3, 60px);
grid-template-rows: repeat(2, 50px);
gap: 10px;
justify-content: center;
margin: 15px auto;
}
.arrow-btn {
background-color: #555;
color: white;
border: 2px solid #888;
border-radius: 50%;
font-size: 24px;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
user-select: none;
}
.arrow-btn:active { background-color: #4CAF50; }
#btn-up { grid-column: 2; }
#btn-left { grid-column: 1; grid-row: 2; }
#btn-down { grid-column: 2; grid-row: 2; }
#btn-right { grid-column: 3; grid-row: 2; }
</style>
</head>
<body>
<h1>🚜 Indian FS25 Mobile 🌾</h1>
<div id="ui-panel">
<div class="stat">💰 <span id="money">₹1,000</span></div>
<div class="stat">⛽ <span id="fuel">100</span>%</div>
<div class="stat">🌾 <span id="crop-stock">0</span> क्विंटल</div>
<div class="stat">🚜 <span id="tractor-name" style="color:#2196F3;">Swaraj</span></div>
<button class="btn" onclick="switchTractor()">बदलें</button>
<button class="btn" onclick="refuel()" style="background-color: #ff9800;">डीजल (-₹200)</button>
</div>
<div id="game-container">
<div id="mandi">अनाज मंडी</div>
<canvas id="gameCanvas" width="600" height="350"></canvas>
</div>
<!-- On-Screen Touch Buttons for Mobile -->
<div id="controls">
<div class="arrow-btn" id="btn-up">↑</div>
<div class="arrow-btn" id="btn-left">←</div>
<div class="arrow-btn" id="btn-down">↓</div>
<div class="arrow-btn" id="btn-right">→</div>
</div>
<script>
const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");
let money = 1000;
let fuel = 100;
let cropStock = 0;
let currentTractorType = "Swaraj";
const tractor = { x: 50, y: 180, width: 35, height: 24, speed: 2.5, color: "#2196F3" };
const moveDirections = { up: false, down: false, left: false, right: false };
// Grid setup for mobile layout
const fields = [];
const cols = 4;
const rows = 3;
const fieldWidth = 90;
const fieldHeight = 60;
const startX = 30;
const startY = 100;
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
fields.push({
x: startX + c * (fieldWidth + 15),
y: startY + r * (fieldHeight + 15),
w: fieldWidth,
h: fieldHeight,
state: 0,
growthTimer: 0
});
}
}
const mandiArea = { x: 500, y: 10, w: 80, h: 60 };
// Mobile Touch Events Function
function setupMobileButton(id, direction) {
const btn = document.getElementById(id);
btn.addEventListener("touchstart", (e) => { e.preventDefault(); moveDirections[direction] = true; });
btn.addEventListener("touchend", (e) => { e.preventDefault(); moveDirections[direction] = false; });
// Fallback for PC mouse testing
btn.addEventListener("mousedown", () => moveDirections[direction] = true);
btn.addEventListener("mouseup", () => moveDirections[direction] = false);
}
setupMobileButton("btn-up", "up");
setupMobileButton("btn-down", "down");
setupMobileButton("btn-left", "left");
setupMobileButton("btn-right", "right");
function switchTractor() {
if (currentTractorType === "Swaraj") {
currentTractorType = "Mahindra";
tractor.color = "#f44336";
document.getElementById("tractor-name").innerText = "Mahindra";
document.getElementById("tractor-name").style.color = "#f44336";
} else {
currentTractorType = "Swaraj";
tractor.color = "#2196F3";
document.getElementById("tractor-name").innerText = "Swaraj";
document.getElementById("tractor-name").style.color = "#2196F3";
}
}
function refuel() {
if (money >= 200 && fuel < 100) { money -= 200; fuel = 100; updateUI(); }
}
function updateUI() {
document.getElementById("money").innerText = "₹" + money;
document.getElementById("fuel").innerText = Math.floor(fuel);
document.getElementById("crop-stock").innerText = cropStock;
}
function checkFieldInteraction() {
fields.forEach(field => {
if (tractor.x + tractor.width > field.x && tractor.x < field.x + field.w &&
tractor.y + tractor.height > field.y && tractor.y < field.y + field.h) {
if (fuel > 0) {
if (field.state === 0) { field.state = 1; fuel -= 0.1; }
else if (field.state === 1) { field.state = 2; field.growthTimer = 0; fuel -= 0.1; }
else if (field.state === 3) { field.state = 0; cropStock += 5; fuel -= 0.2; }
}
}
});
if (tractor.x + tractor.width > mandiArea.x && tractor.x < mandiArea.x + mandiArea.w &&
tractor.y + tractor.height > mandiArea.y && tractor.y < mandiArea.y + mandiArea.h) {
if (cropStock > 0) { money += cropStock * 150; cropStock = 0; }
}
updateUI();
}
function update() {
if (fuel > 0) {
let moving = false;
if (moveDirections.left && tractor.x > 0) { tractor.x -= tractor.speed; moving = true; }
if (moveDirections.right && tractor.x < canvas.width - tractor.width) { tractor.x += tractor.speed; moving = true; }
if (moveDirections.up && tractor.y > 0) { tractor.y -= tractor.speed; moving = true; }
if (moveDirections.down && tractor.y < canvas.height - tractor.height) { tractor.y += tractor.speed; moving = true; }
if (moving) { fuel -= 0.03; checkFieldInteraction(); }
}
fields.forEach(field => {
if (field.state === 2) {
field.growthTimer += 1;
if (field.growthTimer > 150) { field.state = 3; }
}
});
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
fields.forEach(field => {
if (field.state === 0) ctx.fillStyle = "#6d5233";
else if (field.state === 1) ctx.fillStyle = "#553c20";
else if (field.state === 2) ctx.fillStyle = "#8bc34a";
else if (field.state === 3) ctx.fillStyle = "#ffeb3b";
ctx.fillRect(field.x, field.y, field.w, field.h);
ctx.strokeStyle = "#4d361c";
ctx.strokeRect(field.x, field.y, field.w, field.h);
ctx.fillStyle = "#fff";
ctx.font = "10px Arial";
let text = "खाली";
if (field.state === 1) text = "जोत दिया";
if (field.state === 2) text = "उग रहा है";
if (field.state === 3) text = "🌾 तैयार";
ctx.fillText(text, field.x + 5, field.y + field.h/2 + 4);
});
// Trolley
ctx.fillStyle = "#795548";
1
1
10KB
10KB
115.0ms
204.0ms
115.0ms