Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/694f5245-1110-800b-b182-7c2accd50046
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: 哎呀又被「座標系鬼打牆」抓回去一次🤣🫠 === 哎呀又被「座標系鬼打牆」抓回去一次🤣🫠 但這其實是好消息:代表它最近那次改動又把「world / screen / iso投影」混在一起了——左右反了跟房間 AREA 壞掉幾乎永遠是同一種病灶:用錯座標空間 or 反向套了兩次。 我直接給你一包「回歸修正 Patch 2.1」:專殺這兩個回歸 bug(Facing 反向+Exit/Room bounds 壞),而且會加上 Debug 顯示,避免下次又默默壞掉 😈🛠️ ==== 把下面整段貼給 GEMINI: ==== <syntaxhighlight lang="text">PATCH 2.1 / Regression Fix: Facing reversed + Room AREA broken (Isometric) Goal: * Prevent recurring regressions by enforcing a strict rule: ALL gameplay logic uses WORLD or TILE coordinates only. Screen/isometric projection is rendering-only. A) Fix facing reversal (mouse aim) * Do NOT decide facing using mouseX screen coords directly. * Convert mouse screen position to aimWorld (inverse isometric projection), then: faceLeft if (aimWorld.x < playerWorld.x) faceRight otherwise * Inverse iso (with camera offset): sx = mouseX - camX sy = mouseY - camY worldX = ( sy/(tileH/2) + sx/(tileW/2) ) / 2 worldY = ( sy/(tileH/2) - sx/(tileW/2) ) / 2 * Ensure sprite mirroring is applied in ONE place only (avoid double-flip): e.g., drawImage with scaleX = -1 OR choose mirrored frame, not both. Debug (F2): * Show: playerWorld.x, playerWorld.y * Show: aimWorld.x, aimWorld.y * Show: facing = LEFT/RIGHT Acceptance: * Aim mouse left of player => mech faces left (always). * Aim mouse right of player => mech faces right (always). B) Fix room AREA / exit trigger (after isometric changes) * Exit triggers MUST be computed in WORLD/TILE coords, never screen coords. * Best practice: define room size in TILE grid: roomTilesW, roomTilesH playerTile = worldToTile(playerWorld) * Exit margins in tiles (e.g. 1~2 tiles): if playerTile.x <= 0 + margin => LEFT exit if playerTile.x >= roomTilesW-1 - margin => RIGHT exit if playerTile.y <= 0 + margin => UP exit if playerTile.y >= roomTilesH-1 - margin => DOWN exit * Only render exit indicators for exits that exist in the room graph. Debug (F1): * Show current room coords (rx, ry) * Show playerTile (tx, ty) * Show roomTilesW/H and margin * Print when trigger fires: "ENTER EXIT: LEFT/RIGHT/UP/DOWN" Acceptance: * Walking to an exit edge triggers transition reliably within 3 seconds. * Indicators match actual exits (no fake arrows). C) Regression guardrails (important) * Never mix screenX/screenY into collision, exit, or facing logic. * Keep a single source of truth: playerWorld, enemyWorld, bulletWorld, roomGraph in world/tile space. </syntaxhighlight> ==== - Facing 反:就是它拿 mouseX(螢幕)去跟 playerX(世界)比,或 inverse 公式少了 cam offset / 係數,或 mirror 做了兩次 ==== * AREA 壞:就是 exit 判定還在用「菱形畫面邊緣」當作碰撞邊界,而不是用「tile/world」當邏輯邊界 ➡️ 把 exit 改成「tile grid boundary」會超穩:不管你渲染怎麼歪、投影怎麼改,它都不會壞。 ==== 你測試只要做兩個動作就行: ==== # 站著不動,滑鼠繞主角一圈 → 面向要跟著左右正確切 # 往任意邊緣一直走 → F1 必須跳出 “ENTER EXIT: …” 而且房間座標變化 如果這兩個過了,後面貼圖、敵人 sprite、特效就能安心堆上去🔥 你如果想更狠一點,我也可以再加一句「如果 F1/F2 debug 沒開就不算完成」——這種回歸 bug 只有用 debug 鐵欄杆才能永遠關住 🤣🧱
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)