ресурсы колобка
190
001.мир.js
@@ -1,190 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Реализация шаблона "издатель-подписчик"
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function Уведомитель()
|
|
||||||
{
|
|
||||||
function Подписка(id, отклик, уведомитель)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.отклик = отклик;
|
|
||||||
this.уведомитель = уведомитель;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.уведомить = function()
|
|
||||||
{
|
|
||||||
// Попутно собираем подписки без отклика.
|
|
||||||
var безотклика = [];
|
|
||||||
for (var номер in this.подписки)
|
|
||||||
{
|
|
||||||
var подписка = this.подписки[номер];
|
|
||||||
if (подписка.отклик)
|
|
||||||
{
|
|
||||||
подписка.отклик();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
безотклика.push(подписка);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// И удаляем их.
|
|
||||||
if (безотклика.length)
|
|
||||||
{
|
|
||||||
this._удалитьПодпискиБезОтклика(безотклика);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.подписать = function(отклик)
|
|
||||||
{
|
|
||||||
var id = this._сгенерироватьUUID();
|
|
||||||
var подписка = new Подписка(id, отклик, this);
|
|
||||||
this.подписки.push(подписка);
|
|
||||||
return подписка;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.отписать = function(подписка)
|
|
||||||
{
|
|
||||||
подписка.отклик = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
this._удалитьПодпискиБезОтклика = function(удалить)
|
|
||||||
{
|
|
||||||
var подписка = удалить.shift()
|
|
||||||
while (подписка)
|
|
||||||
{
|
|
||||||
var индекс = this.подписки.indexOf(подписка);
|
|
||||||
if (индекс !== -1)
|
|
||||||
{
|
|
||||||
this.подписки.splice(индекс, 1);
|
|
||||||
}
|
|
||||||
var подписка = удалить.shift()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this._сгенерироватьUUID = function()
|
|
||||||
{
|
|
||||||
// https://stackoverflow.com/a/2117523
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
|
|
||||||
/[xy]/g,
|
|
||||||
function(c)
|
|
||||||
{
|
|
||||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
||||||
return v.toString(16);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Конструктор.
|
|
||||||
this.подписки = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Связь событий и реакций в виде последовательности (череды)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
function Мир()
|
|
||||||
{
|
|
||||||
// Разобрать события и реакции, выраженные в тексте.
|
|
||||||
this.разобрать = function(череда)
|
|
||||||
{
|
|
||||||
var соответствия = this._событияРеакции(череда);
|
|
||||||
for (var событие in соответствия)
|
|
||||||
{
|
|
||||||
if (!(событие in this.события))
|
|
||||||
{
|
|
||||||
this.события[событие] = new Уведомитель();
|
|
||||||
}
|
|
||||||
var реакции = соответствия[событие];
|
|
||||||
for (var номер in реакции)
|
|
||||||
{
|
|
||||||
const реакция = реакции[номер];
|
|
||||||
const название = this._имяФункцииИзРеакции(реакция);
|
|
||||||
const функция = eval(название);
|
|
||||||
var тут = this;
|
|
||||||
this.события[событие].подписать(function(){
|
|
||||||
функция(тут);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Уведомить о событии при его наличии.
|
|
||||||
this.уведомить = function(событие)
|
|
||||||
{
|
|
||||||
if (событие in this.события)
|
|
||||||
{
|
|
||||||
this.события[событие].уведомить();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Разобрать текст с событиями и реакциями, вернуть словарь их соответствия.
|
|
||||||
this._событияРеакции = function(текст)
|
|
||||||
{
|
|
||||||
var соответствие = {};
|
|
||||||
|
|
||||||
var элементы = текст.split("\n");
|
|
||||||
var имяСобытия = null;
|
|
||||||
for (var номер in элементы)
|
|
||||||
{
|
|
||||||
var элемент = элементы[номер];
|
|
||||||
// Пропускаем комментарии.
|
|
||||||
if (элемент.charAt(0) == "#")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var имя = элемент.trim();
|
|
||||||
// Пропускаем пустые строки.
|
|
||||||
if (!имя.length)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Событие.
|
|
||||||
if (имя == элемент)
|
|
||||||
{
|
|
||||||
if (!(имя in соответствие))
|
|
||||||
{
|
|
||||||
имяСобытия = имя;
|
|
||||||
соответствие[имя] = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Реакция.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
соответствие[имяСобытия].push(имя);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return соответствие;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Преобразовать имя реакции в название функции.
|
|
||||||
this._имяФункцииИзРеакции = function(реакция)
|
|
||||||
{
|
|
||||||
var имя = "";
|
|
||||||
|
|
||||||
var части = реакция.split(" ");
|
|
||||||
for (var номер in части)
|
|
||||||
{
|
|
||||||
var часть = части[номер];
|
|
||||||
имя += часть.charAt(0).toUpperCase() + часть.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return имя;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Конструктор.
|
|
||||||
this.события = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Создание глобального мира.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
мир = new Мир();
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
мир.ресурсы = {
|
мир.ресурсы = {
|
||||||
изображения: {
|
изображения: {
|
||||||
основа: "основа.jpg",
|
основа: "р/отладка/основа.jpg",
|
||||||
},
|
},
|
||||||
звуки: {
|
звуки: {
|
||||||
цикл: "loop.wav",
|
цикл: "р/звуки/555803__ddmyzik__sunset-loop.wav",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
мир.уведомить("пуск");
|
|
||||||
11
index.html
@@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>J 0.1.0</title>
|
<title>K 0.9.0</title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/phaser@3.54.0/dist/phaser.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/phaser@3.54.0/dist/phaser.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
@@ -25,8 +25,11 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="родитель"></div>
|
<div id="родитель"></div>
|
||||||
<script src="001.мир.js"></script>
|
<script>
|
||||||
<script src="011.phaser.js"></script>
|
var мир = {};
|
||||||
<script src="499.пуск.js"></script>
|
</script>
|
||||||
|
<script src="011.настройки.js"></script>
|
||||||
|
<script src="101.ресурсы.js"></script>
|
||||||
|
<script src="999.игра.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
var мир = {};
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
||||||
<title>J 0.1.0</title>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/phaser@3.54.0/dist/phaser.min.js"></script>
|
|
||||||
<style>
|
|
||||||
html, body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
height: 100vh;
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
#родитель
|
|
||||||
{
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="родитель"></div>
|
|
||||||
<script src="001.мир.js"></script>
|
|
||||||
<script src="011.настройки.js"></script>
|
|
||||||
<script src="101.ресурсы.js"></script>
|
|
||||||
<script src="999.игра.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
BIN
основа.jpg
|
Before Width: | Height: | Size: 1.2 KiB |
BIN
р/вещи/банка_молока.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
р/вещи/банка_молока.xcf
Normal file
BIN
р/вещи/крышка-подпола.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
р/вещи/крышка-подпола.xcf
Normal file
BIN
р/вещи/лестница.png
Normal file
|
After Width: | Height: | Size: 376 KiB |
BIN
р/вещи/лестница.xcf
Normal file
BIN
р/вещи/лужа.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
р/вещи/лужа.xcf
Normal file
BIN
р/вещи/окно.xcf
Normal file
BIN
р/вещи/окно_дыра.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
р/вещи/окно_разбитая-часть.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
р/вещи/самовар.png
Normal file
|
After Width: | Height: | Size: 161 KiB |
BIN
р/вещи/самовар.xcf
Normal file
BIN
р/вещи/стрела.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
р/вещи/стрела.xcf
Normal file
BIN
р/животные/мышь.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
р/животные/мышь.xcf
Normal file
BIN
р/животные/паук.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
р/животные/паук.xcf
Normal file
BIN
р/звуки/235596__tcrocker68__large-glassbottle-fall-woodfloor.wav
Normal file
BIN
р/звуки/330800__czarcazas__shattering-glass-small.mp3
Normal file
BIN
р/звуки/331381__qubodup__public-domain-jump-sound.wav
Normal file
BIN
р/звуки/352065__cabled-mess__glassy-bits-06.wav
Normal file
BIN
р/звуки/360432__davethetech__clink-bottle3.wav
Normal file
BIN
р/звуки/387922__setuniman__scheming-1o95.mp3
Normal file
BIN
р/звуки/437650__dersuperanton__getting-hit-damage-scream.wav
Normal file
BIN
р/звуки/448004__kneeling__break-window.mp3
Normal file
BIN
р/звуки/521552__omerbhatti34__arrow-impact.mp3
Normal file
BIN
р/звуки/543927__eminyildirim__pistol-gun-cocking.wav
Normal file
10
р/звуки/README.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
* https://freesound.org/people/DDmyzik/sounds/555803/
|
||||||
|
* https://freesound.org/people/Setuniman/sounds/387922/
|
||||||
|
* https://freesound.org/people/qubodup/sounds/331381/
|
||||||
|
* https://freesound.org/people/davethetech/sounds/360432/
|
||||||
|
* https://freesound.org/people/omerbhatti34/sounds/521552/
|
||||||
|
* https://freesound.org/people/Czarcazas/sounds/330800/
|
||||||
|
* https://freesound.org/people/Kneeling/sounds/448004/
|
||||||
|
* https://freesound.org/people/EminYILDIRIM/sounds/543927/
|
||||||
|
* https://freesound.org/people/tcrocker68/sounds/235596/
|
||||||
|
* https://freesound.org/people/cabled_mess/sounds/352065/
|
||||||
53
р/колобок/анимации/колобок-анимации.autosave.scml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<spriter_data scml_version="1.0" generator="BrashMonkey Spriter" generator_version="r9">
|
||||||
|
<folder id="0">
|
||||||
|
<file id="0" name="колобок_вращение.png" width="70" height="70" pivot_x="0.5" pivot_y="0.5"/>
|
||||||
|
<file id="1" name="колобок_прыжок.png" width="56" height="90" pivot_x="0.5" pivot_y="0.357143"/>
|
||||||
|
</folder>
|
||||||
|
<entity id="0" name="колобок">
|
||||||
|
<animation id="0" name="крутится-прыгает" length="1500" interval="100">
|
||||||
|
<mainline>
|
||||||
|
<key id="0">
|
||||||
|
<object_ref id="0" timeline="0" key="0" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="1" time="200">
|
||||||
|
<object_ref id="0" timeline="0" key="1" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="2" time="400">
|
||||||
|
<object_ref id="0" timeline="0" key="2" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="3" time="600">
|
||||||
|
<object_ref id="0" timeline="0" key="3" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="4" time="800">
|
||||||
|
<object_ref id="0" timeline="0" key="4" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="5" time="1000">
|
||||||
|
<object_ref id="0" timeline="1" key="0" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
</mainline>
|
||||||
|
<timeline id="0" name="колобок_вращение">
|
||||||
|
<key id="0">
|
||||||
|
<object folder="0" file="0" angle="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="1" time="200">
|
||||||
|
<object folder="0" file="0" angle="90"/>
|
||||||
|
</key>
|
||||||
|
<key id="2" time="400">
|
||||||
|
<object folder="0" file="0" angle="180"/>
|
||||||
|
</key>
|
||||||
|
<key id="3" time="600">
|
||||||
|
<object folder="0" file="0" angle="270"/>
|
||||||
|
</key>
|
||||||
|
<key id="4" time="800" spin="0">
|
||||||
|
<object folder="0" file="0" angle="0"/>
|
||||||
|
</key>
|
||||||
|
</timeline>
|
||||||
|
<timeline id="1" name="колобок_прыжок">
|
||||||
|
<key id="0" time="1000" spin="0">
|
||||||
|
<object folder="0" file="1"/>
|
||||||
|
</key>
|
||||||
|
</timeline>
|
||||||
|
</animation>
|
||||||
|
</entity>
|
||||||
|
</spriter_data>
|
||||||
53
р/колобок/анимации/колобок-анимации.scml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<spriter_data scml_version="1.0" generator="BrashMonkey Spriter" generator_version="r9">
|
||||||
|
<folder id="0">
|
||||||
|
<file id="0" name="колобок_вращение.png" width="70" height="70" pivot_x="0.5" pivot_y="0.5"/>
|
||||||
|
<file id="1" name="колобок_прыжок.png" width="56" height="90" pivot_x="0.5" pivot_y="0.357143"/>
|
||||||
|
</folder>
|
||||||
|
<entity id="0" name="колобок">
|
||||||
|
<animation id="0" name="крутится-прыгает" length="1500" interval="100">
|
||||||
|
<mainline>
|
||||||
|
<key id="0">
|
||||||
|
<object_ref id="0" timeline="0" key="0" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="1" time="200">
|
||||||
|
<object_ref id="0" timeline="0" key="1" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="2" time="400">
|
||||||
|
<object_ref id="0" timeline="0" key="2" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="3" time="600">
|
||||||
|
<object_ref id="0" timeline="0" key="3" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="4" time="800">
|
||||||
|
<object_ref id="0" timeline="0" key="4" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="5" time="1000">
|
||||||
|
<object_ref id="0" timeline="1" key="0" z_index="0"/>
|
||||||
|
</key>
|
||||||
|
</mainline>
|
||||||
|
<timeline id="0" name="колобок_вращение">
|
||||||
|
<key id="0">
|
||||||
|
<object folder="0" file="0" angle="0"/>
|
||||||
|
</key>
|
||||||
|
<key id="1" time="200">
|
||||||
|
<object folder="0" file="0" angle="90"/>
|
||||||
|
</key>
|
||||||
|
<key id="2" time="400">
|
||||||
|
<object folder="0" file="0" angle="180"/>
|
||||||
|
</key>
|
||||||
|
<key id="3" time="600">
|
||||||
|
<object folder="0" file="0" angle="270"/>
|
||||||
|
</key>
|
||||||
|
<key id="4" time="800" spin="0">
|
||||||
|
<object folder="0" file="0" angle="0"/>
|
||||||
|
</key>
|
||||||
|
</timeline>
|
||||||
|
<timeline id="1" name="колобок_прыжок">
|
||||||
|
<key id="0" time="1000" spin="0">
|
||||||
|
<object folder="0" file="1"/>
|
||||||
|
</key>
|
||||||
|
</timeline>
|
||||||
|
</animation>
|
||||||
|
</entity>
|
||||||
|
</spriter_data>
|
||||||
BIN
р/колобок/анимации/колобок_вращение.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
р/колобок/анимации/колобок_прыжок.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
р/колобок/колобок.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
р/колобок/колобок_все.xcf
Normal file
BIN
р/колобок/колобок_неподвижен.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
р/колобок/колобок_неподвижен.xcf
Normal file
BIN
р/колобок/колобок_прыжок.xcf
Normal file
BIN
р/отладка/линия_вертикальная.png
Normal file
|
After Width: | Height: | Size: 573 B |
BIN
р/отладка/линия_вертикальная.xcf
Normal file
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
р/отладка/основа.xcf
Normal file
BIN
р/сцены/изба.jpg
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
р/сцены/изба.xcf
Normal file
BIN
р/сцены/подпол.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |