Skip to content

Commit

Permalink
Buscaminas
Browse files Browse the repository at this point in the history
  • Loading branch information
ASHVALDE committed Mar 3, 2024
1 parent c87f48c commit e88cb74
Show file tree
Hide file tree
Showing 27 changed files with 1,294 additions and 5 deletions.
Binary file added Prueba/index.144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Prueba/index.180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Prueba/index.512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Prueba/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
</style>
<link id='-gd-engine-icon' rel='icon' type='image/png' href='index.icon.png' />
<link rel='apple-touch-icon' href='index.apple-touch-icon.png'/>
<link rel='manifest' href='index.manifest.json'>

</head>
<body>
Expand All @@ -137,7 +138,7 @@

<script src="index.js"></script>
<script>
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":108704,"index.wasm":49219187},"focusCanvas":true,"gdextensionLibs":[]};
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":108704,"index.wasm":49219187},"focusCanvas":true,"gdextensionLibs":[],"serviceWorker":"index.service.worker.js"};
const engine = new Engine(GODOT_CONFIG);

(function () {
Expand Down
1 change: 1 addition & 0 deletions Prueba/index.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"background_color":"#000000","display":"standalone","icons":[{"sizes":"144x144","src":"index.144x144.png","type":"image/png"},{"sizes":"180x180","src":"index.180x180.png","type":"image/png"},{"sizes":"512x512","src":"index.512x512.png","type":"image/png"}],"name":"UTY","orientation":"any","start_url":"./index.html"}
41 changes: 41 additions & 0 deletions Prueba/index.offline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>You are offline</title>
<style>
html {
background-color: #000000;
color: #ffffff;
}

body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
margin: 2rem;
}

p {
margin-block: 1rem;
}

button {
display: block;
padding: 1rem 2rem;
margin: 3rem auto 0;
}
</style>
</head>
<body>
<h1>You are offline</h1>
<p>This application requires an Internet connection to run for the first time.</p>
<p>Press the button below to try reloading:</p>
<button type="button">Reload</button>
<script>
document.querySelector('button').addEventListener('click', () => {
window.location.reload();
});
</script>
</body>
</html>
106 changes: 106 additions & 0 deletions Prueba/index.service.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// This service worker is required to expose an exported Godot project as a
// Progressive Web App. It provides an offline fallback page telling the user
// that they need an Internet connection to run the project if desired.
// Incrementing CACHE_VERSION will kick off the install event and force
// previously cached resources to be updated from the network.
const CACHE_VERSION = "1708874288|437342416";
const CACHE_PREFIX = "UTY-sw-cache-";
const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION;
const OFFLINE_URL = "index.offline.html";
// Files that will be cached on load.
const CACHED_FILES = ["index.html","index.js","index.offline.html","index.icon.png","index.apple-touch-icon.png","index.worker.js","index.audio.worklet.js"];
// Files that we might not want the user to preload, and will only be cached on first load.
const CACHABLE_FILES = ["index.wasm","index.pck"];
const FULL_CACHE = CACHED_FILES.concat(CACHABLE_FILES);

self.addEventListener("install", (event) => {
event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(CACHED_FILES)));
});

self.addEventListener("activate", (event) => {
event.waitUntil(caches.keys().then(
function (keys) {
// Remove old caches.
return Promise.all(keys.filter(key => key.startsWith(CACHE_PREFIX) && key != CACHE_NAME).map(key => caches.delete(key)));
}).then(function() {
// Enable navigation preload if available.
return ("navigationPreload" in self.registration) ? self.registration.navigationPreload.enable() : Promise.resolve();
})
);
});

async function fetchAndCache(event, cache, isCachable) {
// Use the preloaded response, if it's there
let response = await event.preloadResponse;
if (!response) {
// Or, go over network.
response = await self.fetch(event.request);
}
if (isCachable) {
// And update the cache
cache.put(event.request, response.clone());
}
return response;
}

self.addEventListener("fetch", (event) => {
const isNavigate = event.request.mode === "navigate";
const url = event.request.url || "";
const referrer = event.request.referrer || "";
const base = referrer.slice(0, referrer.lastIndexOf("/") + 1);
const local = url.startsWith(base) ? url.replace(base, "") : "";
const isCachable = FULL_CACHE.some(v => v === local) || (base === referrer && base.endsWith(CACHED_FILES[0]));
if (isNavigate || isCachable) {
event.respondWith(async function () {
// Try to use cache first
const cache = await caches.open(CACHE_NAME);
if (event.request.mode === "navigate") {
// Check if we have full cache during HTML page request.
const fullCache = await Promise.all(FULL_CACHE.map(name => cache.match(name)));
const missing = fullCache.some(v => v === undefined);
if (missing) {
try {
// Try network if some cached file is missing (so we can display offline page in case).
return await fetchAndCache(event, cache, isCachable);
} catch (e) {
// And return the hopefully always cached offline page in case of network failure.
console.error("Network error: ", e);
return await caches.match(OFFLINE_URL);
}
}
}
const cached = await cache.match(event.request);
if (cached) {
return cached;
} else {
// Try network if don't have it in cache.
return await fetchAndCache(event, cache, isCachable);
}
}());
}
});

self.addEventListener("message", (event) => {
// No cross origin
if (event.origin != self.origin) {
return;
}
const id = event.source.id || "";
const msg = event.data || "";
// Ensure it's one of our clients.
self.clients.get(id).then(function (client) {
if (!client) {
return; // Not a valid client.
}
if (msg === "claim") {
self.skipWaiting().then(() => self.clients.claim());
} else if (msg === "clear") {
caches.delete(CACHE_NAME);
} else if (msg === "update") {
self.skipWaiting().then(() => self.clients.claim()).then(() => self.clients.matchAll()).then(all => all.forEach(c => c.navigate(c.url)));
} else {
onClientMessage(event);
}
});
});

2 changes: 1 addition & 1 deletion Script/desktopManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var programs = ["Sobre Mi","Configuraciones"]
var programs = ["Sobre Mi","Configuraciones","Buscaminas"]
var icons = document.getElementsByClassName("icon")
var currentActive = null
const startIcon = (e)=>{
Expand Down
2 changes: 1 addition & 1 deletion Stylesheet/98.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions applet/Buscaminas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
minesweeper
===========
Clone of Microsoft's Minesweeper from Windows XP. An effort was made to duplicate every feature (excluding menus) as exactly as possible.

Demo: https://ziebelje.github.io/minesweeper/
9 changes: 9 additions & 0 deletions applet/Buscaminas/css/minesweeper.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
margin: 0;
padding: 0;
background-color: #bdbdbd;
}

#play_area {
margin: auto;
}
17 changes: 17 additions & 0 deletions applet/Buscaminas/data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Minesweeper</title>
<script type="text/javascript" src="js/rocket.12.06.js"></script>
<script type="text/javascript" src="js/seedrandom.js"></script>
<script type="text/javascript" src="js/minesweeper.js"></script>
<script type="text/javascript" src="js/tile.js"></script>
<script type="text/javascript" src="js/face.js"></script>
<script type="text/javascript" src="js/grid.js"></script>
<script type="text/javascript" src="js/ssd.js"></script>
<link rel="stylesheet" href="css/minesweeper.css">
</head>
<body>
<div id="play_area"></div>
</body>
</html>
Binary file added applet/Buscaminas/image/sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applet/Buscaminas/image/v/v_sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions applet/Buscaminas/js/face.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
arcade.minesweeper.face = function(minesweeper, container) {
this.minesweeper = minesweeper;
container.appendChild(this.get_element());
}

arcade.minesweeper.face.prototype.minesweeper;
arcade.minesweeper.face.prototype.state;
arcade.minesweeper.face.prototype.element;
arcade.minesweeper.face.prototype.mouse_left = 1;
arcade.minesweeper.face.prototype.mouse_right = 3;

arcade.minesweeper.face.prototype.get_element = function() {
var self = this;
if(!this.element) {
this.element = $.createElement("div")
.style({"width": 26, "height": 26, "margin": "auto", "background-image": "url('image/sprite.png')", "background-repeat": "no-repeat"})
.addEventListener("mousedown", function() {
if(self.state === "smile") self.set_state("depressed_smile");
})
.addEventListener("mouseup", function() {
if(self.state === "depressed_smile") {
self.set_state("smile");
self.minesweeper.restart();
}
})
.addEventListener("mouseout", function() {
if(self.state === "depressed_smile") self.set_state("smile");
})
.addEventListener("mouseover", function(e) {
if(e.which === self.mouse_left && self.state === "smile") self.set_state("depressed_smile");
})
this.set_state("smile");
}
return this.element[0];
}

arcade.minesweeper.face.prototype.set_state = function(state) {
this.state = state;
switch(state) {
case "smile":
this.element.style({"background-position": "0px -55px"})
break;
case "depressed_smile":
this.element.style({"background-position": "-26px -55px"});
break;
case "scared":
this.element.style({"background-position": "-52px -55px"});
break;
case "dead":
this.element.style({"background-position": "-78px -55px"});
break;
case "sunglasses":
this.element.style({"background-position": "-104px -55px"});
break;
}
}
arcade.minesweeper.face.prototype.get_state = function() {
return this.state;
}
Loading

0 comments on commit e88cb74

Please sign in to comment.