Skip to content

Commit

Permalink
#29 texture selection
Browse files Browse the repository at this point in the history
  • Loading branch information
L3P3 committed Aug 4, 2024
1 parent 3e5647c commit 132b3d8
Show file tree
Hide file tree
Showing 33 changed files with 296 additions and 324 deletions.
3 changes: 0 additions & 3 deletions app-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
<body>
<script type=module src=https://cdn.jsdelivr.net/gh/L3P3/lui@2/lui.dev.js></script>
<script type=module src=src/app.js></script>
<script>
window.ASSETS = 'assets/';
</script>
</body>
</html>
3 changes: 0 additions & 3 deletions app-prod.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
<body>
<script defer src=https://cdn.jsdelivr.net/gh/L3P3/lui@2/lui.dev.js></script>
<script defer src=dist/app-en.js></script>
<script>
window.ASSETS = 'assets/';
</script>
</body>
</html>
Binary file removed assets/blocks.webp
Binary file not shown.
8 changes: 4 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ async function lang_generate(lang) {
return output;
}

const env_set = async (version, debug, lang, api, api_download) => Promise.all([
const env_set = async (version, debug, lang, api, api_data) => Promise.all([
writeFile(
'./src/etc/env.js',
`export const VERSION = '${version}';
export const DEBUG = ${debug};
export const LANG = '${lang}';
export const API = '${api}';
export const API_DOWNLOAD = '${api_download}';
export const API_DATA = '${api_data}';
`,
'utf8'
),
Expand Down Expand Up @@ -92,7 +92,7 @@ async function build_js(lang) {
false,
lang,
prod ? '/api/minicraft/' : '//l3p3.de/api/minicraft/',
prod ? '/static/minicraft/worlds/' : '//l3p3.de/static/minicraft/worlds/'
prod ? '/static/minicraft/' : '//l3p3.de/static/minicraft/'
);

console.log('js pass 1...');
Expand Down Expand Up @@ -170,7 +170,7 @@ try {
for (const lang of languages) await build_js(lang);
}
finally {
await env_set('dev', true, 'en', '//l3p3.de/api/minicraft/', '//l3p3.de/static/minicraft/worlds/');
await env_set('dev', true, 'en', '//l3p3.de/api/minicraft/', '//l3p3.de/static/minicraft/');
}

console.log('done.');
2 changes: 1 addition & 1 deletion locales/de.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
amount: Anzahl
ask_world_delete_1: Welt "
ask_world_delete_2: " wirklich löschen?
back: Zurück
back_to_game: Zurück zum Spiel
change_world_name: Welt-Namen ändern
chunk_regenerated: Chunk neu generiert.
Expand Down Expand Up @@ -78,7 +79,6 @@ settings: Einstellungen
show_world_settings: Aktionen/Einstellungen zur Welt anzeigen
spawn_updated: Startpunkt aktualisiert.
surfaces_colored: Einfarbig
surfaces_textured: Texturiert
surfaces: Oberflächen
teleported_to_spawn: Zum Startpunkt teleportiert.
teleported_to: Teleportiert zu
Expand Down
2 changes: 1 addition & 1 deletion locales/en.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
amount: Amount
ask_world_delete_1: Really delete world "
ask_world_delete_2: "?
back: Back
back_to_game: Back to game
change_world_name: Change world name
chunk_regenerated: Chunk regenerated.
Expand Down Expand Up @@ -78,7 +79,6 @@ settings: Settings
show_world_settings: Show world settings
spawn_updated: Spawn updated.
surfaces_colored: Plain
surfaces_textured: Textured
surfaces: Surfaces
teleported_to_spawn: Teleported to spawn.
teleported_to: Teleported to
Expand Down
2 changes: 1 addition & 1 deletion locales/ru.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
amount: Число
ask_world_delete_1: Мир "
ask_world_delete_2: " точно удалить?
back: Вернуться
back_to_game: Вернуться в игру
change_world_name: Изменит имя миру
chunk_regenerated: Чанки перезагружается
Expand Down Expand Up @@ -78,7 +79,6 @@ settings: Настройки
show_world_settings: Акции/Показать настройки мира
spawn_updated: Началная точка обновлена
surfaces_colored: Одноцветный
surfaces_textured: С текстурами
surfaces: Поверхность
teleported_to_spawn: Переместится к стартовой точки
teleported_to: Переместится к
Expand Down
2 changes: 1 addition & 1 deletion locales/tr.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
amount: Miktar
ask_world_delete_1: "
ask_world_delete_2: " isimli dünya gerçekten silinsin mi?
back: Geri
back_to_game: Oyuna geri dön
change_world_name: Dünyayı değiştir
chunk_regenerated: Parça yenilendi.
Expand Down Expand Up @@ -78,7 +79,6 @@ settings: Ayarlar
show_world_settings: Dünya ayarlarını göster
spawn_updated: Spawn güncellendi.
surfaces_colored: Sade
surfaces_textured: Dokulu
surfaces: Yüzeyler
teleported_to_spawn: Spawn\'a ışınlandı.
teleported_to: Şuraya ışınlandı:
Expand Down
4 changes: 2 additions & 2 deletions locales/uk.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
amount: Номер
ask_world_delete_1: Світ "
ask_world_delete_2: " дійсно видалити?
back: Повернуться
back_to_game: Повернуться в гру
change_world_name: Змінити ім\'я світу
chunk_regenerated: Участки відновлені.
Expand Down Expand Up @@ -77,8 +78,7 @@ selection_secondary: Друга крапка вибору
settings: Налаштування
show_world_settings: Акції/Показати налаштування світу.
spawn_updated: Початкова крапка оновлена.
surfaces_colored: Однотонні
surfaces_textured: Текстурований
surfaces_colored: Однотонні
surfaces: Поверхности
teleported_to_spawn: Перемістився до початкової.
teleported_to: Переміститися до
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minicraft",
"version": "0.10.7",
"version": "0.11.0",
"description": "voxel-based 3d game, written in javascript",
"homepage": "https://l3p3.de/minicraft",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ button {
}
.game .bitmap {
background-size: 100% auto;
transform: scaleY(-1);
}
.game > .diagnostics {
position: absolute;
Expand Down Expand Up @@ -266,9 +265,11 @@ button {
margin: 1rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
grid-template-rows: 3rem;
gap: 1rem;
}
.game .menu > .settings > * {
min-height: 2rem;
}
.game .menu.inventory, .game .menu.advanced {
display: flex;
align-items: center;
Expand Down
4 changes: 4 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import {
game_key,
game_save,
} from './game/m_game.js';
import {
tiles_set,
} from './game/m_renderer.js';

import App from './game/c_app.js';

Expand Down Expand Up @@ -121,6 +124,7 @@ function Root() {
addEventListener_('touchstart', handler_touch, true);
}
}, [flag_touch]);
hook_effect(tiles_set, [state.config.textures]);

hook_dom('', {
onkeydown: handler_key,
Expand Down
5 changes: 3 additions & 2 deletions src/etc/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {
locale_item_labels,
} from './locale.js';

export const APP_VIEW_WORLDS = 0;
export const APP_VIEW_GAME = 1;
export const APP_VIEW_GAME = 0;
export const APP_VIEW_SETTINGS = 1;
export const APP_VIEW_WORLDS = 2;

export const CHUNK_WIDTH_L2 = 4;
export const CHUNK_WIDTH = 1 << CHUNK_WIDTH_L2;
Expand Down
2 changes: 1 addition & 1 deletion src/etc/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const VERSION = 'dev';
export const DEBUG = true;
export const LANG = 'en';
export const API = '//l3p3.de/api/minicraft/';
export const API_DOWNLOAD = '//l3p3.de/static/minicraft/worlds/';
export const API_DATA = '//l3p3.de/static/minicraft/';
3 changes: 3 additions & 0 deletions src/etc/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ export const localStorage_getItem = key => localStorage_.getItem(key);
export const localStorage_setItem = localStorage_.setItem.bind(localStorage_);
export const localStorage_removeItem = localStorage_.removeItem.bind(localStorage_);
export const indexedDB_ = window_.indexedDB;
export const fetch_ = fetch;
export const Error_ = msg => new Error(msg);
export const Uint8Array_ = Uint8Array;
export const Uint32Array_ = Uint32Array;
export const Set_ = Set;
export const Map_ = Map;
export const Number_ = Number;
export const Object_ = Object;
Expand Down
2 changes: 1 addition & 1 deletion src/etc/locale.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const locale_amount = 'Amount';
export const locale_ask_world_delete_1 = 'Really delete world "';
export const locale_ask_world_delete_2 = '"?';
export const locale_back = 'Back';
export const locale_back_to_game = 'Back to game';
export const locale_change_world_name = 'Change world name';
export const locale_chunk_regenerated = 'Chunk regenerated.';
Expand Down Expand Up @@ -78,7 +79,6 @@ export const locale_settings = 'Settings';
export const locale_show_world_settings = 'Show world settings';
export const locale_spawn_updated = 'Spawn updated.';
export const locale_surfaces_colored = 'Plain';
export const locale_surfaces_textured = 'Textured';
export const locale_surfaces = 'Surfaces';
export const locale_teleported_to_spawn = 'Teleported to spawn.';
export const locale_teleported_to = 'Teleported to';
Expand Down
26 changes: 17 additions & 9 deletions src/etc/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
JSON_parse,
JSON_stringify,
Object_keys,
Set_,
localStorage_,
localStorage_getItem,
localStorage_removeItem,
Expand All @@ -25,7 +26,7 @@ if (
config_loaded['worlds'] &&
config_loaded['version'].startsWith('0.9.')
) {
const prefixes_keep = new Set(
const prefixes_keep = new Set_(
config_loaded['worlds']
.map(world => 'minicraft.world.' + world.id)
);
Expand All @@ -42,25 +43,20 @@ export const reducers = {
init: () => {
let needs_save = false;
const config = {
flag_textures: true,
flag_touch: false, // not saved
pixel_grouping: 1,
mouse_sensitivity: 3,
resolution_scaling: 4,
textures: 1,
view_angle: 120,
view_distance: 64,
world_last: 0,
/** @type {!Array<TYPE_WORLD_LISTING_LOCAL>} */
worlds: [],
};
if (config_loaded) {
let tmp = config_loaded['flag_textures'];
let tmp = config_loaded['pixel_grouping'];
if (tmp != null) {
config.flag_textures = tmp;
}
if ((
tmp = config_loaded['pixel_grouping']
) != null) {
config.pixel_grouping = tmp;
}
if ((
Expand All @@ -69,6 +65,18 @@ export const reducers = {
config.mouse_sensitivity = tmp;
}
config.resolution_scaling = config_loaded['resolution_scaling'];
if ((
tmp = config_loaded['textures']
) != null) {
config.textures = tmp;
}
else {
config.textures = (
config_loaded['flag_textures']
? 1
: 0
);
}
config.view_angle = config_loaded['view_angle'];
config.view_distance = config_loaded['view_distance'];
if ((
Expand Down Expand Up @@ -117,10 +125,10 @@ export const reducers = {
if (config === state.config_saved) return state;
localStorage_setItem('minicraft.config', JSON_stringify({
'version': VERSION,
'flag_textures': config.flag_textures,
'pixel_grouping': config.pixel_grouping,
'mouse_sensitivity': config.mouse_sensitivity,
'resolution_scaling': config.resolution_scaling,
'textures': config.textures,
'view_angle': config.view_angle,
'view_distance': config.view_distance,
'world_last': config.world_last,
Expand Down
1 change: 0 additions & 1 deletion src/etc/textures.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/etc/textures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const TILES_COUNT = 26;
export const TILES_RESOLUTION_LOG2 = 4;
export const TILES_RESOLUTION = 1 << TILES_RESOLUTION_LOG2;

export const TILE_STONE = 0;
export const TILE_GRASS_TOP = 1;
export const TILE_DIRT = 2;
export const TILE_COBBLE = 3;
export const TILE_PLANKS = 4;
export const TILE_BEDROCK = 5;
export const TILE_LOG_SIDE = 6;
export const TILE_LEAVES = 7;
export const TILE_BRICKS = 8;
export const TILE_WOOL = 9;
export const TILE_SAND = 10;
export const TILE_GRAVEL = 11;
export const TILE_GLASS = 12;
export const TILE_BOOKSHELF = 13;
export const TILE_OBSIDIAN = 14;
export const TILE_STONE_BRICKS = 15;
export const TILE_SANDSTONE = 16;
export const TILE_LAPIS_BLOCK = 17;
export const TILE_IRON_BLOCK = 18;
export const TILE_GOLD_BLOCK = 19;
export const TILE_DIAMOND_BLOCK = 20;
export const TILE_EMERALD_BLOCK = 21;
export const TILE_REDSTONE_BLOCK = 22;
export const TILE_QUARTZ_BLOCK = 23;
export const TILE_GRASS_SIDE = 24;
export const TILE_LOG_TOP = 25;
14 changes: 9 additions & 5 deletions src/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,6 @@ var onmousedown;
*/
var onmouseup;

/**
@type {string}
*/
var ASSETS;

/**
@type {boolean}
*/
Expand Down Expand Up @@ -327,6 +322,15 @@ var TYPE_WORLD_API;
*/
var TYPE_CHAT_API;

/**
@typedef {{
id: number,
label: string,
owner: string,
}}
*/
var TYPE_TEXTURES_ITEM;

/**
@typedef {{
account: {
Expand Down
Loading

0 comments on commit 132b3d8

Please sign in to comment.