- 累计送礼:
- 0 个
- 累计收礼:
- 1 个
TA的每日心情 | 开心 2026-7-12 04:10 |
|---|
签到天数: 209 天 连续签到: 2 天 [LV.7]常住居民III

管理员
  
- VIP
- 7
- 卡币
- 25563
- OK点
- 16
- 推广点
- 0
- 同能卷
- 50
- 积分
- 32235


|
Hello i remade one of my script from ace a SpaceShip minigame, you control a spaceship with up and down(or mouse) throught a tunnel
Spoiler//=============================================================================// SpaceShipMinigame.js// Free for commercial use//=============================================================================/*:* @plugindesc SpaceShipMinigame v.1.0* @author Zarby** @param Score Variable ID* @desc Score is stored in this variable when gameover* @default 10** @param Lives* @desc How many live the player have* @default 3** @param HoleSize* @desc Define the size of the hole for the spaceship* @default 10** @param HoleRandom* @desc more higher this value is more it create straight tunnel* @default 2** @param ScrollSpeed* @desc speed of the view* @default 4*/function Scene_SpaceMinigame() { this.initialize.apply(this, arguments);}Scene_SpaceMinigame.prototype = Object.create(Scene_Base.prototype);Scene_SpaceMinigame.prototype.constructor = Scene_SpaceMinigame;Scene_SpaceMinigame.prototype.initialize = function () { Scene_Base.prototype.initialize.call(this);};Scene_SpaceMinigame.prototype.create = function () { Scene_Base.prototype.create.call(this); //#--------------------------------------------------------------------------- //# Images Generation uri, you can change images here by using a image to uri //#--------------------------------------------------------------------------- //Font Bitmap Data 256x40; this.fontdata = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAoCAYAAAAR+iSJAAAGzElEQVR4nO1a27YiOwj02/1xz8s4E2koqoCofezwMKa5FQWm415ze9zeKM/1zpyXXHJJKO9N92fd7/eH9/w6HC75CVFnnbG3C+kWGy6RfR7s7\ /d7/EU26+8hoPpOktVtzDdL1LOsRrJ/ZT3KqeRQ/bv4h/tyv9+PL0LSL4252hqdteEIsMnR3gMa2ENfoC8TNaE/i4AhCHlcVtQ/1z/QwxkIsL4MabU31q6IH/GD8mb68mxF/qDezMcHnzXPSeCt8MBYxMZAJxhFYGbT0a+sHRk82nxKyH4dDmRPl8Vj9hE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AQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3woeEQsOzGIB3AAAAB1pVFh0Q29tbWVudAAAAAAAQ3J\ lYXRlZCB3aXRoIEdJTVBkLmUHAAABKUlEQVQ4y6WTPW7CQBCFv/VsQ+NbpEOpIrmgCQdIwzUooM0JtoXC13DjA5iGwhJVRJdbWEI0NpNis2YdQHLESivNz87Tm/e0RouaZ44BFECL2phF1sdjARKAKgezyHS7vsb/YqB1yu7QMF/Cdu0bq804JgnA7tDw/pZS5X\ 7w9cUDjWGSaFGb+dInASTkY9ZJQrA7NAOQ1Qa+vkdoEGw0i0y1Tq+NrHk4FGuThOGYRaAP4ERwIgCcugun7nKzljoRdSL660h/qxwFtLRWAd2fW92fWz11F/+2qLF/6cUs4uNEmE0s+3M7qPcAU2NwIsyX3c3wUbXvzyb2PsBH65FLaznq0LnPrsOJMDWG0tr+b\ VB0oEOsR3zjepV7rQAd2PjIqnv9/gM++51/APquqcGRJtvwAAAAAElFTkSuQmCC";};Scene_SpaceMinigame.prototype.start = function () { Scene_Base.prototype.start.call(this); var vparameters = PluginManager.parameters('SpaceShipMinigame'); this.lives = Number(vparameters['Lives'] || 3); this.sendvar = Number(vparameters['Score Variable ID'] || 10); this.holesize = Number(vparameters['HoleSize'] || 10); this.holerand = Number(vparameters['HoleRandom'] || 2); this.scrollspeed = Number(vparameters['ScrollSpeed'] || 4); this.startFadeIn(this.fadeSpeed(), false); this.screenbit = new Bitmap(424, 312); this.score = 0; var text = this.score.toString() + ' '; var xp = 0; var yp = 0; this.mapdir = 1; this.mapi = []; this.lastdir = 0; this.gameover = false; this.scoretimer = 0; for (i = 0; i < 54; i++) { this.mapi = 16; } var fbit = Bitmap.load(this.fontdata); var scorebit = new Bitmap(text.length * 8, 16); fbit.addLoadListener(function () { for (i = 0; i < text.length; i++) { for (j = 33; j < 122; j++) { var c = text.charCodeAt(i); if (c == j) { var x = (j - 33); var y = Math.floor(((j - 33) / 32)); x = x - (y * 32); scorebit.blt(fbit, x * 8, y * 13, 8, 13, xp + (i * 8), yp); break; } } } }); this.screensprite = new Sprite(this.screenbit); this.screensprite.scale = new Point(2, 2); this.addChild(this.screensprite); this.scoresprite = new Sprite(scorebit); this.scoresprite.x = (816 / 2) - (text.length * 8)/2; this.scoresprite.y = 4; this.addChild(this.scoresprite); this.shipsprite = new Sprite(Bitmap.load(this.spaceshipdata)) this.shipsprite.scale = new Point(2, 2); this.shipsprite.x = 8; this.shipsprite.y = 312; this.addChild(this.shipsprite);};function padzero(n, p, c) { var pad_char = typeof c !== 'undefined' ? c : '0'; var pad = new Array(1 + p).join(pad_char); return (pad + n).slice(-pad.length);}Scene_SpaceMinigame.prototype.update = function () { var active = this.isActive(); $gameTimer.update(active); $gameScreen.update(); if (this.gameover == false) { this.scoretimer += 1; if (this.scoretimer >= 10) { this.score += 1; this.scoretimer = 0; } this.screensprite.x -= this.scrollspeed; if (this.screensprite.x <= -16) { var cdir = Math.floor(Math.random() * this.holerand) this.mapdir = Math.floor(Math.random() * 3); this.mapi = this.mapi.slice(1, this.mapi.length); if (cdir == 1) { this.lastdir = this.mapdir; if (this.mapi[this.mapi.length - 1] <= 3) { this.mapi.push(this.mapi[this.mapi.length - 1] + 1) } else if (this.mapi[this.mapi.length - 1] >= 30) { this.mapi.push(this.mapi[this.mapi.length - 1] - 1) } else if (this.mapdir == 0) { this.mapi.push(this.mapi[this.mapi.length - 1]); } else if (this.mapdir == 1) { this.mapi.push(this.mapi[this.mapi.length - 1] - 1); } else if (this.mapdir == 2) { this.mapi.push(this.mapi[this.mapi.length - 1] + 1); } } else { if (this.mapi[this.mapi.length - 1] <= 3) { this.mapi.push(this.mapi[this.mapi.length - 1] + 1) } else if (this.mapi[this.mapi.length - 1] >= 21) { this.mapi.push(this.mapi[this.mapi.length - 1] - 1) } else if (this.lastdir == 0) { this.mapi.push(this.mapi[this.mapi.length - 1]); } else if (this.lastdir == 1) { this.mapi.push(this.mapi[this.mapi.length - 1] - 1); } else if (this.lastdir == 2) { this.mapi.push(this.mapi[this.mapi.length - 1] + 1); } } this.screensprite.x = 0; } if (Input.isPressed('up')) { this.shipsprite.y -= 3; } if (Input.isPressed('down')) { this.shipsprite.y += 3; } if (TouchInput.isPressed()) { if (TouchInput.y > this.shipsprite.y) { this.shipsprite.y += 3; } if (TouchInput.y < this.shipsprite.y) { this.shipsprite.y -= 3; } } //check collision if (this.shipsprite.y + 4 <= this.mapi[1] * 16) { this.gameover = true; //collision } if (this.shipsprite.y + 32 >= this.mapi[1] * 16 + (this.holesize * 16)) { //collision this.gameover = true; } var text = padzero(this.score, 6, '0') + ' x' + padzero(this.lives, 2, '0'); var fbit = Bitmap.load(this.fontdata); var scorebit = this.scoresprite.bitmap; fbit.addLoadListener(function () { scorebit.fillAll('#000000'); for (i = 0; i < text.length; i++) { for (j = 33; j < 122; j++) { var c = text.charCodeAt(i); if (c == j) { var x = (j - 33); var y = Math.floor(((j - 33) / 32)); x = x - (y * 32); scorebit.blt(fbit, x * 8, y * 13, 8, 13, 0 + (i * 8), 0); break; } } } }); this.screenbit.fillAll('#8B4513'); for (i = 0; i < 54; i++) { this.screenbit.fillRect(i * 8, this.mapi * 8, 8, this.holesize * 8, '#3C1E05') } } else { if (Input.isTriggered('cancel')) { SceneManager.goto(Scene_Map); } if (Input.isTriggered('ok') || TouchInput.isTriggered()) { if (this.lives > 1) { this.scoretimer = 0; for (i = 0; i < 54; i++) { this.mapi = 16; } this.shipsprite.y = 312; this.gameover = false; this.lives -= 1; } else { $gameVariables.setValue(this.sendvar, this.score); SceneManager.goto(Scene_Map); } } } Scene_Base.prototype.update.call(this);};
How to use it just call a script from an event :
SceneManager.goto(Scene_SpaceMinigame)Preview :
本贴来自国际rpgmaker官方论坛作者:Zarby处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址: https://forums.rpgmakerweb.com/threads/spaceship-minigame-plugin.48568/ |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|