Commit 5ec0fba6 authored by 邱旭's avatar 邱旭

init

parent e61c7309
node_modules/
dist/
build/
released/
released/resource/
yarn-error.log
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>
\ No newline at end of file
/*
* index.mjs
* Created by 还有醋v on 2022/5/27.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
/**
* 插入banner变量
* @param {{values:{[key in string]: string|number|Function<string|number>}}} options
*/
export default function pluginBannerVariable(options) {
const { values } = options;
return {
name: "banner-variable",
banner() {
let code = "var ";
for (const key in values) {
const value = values[key] instanceof Function ? values[key]() : values[key];
code += `${key}=${value},`;
}
code = code.slice(0, code.length - 1) + ";";
return code;
},
}
}
/*
* utils.mjs.js
* Created by 还有醋v on 2022/5/27.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
import childProcess from "child_process";
export function _debounce(fn, delay = 1000) {
let timer = null;
return function (...args) {
timer && clearTimeout(timer);
timer = setTimeout(fn, delay, ...args);
};
}
export function runScript(scriptPath, callback) {
let invoked = false;
const process = childProcess.fork(scriptPath);
process.on('error', (err) => {
if (invoked) return;
invoked = true;
callback(err);
});
process.on('exit', (code) => {
if (invoked) return;
invoked = true;
const err = code === 0 ? null : new Error('exit code ' + code);
callback(err);
});
}
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>game_template</title>
<title>new_game_template</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
......@@ -37,20 +37,33 @@
overflow: hidden;
position: absolute;
background-color: #ffffff;
/* background: linear-gradient(#93dbb7,#ff0,#b5d89a); */
/* background: linear-gradient(#93dbb7,#b5d89a); */
/* 背景图片,解决加载太慢,白屏问题,加了这个下面的__loading__可以删掉了 */
/* background-size: 100%;
background-position: center;
background-image: url("https://yun.duiba.com.cn/db_games/activity/game/1550472986/resource/assets/playscene/playscenebg.jpg"); */
}
#__loading__ {
position: absolute;
left: 50%;
top: 50%;
margin-left: -45px;
color: #ffffff;
}
#cusEngine {
line-height: 0;
font-size: 0;
position: absolute;
}
#canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="__loading__" style="position:absolute;left:50%;top:50%;margin-left:-45px;color:#ffffff">拼命加载中...</div>
<div id="cusEngine" style="line-height:0;font-size:0;position: absolute;">
<canvas id="canvas" style="width: 100%;height: 100%"></canvas>
<div id="__loading__">拼命加载中...</div>
<div id="cusEngine">
<canvas id="canvas"></canvas>
</div>
<!-- 帧率检测 -->
<!-- <script src="https://yun.duiba.com.cn/db_games/libs0126/stats.js"></script> -->
......
/*
* lib.d.ts
* Created by 还有醋v on 2022/5/27.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
declare const __ENV__: "development" | "production";
declare const __version__: string;
declare const __buildDate__: string;
......@@ -2,11 +2,12 @@
"name": "game_template",
"version": "1.0.0",
"description": "game_template",
"main": "index.html",
"main": "released/output.js",
"module": "released/output.module.js",
"scripts": {
"dev": "node rollup.dev.mjs -p 8080",
"build": "npm run handleRes && node scripts/mergeJson && node scripts/upload && npm run buildTS",
"buildTS": "rollup -c rollup.prod.mjs && node scripts/uploadSingleJs",
"buildTS": "npm version patch && rollup -c rollup.prod.mjs && node scripts/uploadSingleJs",
"handleLotS": "node scripts/handleLotS",
"handleRes": "node scripts/delRel && node scripts/copyRes && node scripts/createTm && node scripts/textureMerge && node scripts/delTm && node scripts/imageMin",
"copyJs": "node scripts/copyJs",
......@@ -25,11 +26,13 @@
"chalk": "^2.3.0",
"co": "^4.6.0",
"del": "^2.2.1",
"duiba-utils": "^1.0.9",
"fs": "0.0.2",
"glslify": "^7.1.1",
"imagemin": "^7.0.1",
"imagemin-mozjpeg": "^8.0.0",
"imagemin-pngquant": "^8.0.0",
"md5": "^2.3.0",
"pack_textures": "^1.1.9",
"path": "^0.12.7",
"progress": "^2.0.0",
......@@ -40,17 +43,11 @@
"rollup-plugin-glsl-loader": "^1.0.13",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"tslint": "^5.9.1",
"typescript": "^4.5.4"
},
"dependencies": {
"colors": "^1.4.0",
"duiba-utils": "^1.0.9",
"md5": "^2.3.0"
},
"author": "MrKwon",
"license": "ISC"
}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>game_template</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<!-- polyfill -->
<script src="//yun.duiba.com.cn/db_games/libs0924/polyfill_220525.js" crossorigin="anonymous"></script>
<!-- 渲染引擎 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/fyge2044.min.js" crossorigin="anonymous"></script>
<!--<script src="libs/fyge.min.js" crossorigin="anonymous"></script>-->
<!-- svga解析库 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js" crossorigin="anonymous"></script>
<!-- 放声音的 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/howler.min.js" crossorigin="anonymous"></script>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: #ffffff;
/* background: linear-gradient(#93dbb7,#ff0,#b5d89a); */
/* background: linear-gradient(#93dbb7,#b5d89a); */
/* 背景图片,解决加载太慢,白屏问题,加了这个下面的__loading__可以删掉了 */
/* background-size: 100%;
background-position: center;
background-image: url("https://yun.duiba.com.cn/db_games/activity/game/1550472986/resource/assets/playscene/playscenebg.jpg"); */
}
</style>
</head>
<body>
<div id="__loading__" style="position:absolute;left:50%;top:50%;margin-left:-45px;color:#ffffff">拼命加载中...</div>
<div id="cusEngine" style="line-height:0;font-size:0;position: absolute;">
<canvas id="canvas" style="width: 100%;height: 100%"></canvas>
</div>
<!-- 帧率检测 -->
<!-- <script src="https://yun.duiba.com.cn/db_games/libs0126/stats.js"></script> -->
<script>
const app = {
checkMember: () => {
return false;
}
};
function getApp() {
return app;
}
document.oncontextmenu = () => false;
</script>
<script>
var CFG = CFG || {};
CFG.projectId = 'pa525eacc';//线上直接写死
CFG.appID = '76177';//线上直接写死
//TODO我的奖品链接
window["recordUrl"] = "fe071865b.html";
window.addEventListener("load", function () {
//获取canvas
var canvas = document.getElementById("canvas");
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new output.Main(canvas);
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
canvas.addEventListener('touchend', mouseEvent, false);
window.stage = main.stage
})
</script>
<!-- 构建的js -->
<script src="//yun.duiba.com.cn/db_games/activity/template/1653551525/output.js" crossorigin="anonymous"></script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,30 +4,34 @@
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import json from "@rollup/plugin-json";
import typescript from "@rollup/plugin-typescript";
import childProcess from "child_process";
import chalk from 'chalk';
import * as fs from "fs";
import * as path from "path";
import * as rollup from "rollup";
import livereload from "rollup-plugin-livereload";
import progress from "rollup-plugin-progress";
import replace from "rollup-plugin-replace";
import serve from "rollup-plugin-serve";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import commonjs from "rollup-plugin-commonjs";
import glslLoader from "rollup-plugin-glsl-loader";
import livereload from "rollup-plugin-livereload";
import progress from "rollup-plugin-progress";
import serve from "rollup-plugin-serve";
import colors from "colors";
import BannerVariable from "./config/plugins/BannerVariable/index.mjs";
import { _debounce, runScript } from "./config/utils/utils.mjs";
const argv = process.argv;
const port = +argv[argv.indexOf("-p") + 1] || 8080;
const open = +argv[argv.indexOf("-open") + 1] || false;
const { version } = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
watchResChange();
const options = {
input: "src/Main.ts",
// input: "src/Main.ts",
input: "src/index.ts",
cache: true,
output: [
{
......@@ -44,16 +48,20 @@ const options = {
],
onwarn(warning) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
console.log(colors.red(`\n(!) ${warning.message}`));
console.log(chalk.red(`\n(!) ${warning.message}`));
}
},
plugins: [
progress(),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
BannerVariable({
values: {
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
__version__: JSON.stringify(version),
__buildDate__: JSON.stringify(new Date()),
}
}),
resolve(),
typescript({ tsconfig: "./tsconfig.json" }),
resolve(),
commonjs(),
json(),
glslLoader({
......@@ -92,37 +100,7 @@ function watchResChange() {
|| filename === "res.json"
|| filename === "skin.json"
) return;
runScript(flushScript, (err) => err && console.log(err));
runScript(flushScript, (err) => err && console.error(err));
}));
runScript(flushScript, (err) => err && console.log(err));
}
function runScript(scriptPath, callback) {
let invoked = false;
const process = childProcess.fork(scriptPath);
process.on('error', (err) => {
if (invoked) return;
invoked = true;
callback(err);
});
process.on('exit', (code) => {
if (invoked) return;
invoked = true;
const err = code === 0 ? null : new Error('exit code ' + code);
callback(err);
});
}
function _debounce(fn, delay = 1000) {
let timer = null;
return function (...args) {
timer && clearTimeout(timer);
timer = setTimeout(fn, delay, ...args);
};
runScript(flushScript, (err) => err && console.error(err));
}
......@@ -5,13 +5,16 @@
*/
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import fs from "fs";
import commonjs from "rollup-plugin-commonjs";
import glslLoader from "rollup-plugin-glsl-loader";
import progress from "rollup-plugin-progress";
import replace from "rollup-plugin-replace";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import BannerVariable from "./config/plugins/BannerVariable/index.mjs";
const { version } = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
export default {
input: "src/Main.ts",
......@@ -30,10 +33,14 @@ export default {
],
plugins: [
progress(),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'prod'),
BannerVariable({
values: {
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
__version__: JSON.stringify(version),
__buildDate__: JSON.stringify(new Date()),
}
}),
resolve({ preferBuiltins: true }),
resolve(),
typescript({ sourceMap: true, watch: false, }),
commonjs(),
json(),
......
......@@ -7,7 +7,6 @@ const chalk = require('chalk');
const ProgressBar = require('progress');
const iconv = require('iconv-lite');
const colors = require("colors");
const config = require("../project.json");
......@@ -136,7 +135,7 @@ if (!config.name) {
const now = new Date();
const version = Math.round(now.getTime() / 1000);
console.log(colors.bgMagenta(`资源版本号:\n${version}`));
console.log(chalk.bgMagenta(`资源版本号:\n${version}`));
const autoupload = new TuiaAutoUpload({
dir: './released/',
......
......@@ -3,7 +3,7 @@ const co = require('co');
const OSS = require('ali-oss');
const config = require("../project.json");
const colors = require("colors");
const chalk = require('chalk');
//只打包js时,自执行上传
uploadSingleJs();
......@@ -27,7 +27,7 @@ function uploadSingleJs(url) {
require("./createHtml")(`${config.type}/${config.name}/${version}`);
console.log(colors.bgGreen(`版本号:\n${version}`));
console.log(chalk.bgGreen(`版本号:\n${version}`));
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -135,7 +135,7 @@ export function sendTbNet(
//网络超时
// let waitObj;
//@ts-ignore 本地开发,直接取数据
if (!my) {
if (__ENV__ == "development") {
const netInfo = netName.split(".");
const url = `../../mock/miniTb/${netInfo[0]}/${netInfo[1]}.json`;
fetchAsync(url)
......
......@@ -59,7 +59,7 @@ export function sendWebNet(
): Promise<dataOut> {
return new Promise((resolve, reject) => {
if (window.location.port == "8080") { // window.location.port == "8080";考虑按端口判断 TODO
if (__ENV__ == "development") { // TODO 编译后提供的变量
let path = netName.split('{projectId}/')[1];//后缀名字之前的是文件夹,mock里结构
if (path.indexOf('/') <= -1) path = `projectX/${path}`;
const url = "../../mock/webNet/" + path + ".json";
......
console.log(11111);
console.log(new Date(__buildDate__));
......@@ -255,7 +255,7 @@ export class Jump3d extends Scene3D {
this.player.push(this.pushObj.c);
}
})
.to({ c: 0.65 }, 1600, Ease.quadInOut)
.to({ c: 0.65 }, 1600) // TODO 变态难度就加上后面的参数 , Ease.quadInOut
.call(() => {
console.log("最大蓄力了");
});
......
......@@ -659,11 +659,6 @@ color-support@^1.1.2:
resolved "http://npm.dui88.com:80/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
integrity sha1-k4NDeaHMmgxh+C9S8NBDIiUb1aI=
colors@^1.4.2:
version "1.4.0"
resolved "http://npm.dui88.com:80/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
integrity sha1-xQSRR51MG9rtLJztMs98fcI2D3g=
commander@^2.12.1, commander@^2.15.1, commander@^2.20.0, commander@^2.8.1:
version "2.20.3"
resolved "http://npm.dui88.com:80/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
......@@ -3140,14 +3135,6 @@ rollup-plugin-progress@^1.1.2:
dependencies:
chalk "^2.4.2"
rollup-plugin-replace@^2.2.0:
version "2.2.0"
resolved "http://npm.dui88.com:80/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz#f41ae5372e11e7a217cde349c8b5d5fd115e70e3"
integrity sha1-9BrlNy4R56IXzeNJyLXV/RFecOM=
dependencies:
magic-string "^0.25.2"
rollup-pluginutils "^2.6.0"
rollup-plugin-serve@^1.1.0:
version "1.1.0"
resolved "http://npm.dui88.com:80/rollup-plugin-serve/-/rollup-plugin-serve-1.1.0.tgz#0654a57021a21b903340c69940f7463706e8288d"
......@@ -3166,7 +3153,7 @@ rollup-plugin-terser@^7.0.2:
serialize-javascript "^4.0.0"
terser "^5.0.0"
rollup-pluginutils@^2.6.0, rollup-pluginutils@^2.8.1:
rollup-pluginutils@^2.8.1:
version "2.8.2"
resolved "http://npm.dui88.com:80/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
integrity sha1-cvKvB0i1kjZNvTOJ5gDlqURKNR4=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment