draw thing

moo

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/482817/1299586/draw%20thing.js

  1. (function() {
  2. "use strict";
  3. /******/
  4. var __webpack_modules__ = ({
  5. /***/
  6. "./src/Cow.js":
  7. /*!********************!*\
  8. !*** ./src/Cow.js ***!
  9. \********************/
  10. /***/
  11. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  12. __webpack_require__.r(__webpack_exports__);
  13. /* harmony import */
  14. var _config_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./config.json */ "./src/config.json");
  15. /* harmony import */
  16. var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./constants.js */ "./src/constants.js");
  17. /* harmony import */
  18. var _modules_entities_Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( /*! ./modules/entities/Player.js */ "./src/modules/entities/Player.js");
  19. /* harmony import */
  20. var _modules_plugins_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( /*! ./modules/plugins/index.js */ "./src/modules/plugins/index.js");
  21. /* harmony import */
  22. var _game_configs_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__( /*! ./game_configs/index.js */ "./src/game_configs/index.js");
  23. class Cow {
  24. constructor() {
  25. this.config = _config_json__WEBPACK_IMPORTED_MODULE_0__
  26. this.camera = _constants_js__WEBPACK_IMPORTED_MODULE_1__.camera
  27. this.renderer = _constants_js__WEBPACK_IMPORTED_MODULE_1__.renderer
  28. }
  29. addRender(renderKey, renderFunc) {
  30. this.renderer.addRender(renderKey, renderFunc)
  31. }
  32. deleteRender(renderKey) {
  33. this.renderer.renders.delete(renderKey)
  34. }
  35. }
  36. /* harmony default export */
  37. __webpack_exports__["default"] = (Cow);
  38. /***/
  39. }),
  40. /***/
  41. "./src/constants.js":
  42. /*!**************************!*\
  43. !*** ./src/constants.js ***!
  44. \**************************/
  45. /***/
  46. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  47. __webpack_require__.r(__webpack_exports__);
  48. /* harmony export */
  49. __webpack_require__.d(__webpack_exports__, {
  50. /* harmony export */
  51. camera: function() {
  52. return /* binding */ camera;
  53. },
  54. /* harmony export */
  55. cow: function() {
  56. return /* binding */ cow;
  57. },
  58. /* harmony export */
  59. renderer: function() {
  60. return /* binding */ renderer;
  61. },
  62. });
  63. /* harmony import */
  64. var _Cow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./Cow.js */ "./src/Cow.js");
  65. /* harmony import */
  66. var _modules_render_Camera_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__( /*! ./modules/render/Camera.js */ "./src/modules/render/Camera.js");
  67. /* harmony import */
  68. var _modules_render_Renderer_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__( /*! ./modules/render/Renderer.js */ "./src/modules/render/Renderer.js");
  69. const camera = new _modules_render_Camera_js__WEBPACK_IMPORTED_MODULE_7__["default"]()
  70. const renderer = new _modules_render_Renderer_js__WEBPACK_IMPORTED_MODULE_8__["default"]()
  71. const cow = new _Cow_js__WEBPACK_IMPORTED_MODULE_0__["default"]()
  72. /***/
  73. }),
  74. /***/
  75. "./src/modules/render/Camera.js":
  76. /*!**************************************!*\
  77. !*** ./src/modules/render/Camera.js ***!
  78. \**************************************/
  79. /***/
  80. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  81. __webpack_require__.r(__webpack_exports__);
  82. /* harmony import */
  83. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  84. class Camera {
  85. constructor() {
  86. this.x = 0
  87. this.y = 0
  88. this.distance = 0
  89. this.angle = 0
  90. this.speed = 0
  91. this.xOffset = 0
  92. this.yOffset = 0
  93. }
  94. setTo(x, y) {
  95. this.x = x
  96. this.y = y
  97. }
  98. update() {
  99. if (_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player?.alive) {
  100. const {
  101. CowUtils
  102. } = window
  103. this.distance = CowUtils.getDistance(this, _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player)
  104. this.angle = CowUtils.getDirection(_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player, this)
  105. this.speed = Math.min(this.distance * .01 * _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.renderer.delta, this.distance)
  106. if (this.distance > .05) {
  107. this.x += this.speed * Math.cos(this.angle)
  108. this.y += this.speed * Math.sin(this.angle)
  109. } else {
  110. this.setTo(
  111. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.x,
  112. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.player.y
  113. )
  114. }
  115. } else {
  116. this.setTo(
  117. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2,
  118. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.mapScale / 2
  119. )
  120. }
  121. this.xOffset = this.x - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenWidth / 2
  122. this.yOffset = this.y - _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.maxScreenHeight / 2
  123. }
  124. }
  125. /* harmony default export */
  126. __webpack_exports__["default"] = (Camera);
  127. /***/
  128. }),
  129. /***/
  130. "./src/modules/render/Renderer.js":
  131. /*!****************************************!*\
  132. !*** ./src/modules/render/Renderer.js ***!
  133. \****************************************/
  134. /***/
  135. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  136. __webpack_require__.r(__webpack_exports__);
  137. /* harmony import */
  138. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ../../constants.js */ "./src/constants.js");
  139. class Renderer {
  140. constructor() {
  141. this.canvas = void 0
  142. this.context = void 0
  143. this.renders = new Map()
  144. this.nowUpdate = void 0
  145. this.lastUpdate = this.nowUpdate
  146. this.delta = 0
  147. window.addEventListener("load", this.init.bind(this))
  148. }
  149. addRender(renderKey, renderFunc) {
  150. if (typeof renderKey !== 'string') return
  151. if (!(renderFunc instanceof Function)) return
  152. if (!this.renders.has(renderKey)) {
  153. this.renders.set(renderKey, new Map())
  154. }
  155. const rendersChunk = this.renders.get(renderKey)
  156. rendersChunk.set(rendersChunk.size + 1, renderFunc)
  157. }
  158. _updateAll() {
  159. _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.camera.update()
  160. }
  161. updateFrame() {
  162. this.nowUpdate = Date.now()
  163. this.delta = this.nowUpdate - this.lastUpdate
  164. this.lastUpdate = this.nowUpdate
  165. requestAnimationFrame(this.updateFrame.bind(this))
  166. this._updateAll()
  167. this.renders.forEach((rendersChunk) => {
  168. if (!rendersChunk.size) return
  169. rendersChunk.forEach((render) => {
  170. render()
  171. })
  172. })
  173. }
  174. init() {
  175. this.canvas = document.getElementById("gameCanvas")
  176. this.context = this.canvas.getContext("2d")
  177. this.updateFrame()
  178. }
  179. }
  180. /* harmony default export */
  181. __webpack_exports__["default"] = (Renderer);
  182. /***/
  183. }),
  184. /***/
  185. "./src/utils/CowUtils.js":
  186. /*!*******************************!*\
  187. !*** ./src/utils/CowUtils.js ***!
  188. \*******************************/
  189. /***/
  190. (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  191. __webpack_require__.r(__webpack_exports__);
  192. class CowUtils {
  193. static removeProto(object) {
  194. if (!(object instanceof Object)) return
  195. return JSON.parse(JSON.stringify(object))
  196. }
  197. static randInt(min, max) {
  198. return Math.floor(CowUtils.randFloat(min, max))
  199. }
  200. static randFloat(min, max) {
  201. if (typeof max === 'undefined') {
  202. max = min
  203. min = 0
  204. }
  205. return (Math.random() * (max - min + 1)) + min
  206. }
  207. static lerp(value1, value2, amount) {
  208. return value1 + (value2 - value1) * amount
  209. }
  210. static kFormat(value) {
  211. value = parseFloat(value)
  212. return value > 999 ? `${(value / 1000).toFixed(1)}k` : value
  213. }
  214. static fixAngle(angle) {
  215. return Math.atan2(Math.cos(angle), Math.sin(angle))
  216. }
  217. static getDistance(x1, y1, x2, y2) {
  218. if (x1 instanceof Object && y1 instanceof Object) {
  219. return Math.hypot(x1.y - y1.y, x1.x - y1.x)
  220. }
  221. return Math.hypot(y1 - y2, x1 - x2)
  222. }
  223. static getDirection(x1, y1, x2, y2) {
  224. if (x1 instanceof Object && y1 instanceof Object) {
  225. return Math.atan2(x1.y - y1.y, x1.x - y1.x)
  226. }
  227. return Math.atan2(y1 - y2, x1 - x2)
  228. }
  229. static getAngleDist(angleBetween, targetLookDir) {
  230. const difference = Math.abs(targetLookDir - angleBetween) % (Math.PI * 2)
  231. return (difference > Math.PI ? (Math.PI * 2) - difference : difference)
  232. }
  233. static lerpAngle(value1, value2, amount) {
  234. const difference = Math.abs(value2 - value1)
  235. if (difference > Math.PI) {
  236. if (value1 > value2) {
  237. value2 += Math.PI * 2
  238. } else {
  239. value1 += Math.PI * 2
  240. }
  241. }
  242. const value = value2 + ((value1 - value2) * amount)
  243. if (value >= 0 && value <= (Math.PI * 2)) return value
  244. return (value % (Math.PI * 2))
  245. }
  246. static createHook({
  247. property,
  248. proto = Object.prototype,
  249. setter,
  250. getter
  251. }) {
  252. const symbol = Symbol(property)
  253. Object.defineProperty(proto, property, {
  254. get() {
  255. typeof getter === 'function' && getter(this, this[symbol])
  256. return this[symbol]
  257. },
  258. set(value) {
  259. typeof setter === 'function' && setter(this, value)
  260. this[symbol] = value
  261. }
  262. })
  263. return symbol
  264. }
  265. }
  266. /* harmony default export */
  267. __webpack_exports__["default"] = (CowUtils);
  268. /***/
  269. }),
  270. /***/
  271. "./src/config.json":
  272. /*!*************************!*\
  273. !*** ./src/config.json ***!
  274. \*************************/
  275. /***/
  276. (function(module) {
  277. module.exports = JSON.parse('{"NAME":"Cow.JS","VERSION":"1.0.0","maxScreenWidth":1920,"maxScreenHeight":1080,"mapScale":14400,"riverWidth":724,"gatherAngle":1.208304866765305,"hitAngle":1.5707963267948966,"shieldAngle":1.0471975511965976,"gatherWiggle":10,"designations":{"plugins":{"AUTO_RECONECT":"auto-reconect","CHECK_PLACEMENT":"check-placement"},"packets":{"INIT_DATA":"A","DISCONNECT":"B","SETUP_GAME":"C","ADD_PLAYER":"D","REMOVE_PLAYER":"E","UPDATE_PLAYERS":"a","UPDATE_LEADERBOARD":"G","LOAD_GAME_OBJECT":"H","LOAD_AI":"I","ANIMATE_AI":"J","GATHER_ANIMATION":"K","WIGGLE_GAME_OBJECT":"L","SHOOT_TURRET":"M","UPDATE_PLAYER_VALUE":"N","UPDATE_HEALTH":"O","KILL_PLAYER":"P","KILL_OBJECT":"Q","KILL_OBJECTS":"R","UPDATE_ITEM_COUNTS":"S","UPDATE_AGE":"T","UPDATE_UPGRADES":"U","UPDATE_ITEMS":"V","ADD_PROJECTILE":"X","REMOVE_PROJECTILE":"Y","SERVER_SHUTDOWN_NOTICE":"Z","ADD_ALLIANCE":"g","DELETE_ALLIANCE":"1","ALLIANCE_NOTIFICATION":"2","SET_PLAYER_TEAM":"3","SET_ALLIANCE_PLAYERS":"4","UPDATE_STORE_ITEMS":"5","RECEIVE_CHAT":"6","UPDATE_MINIMAP":"7","SHOW_TEXT":"8","PING_MAP":"9","PING_SOCKET_RESPONSE":"0","ALLIANCE_JOIN_REQUEST":"P","KICK_FROM_CLAN":"Q","SEND_ALLIANCE_JOIN":"b","CREATE_ALLIANCE":"L","LEAVE_ALLIANCE":"N","STORE_EQUIP":"c","CHAT_MESSAGE":"6","RMD":"E","ATTACK_STATE":"d","MOVE_DIR":"a","MAP_PING":"S","AUTO_ATTACK":"K","SELECT_BUILD":"G","SPAWN":"M","SELECT_UPGRADE":"H","LOOK_DIR":"D","PING_SOCKET":"0"},"items":{"FOOD":0,"WALL":1,"SPIKE":2,"MILL":3,"TRAP":4,"TURRET":5}}}');
  278. /***/
  279. })
  280. /******/
  281. });
  282. /************************************************************************/
  283. /******/ // The module cache
  284. /******/
  285. var __webpack_module_cache__ = {};
  286. /******/
  287. /******/ // The require function
  288. /******/
  289. function __webpack_require__(moduleId) {
  290. /******/ // Check if module is in cache
  291. /******/
  292. var cachedModule = __webpack_module_cache__[moduleId];
  293. /******/
  294. if (cachedModule !== undefined) {
  295. /******/
  296. return cachedModule.exports;
  297. /******/
  298. }
  299. /******/ // Create a new module (and put it into the cache)
  300. /******/
  301. var module = __webpack_module_cache__[moduleId] = {
  302. /******/ // no module.id needed
  303. /******/ // no module.loaded needed
  304. /******/
  305. exports: {}
  306. /******/
  307. };
  308. /******/
  309. /******/ // Execute the module function
  310. /******/
  311. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  312. /******/
  313. /******/ // Return the exports of the module
  314. /******/
  315. return module.exports;
  316. /******/
  317. }
  318. /******/
  319. /************************************************************************/
  320. /******/
  321. /* webpack/runtime/define property getters */
  322. /******/
  323. ! function() {
  324. /******/ // define getter functions for harmony exports
  325. /******/
  326. __webpack_require__.d = function(exports, definition) {
  327. /******/
  328. for (var key in definition) {
  329. /******/
  330. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  331. /******/
  332. Object.defineProperty(exports, key, {
  333. enumerable: true,
  334. get: definition[key]
  335. });
  336. /******/
  337. }
  338. /******/
  339. }
  340. /******/
  341. };
  342. /******/
  343. }();
  344. /******/
  345. /******/
  346. /* webpack/runtime/hasOwnProperty shorthand */
  347. /******/
  348. ! function() {
  349. /******/
  350. __webpack_require__.o = function(obj, prop) {
  351. return Object.prototype.hasOwnProperty.call(obj, prop);
  352. }
  353. /******/
  354. }();
  355. /******/
  356. /******/
  357. /* webpack/runtime/make namespace object */
  358. /******/
  359. ! function() {
  360. /******/ // define __esModule on exports
  361. /******/
  362. __webpack_require__.r = function(exports) {
  363. /******/
  364. if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  365. /******/
  366. Object.defineProperty(exports, Symbol.toStringTag, {
  367. value: 'Module'
  368. });
  369. /******/
  370. }
  371. /******/
  372. Object.defineProperty(exports, '__esModule', {
  373. value: true
  374. });
  375. /******/
  376. };
  377. /******/
  378. }();
  379. /******/
  380. /************************************************************************/
  381. var __webpack_exports__ = {};
  382. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  383. ! function() {
  384. /*!**********************!*\
  385. !*** ./src/index.js ***!
  386. \**********************/
  387. __webpack_require__.r(__webpack_exports__);
  388. /* harmony import */
  389. var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( /*! ./constants.js */ "./src/constants.js");
  390. /* harmony import */
  391. var _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( /*! ./utils/CowUtils.js */ "./src/utils/CowUtils.js");
  392. const watermark = setInterval(() => {
  393. const linksContainer = document.getElementById("linksContainer2")
  394. if (!linksContainer) return
  395. const html = linksContainer.innerHTML
  396. linksContainer.innerHTML = html.replace(/(v\d\.\d\.\d)/gi, `$1 </a> | <a href="#" target="_blank" class="menuLink" style="color: #9f1a1a">${_constants_js__WEBPACK_IMPORTED_MODULE_0__.cow.config.NAME}</a>`)
  397. clearInterval(watermark)
  398. })
  399. setTimeout(() => clearInterval(watermark), 30e3)
  400. window.CowUtils = _utils_CowUtils_js__WEBPACK_IMPORTED_MODULE_1__["default"]
  401. window.Cow = _constants_js__WEBPACK_IMPORTED_MODULE_0__.cow
  402. }();
  403. /******/
  404. })();
  405. //# sourceMappingURL=bundle.js.map

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址