画面90度回転
by
cutfloss
4 hours ago [2026/05/07 21:37:28]
ゲーム画面を90度回転させるぞ 配信とかでも見えやすくなるはずだっ
@@ -4,73 +4,60 @@
* @private
*/
javascript:(function(){
- /* 1. 既存のフックがあれば解除(リロードを推奨しますが、簡易的な安全策) */
- if(window._rotateActive) return alert('既に適用済みです。戻すにはリロードしてください。');
- window._rotateActive = true;
-
const container = document.getElementById('game-container');
const canvas = document.getElementById('gameCanvas');
if(!container || !canvas) return;
- /* 2. 画面をブラウザいっぱいに広げる(比率維持) */
+ /* 1. コンテナを全画面 FlexBox 化(これで絶対にど真ん中へ) */
Object.assign(container.style, {
position: 'fixed', top: '0', left: '0', width: '100vw', height: '100vh',
- zIndex: '9999', backgroundColor: '#000', maxWidth: 'none', maxHeight: 'none'
+ zIndex: '9999', backgroundColor: '#000', maxWidth: 'none', maxHeight: 'none',
+ display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden'
});
- /* 3. 本来の描画コンテキストを拡張 */
- const ctx = canvas.getContext('2d');
- const originalSetTransform = ctx.setTransform;
+ /* 2. キャンバスのサイズと回転の設定 */
+ /* 画面の短い方の辺に合わせて、はみ出さない最大倍率を計算 */
+ const scale = Math.min(window.innerWidth / canvas.height, window.innerHeight / canvas.width) * 0.95;
- /* 描画の全命令を90度回転させる「魔法のレイヤー」を被せる */
- const applyRotation = (c) => {
- const scale = Math.min(window.innerWidth / canvas.height, window.innerHeight / canvas.width);
- c.setTransform(0, scale, -scale, 0, window.innerWidth / 2, window.innerHeight / 2);
- };
-
- /* 4. アニメーションループに割り込み、毎フレーム画面を回す */
- const originalLoop = window.loop;
- window.loop = function() {
- /* 画面を全画面にリサイズ */
- if(canvas.width !== window.innerWidth || canvas.height !== window.innerHeight) {
- canvas.width = window.innerWidth;
- canvas.height = window.innerHeight;
- }
-
- ctx.save();
- /* ここで描画全体を90度回転+スケーリング */
- const scale = Math.min(window.innerWidth / 1200, window.innerHeight / 800); // 基準サイズ
- ctx.translate(window.innerWidth / 2, window.innerHeight / 2);
- ctx.rotate(Math.PI / 2);
- ctx.scale(1.2, 1.2); // 司令官、ここの数値で拡大率を微調整できます
- ctx.translate(-600, -400); // 中心を戻す(数値は環境に依存)
-
- originalLoop.apply(this, arguments);
- ctx.restore();
- };
+ canvas.style.transformOrigin = 'center center';
+ canvas.style.transform = `rotate(90deg) scale(${scale})`;
+ canvas.style.position = 'static'; /* Flexboxで制御するため */
+
+ /* 3. 名前と絵文字の「首折れ」防止フック(安全版) */
+ if (!window._originalFillText) {
+ window._originalFillText = CanvasRenderingContext2D.prototype.fillText;
+ CanvasRenderingContext2D.prototype.fillText = function(text, x, y, maxWidth) {
+ /* プレイヤー名や絵文字の描画位置(中心付近)を狙い撃ち */
+ /* スコアの % やタイマーの : は除外 */
+ if (Math.abs(x) < 40 && Math.abs(y) < 40 && !text.includes('%') && !text.includes(':')) {
+ this.save();
+ this.rotate(-Math.PI / 2);
+ window._originalFillText.call(this, text, -y, x, maxWidth);
+ this.restore();
+ } else {
+ window._originalFillText.apply(this, arguments);
+ }
+ };
+ }
- /* 5. 操作方向の完全補正 */
- if (typeof sendInput === 'function') {
- const _origSend = window.sendInput;
+ /* 4. 操作方向の90度回転補正(右が下、上が右) */
+ if (typeof sendInput === 'function' && !window._inputHooked) {
+ window._inputHooked = true;
+ const _origSendInput = window.sendInput;
window.sendInput = function() {
const dx = inputState.dx;
const dy = inputState.dy;
- /* スティックの「右」が「下」に、「上」が「右」になるよう入れ替え */
inputState.dx = -dy;
inputState.dy = dx;
- _origSend.apply(this, arguments);
+ _origSendInput.apply(this, arguments);
inputState.dx = dx;
inputState.dy = dy;
};
}
- /* 6. ブーストボタンを「物理キー」で確実に叩く */
- window.addEventListener('keydown', e => {
- if(e.code === 'Space') {
- e.preventDefault();
- if(typeof triggerBoost === 'function') triggerBoost();
- }
- }, { capture: true });
-
- alert('【全画面・横回転パッチ】\n・フリーズ対策完了\n・アスペクト比固定\n・スペースキーでブースト可能');
+ /* 5. ゲーム側の強制リサイズ(resize関数)を無効化して暴走を止める */
+ window.removeEventListener('resize', window.resize);
+
+ document.body.style.overflow = 'hidden';
+ alert('【究極・横画面パッチ】\n・ど真ん中配置完了!\n・名前の向きを水平に固定\n・スペースキーでブースト可能');
})();
/*
* @title 画面90度回転
* @description ゲーム画面を90度回転させるぞ 配信とかでも見えやすくなるはずだっ
* @private
*/
javascript:(function(){
const container = document.getElementById('game-container');
const canvas = document.getElementById('gameCanvas');
if(!container || !canvas) return;
/* 1. コンテナを全画面 FlexBox 化(これで絶対にど真ん中へ) */
Object.assign(container.style, {
position: 'fixed', top: '0', left: '0', width: '100vw', height: '100vh',
zIndex: '9999', backgroundColor: '#000', maxWidth: 'none', maxHeight: 'none',
display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden'
});
/* 2. キャンバスのサイズと回転の設定 */
/* 画面の短い方の辺に合わせて、はみ出さない最大倍率を計算 */
const scale = Math.min(window.innerWidth / canvas.height, window.innerHeight / canvas.width) * 0.95;
canvas.style.transformOrigin = 'center center';
canvas.style.transform = `rotate(90deg) scale(${scale})`;
canvas.style.position = 'static'; /* Flexboxで制御するため */
/* 3. 名前と絵文字の「首折れ」防止フック(安全版) */
if (!window._originalFillText) {
window._originalFillText = CanvasRenderingContext2D.prototype.fillText;
CanvasRenderingContext2D.prototype.fillText = function(text, x, y, maxWidth) {
/* プレイヤー名や絵文字の描画位置(中心付近)を狙い撃ち */
/* スコアの % やタイマーの : は除外 */
if (Math.abs(x) < 40 && Math.abs(y) < 40 && !text.includes('%') && !text.includes(':')) {
this.save();
this.rotate(-Math.PI / 2);
window._originalFillText.call(this, text, -y, x, maxWidth);
this.restore();
} else {
window._originalFillText.apply(this, arguments);
}
};
}
/* 4. 操作方向の90度回転補正(右が下、上が右) */
if (typeof sendInput === 'function' && !window._inputHooked) {
window._inputHooked = true;
const _origSendInput = window.sendInput;
window.sendInput = function() {
const dx = inputState.dx;
const dy = inputState.dy;
inputState.dx = -dy;
inputState.dy = dx;
_origSendInput.apply(this, arguments);
inputState.dx = dx;
inputState.dy = dy;
};
}
/* 5. ゲーム側の強制リサイズ(resize関数)を無効化して暴走を止める */
window.removeEventListener('resize', window.resize);
document.body.style.overflow = 'hidden';
alert('【究極・横画面パッチ】\n・ど真ん中配置完了!\n・名前の向きを水平に固定\n・スペースキーでブースト可能');
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。