Skip to content

Commit

Permalink
Merge pull request #4409 from Maheshwari-Love/add/Lunar-game
Browse files Browse the repository at this point in the history
[New-Game] Lunar_Lander Added
  • Loading branch information
kunjgit authored Jun 15, 2024
2 parents 1ff2574 + bb128fa commit 70b83b8
Show file tree
Hide file tree
Showing 11 changed files with 722 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Games/Lunar_Lander/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Overview

**Lunar Lander** is a classic arcade-style game where the player controls a lunar module attempting to land safely on the surface of the moon. The game challenges the player's ability to manage the module's fuel, speed, and trajectory to achieve a smooth landing.

## Table of Contents

- [Gameplay](#gameplay)
- [Controls](#controls)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Screenshots](#screenshots)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## Gameplay

The objective of the game is to successfully land the lunar module on the moon's surface. The player must control the descent rate and angle to avoid crashing. The game is won when the module lands safely within designated landing zones, marked on the surface.

### Key Points

- **Fuel Management**: The module has a limited amount of fuel. Use it wisely to control your descent.
- **Landing Speed**: The module must land with a vertical speed below a certain threshold to avoid crashing.
- **Landing Zones**: Safe landing zones are marked and provide bonuses for landing accuracy.

## Controls

- **Arrow Keys**:
- **Up**: Fire thrusters to slow descent.
- **Left/Right**: Tilt the module to control horizontal movement.
- **Spacebar**: Activate main thruster for a powerful, fuel-consuming burst.
- **P**: Pause the game.
- **R**: Restart the game.

## Features

- **Realistic Physics**: Simulates lunar gravity and module thruster mechanics.
- **Fuel Management**: Limited fuel adds a layer of strategy to the game.
- **Multiple Levels**: Increasing difficulty with various landing zone configurations.
- **Scoring System**: Points awarded for landing accuracy, fuel efficiency, and speed.
70 changes: 70 additions & 0 deletions Games/Lunar_Lander/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
html {
margin: 0;
background-color: black;
font-family: monospace;
font-size: 16px;
}

body {
margin: 0 0 0 0;
}

a {
color: white;
}

#menu {
position: absolute;
top: 0;
width: 100%;
color: white;
height: 3.5em;
line-height: 3.5em;
text-align: right;
}

#menu a {
margin: 0 4em;
}

#console-root {
margin: 8em 0 0 0;
padding: 0 1em 4em 1em;
}

.console-line {
padding: 0;
border: none;
background-color: black;
color: white;
font-family: monospace;
font-size: 1em;
margin: 0 auto;
display: block;
width: 45em;
line-height: 1.4em;
}

@media (max-width: 760px) {
html {
font-size: 14px;
}
}

@media (max-width: 660px) {
html {
font-size: 12px;
}
}

@media (max-width: 560px) {
html {
font-size: 10px;
}
}

@media (max-width: 460px) {
html {
font-size: 8px;
}
}
39 changes: 39 additions & 0 deletions Games/Lunar_Lander/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>

<html onkeyup="navigate(event)" onclick="navigate('click')">

<head>
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<title>LUNAR LANDER SIMULATOR</title>
<meta name="description" content="RECODING OF JIM STORER'S LUNAR LANDING GAME FROM 1969.">
<meta name="keywords" content="LUNAR LANDER, LUNAR LANDING GAME, JIM STORER, 1969">
<meta name="author" content="STEFAN TRENKEL">
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>

<body id="">

<div id="menu">
<a href="info.html">INFO</a>
</div>

<div id="console-root">
<div class="console-line">LUNAR LANDER SIMULATOR</div>
<div class="console-line">----------------------</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">RECODING OF JIM STORER'S LUNAR LANDING GAME FROM 1969.</div>
<div class="console-line">PRESS ENTER, CLICK OR TOUCH TO START!</div>
</div>

</body>

<script>
var navigate = function(event) {
if (event === "click" || event.keyCode === 13) {
window.location.href = "lunar.html";
}
};
</script>

</html>
71 changes: 71 additions & 0 deletions Games/Lunar_Lander/info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>

<html>

<head>
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<title>LUNAR LANDER SIMULATOR</title>
<meta name="description" content="RECODING OF JIM STORER'S LUNAR LANDING GAME FROM 1969.">
<meta name="keywords" content="LUNAR LANDER, LUNAR LANDING GAME, JIM STORER, 1969">
<meta name="author" content="STEFAN TRENKEL">
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>

<body id="">

<div id="menu">
<a href="index.html">HOME</a>
</div>

<div id="console-root">
<div class="console-line">LUNAR LANDER SIMULATOR</div>
<div class="console-line">----------------------</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">THE LUNAR LANDING GAME WAS WRITTEN BY JIM STORER IN 1969.
IT WAS CODED IN FOCAL FOR A DEC PDP-8 MINICOMPUTER. IT BECAME ONE OF THE MOST INFLUENTIAL COMPUTER GAMES EVER.
THE LUNAR LANDER SIMULATOR IS AN ACCURATE RECODING IN JAVASCRIPT AND HTML OF THE FOCAL CODE FROM 1969.</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">LUNAR LINKS</div>
<div class="console-line">-----------</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">
<a href="https://www.cs.brandeis.edu/~storer/LunarLander/LunarLander.html">LUNAR DOCS</a> BY JIM STORER
</div>
<div class="console-line">
<a href="http://omerkel.github.io/rocketscience/html5/src/">ROCKET SCIENCE</a> BY OLIVER MERKEL
</div>
<div class="console-line">
<a href="http://moonlander.seb.ly/">GRAPHICAL LUNAR LANDER</a> BY SEB LEE-DELISLE
</div>
<div class="console-line">
<a href="https://lulander.uber.space/">REALTIME LUNAR LANDER</a> BY STEFAN TRENKEL
</div>
<div class="console-line">
<a href="http://www.math.muni.cz/~zemanekp/files/M0160/OLD/Lunar-text-CZE/">LUNAR LANDER SIMULATOR - TRANSLATION INTO CZECH</a>
BY <a href="http://www.math.muni.cz/~zemanekp/index.html">PETR ZEMÁNEK</a>
</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">PRIVACY</div>
<div class="console-line">-------</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">LUNAR LANDER SIMULATOR DOES NOT TRACK OR COLLECT ANY DATA. NEITHER COOKIES NOR TOOLS LIKE GOOGLE
ANALYTICS ARE USED. PAGE CALLS ARE NOT LOGGED. LUNAR LANDER SIMULATOR IS HOSTED BY <a href="https://uberspace.de">UEBERSPACE</a>.
CODE IS FREE ON <a href="https://github.com/strenkel/lunar">GITHUB</a> UNDER
<a href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPLV3</a>.</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">&nbsp;</div>
<div class="console-line">CONTACT</div>
<div class="console-line">-------</div>
<div class="console-line">&nbsp;</div>
<div class="console-line"><a href="http://www.stefantrenkel.de/">STEFAN TRENKEL</a></div>
<div class="console-line">TANNHAEUSERPLATZ 3</div>
<div class="console-line">28205 BREMEN, GERMANY</div>
<div class="console-line">INFO (AT) STEFANTRENKEL.DE</div>
</div>

</body>

</html>
41 changes: 41 additions & 0 deletions Games/Lunar_Lander/js/delayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var delayer = (function() {

var delayId;
var delayerStack = [];
var delayTime = 75; // in millis

// --- PUBLIC METHODS ---

/**
* @param {Function} callbacks
* @returns {Function}
*/
var delay = function(callback) {
return function() {
delayerStack.push([callback, arguments]);
runDelayer();
}
};

// --- PRIVATE METHODES ---

var runDelayer = function() {
if (delayId == null) {
delayId = setTimeout(function() {
delayId = null;
var task = delayerStack.shift();
if (task) {
task[0].apply(null, task[1]);
if (delayerStack.length != 0) {
runDelayer();
}
}
}, delayTime);
}
};

return {
delay: delay
};

})();
62 changes: 62 additions & 0 deletions Games/Lunar_Lander/js/htmlfrontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
(function(myLunarControl, myDelayer) {

var root = document.getElementById("console-root");
var lastFormElm;

var scrollToBottom = function() {
window.scrollTo(0, document.body.scrollHeight);
};

var log = function(message) {
clearForm();
var input = createInputElm(message);
input.disabled = true;
root.appendChild(input);
scrollToBottom();
};

var prompt = function(message, callback) {
clearForm();
var inputElm = createInputElm(message);
var form = document.createElement("form");
form.appendChild(inputElm);
root.appendChild(form);
inputElm.focus();
form.onsubmit = function(event) {
event.preventDefault();
callback(inputElm.value.substr(message.length));
return false; // necessary?
};
lastFormElm = form;
scrollToBottom();
};

var createInputElm = function(message) {
var input = document.createElement("input");
input.className = "console-line";
if (message) {
input.value = message;
}
return input;
};

var clearForm = function() {
if (lastFormElm) {
lastFormElm.onsubmit = null;
lastFormElm.firstElementChild.disabled = true;
lastFormElm = null;
}
};

var Logger = {
log: myDelayer.delay(log),
prompt: myDelayer.delay(prompt)
};

var runLL = function() {
myLunarControl.run(Logger);
};

runLL();

})(lunarcontrol, delayer);
Loading

0 comments on commit 70b83b8

Please sign in to comment.