Created
October 2, 2024 21:17
-
-
Save naosim/12a34c696b072003f87e185a93472ead to your computer and use it in GitHub Desktop.
【microStudio】裏技の実装(コナミコマンド)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CheatCommand { | |
cheatCommandDef = "uuddlrlrba" // コナミコマンド | |
initKeys; | |
inputKeys; | |
isCheatCompleted = false; | |
init() { | |
this.initKeys = this.cheatCommandDef.split("").map(v => "-").join(""); | |
this.inputKeys = this.initKeys; | |
} | |
update() { | |
this.isCheatCompleted = false; | |
var isKeyRelesed = false; | |
if(gamepad.release.UP || keyboard.release.E) { | |
this.inputKeys += "u" | |
isKeyRelesed = true; | |
} | |
if(gamepad.release.DOWN || keyboard.release.D) { | |
this.inputKeys += "d"; | |
isKeyRelesed = true; | |
} | |
if(gamepad.release.LEFT || keyboard.release.S) { | |
this.inputKeys += "l"; | |
isKeyRelesed = true; | |
} | |
if(gamepad.release.RIGHT || keyboard.release.F) { | |
this.inputKeys += "r"; | |
isKeyRelesed = true; | |
} | |
if(gamepad.release.A || keyboard.release.SPACE) { | |
this.inputKeys += "a"; | |
isKeyRelesed = true; | |
} | |
if(gamepad.release.B || keyboard.release.ENTER) { | |
this.inputKeys += "b"; | |
isKeyRelesed = true; | |
} | |
if(isKeyRelesed) { | |
this.inputKeys = this.inputKeys.slice(-this.cheatCommandDef.length); | |
print(this.inputKeys); | |
if(this.inputKeys == this.cheatCommandDef) { | |
this.isCheatCompleted = true; | |
this.inputKeys = this.initKeys; | |
} | |
} | |
} | |
draw() { /* none */ } | |
} | |
// 以下、実行 | |
var cheatCommand = new CheatCommand(); | |
init = function() { | |
cheatCommand.init(); | |
} | |
update = function() { | |
cheatCommand.update(); | |
if(cheatCommand.isCheatCompleted) { | |
print("cheat!!"); | |
} | |
} | |
draw = function() { | |
cheatCommand.draw(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment