Add piece mirror; fix move hints on rotate.
This commit is contained in:
parent
6b596cc766
commit
c9df933bfb
@ -394,6 +394,9 @@ const INTERFACE = {
|
||||
if(!is_hover) { draw.hints(piece); }
|
||||
|
||||
// Draw piece icon
|
||||
if(INTERFACE_DATA.mirror && (piece.player ^ (INTERFACE_DATA.player & 1) ^ INTERFACE_DATA.rotate) != 0) {
|
||||
ctx.rotate(Math.PI);
|
||||
}
|
||||
if(piece.promoted) { ctx.drawImage(GAME_ASSET.Image.Promote, -icon_radius, -icon_radius, icon_radius * 2., icon_radius * 2.); }
|
||||
ctx.drawImage(GAME_ASSET.Image.Piece[piece.piece][piece.player], -icon_radius, -icon_radius, icon_radius * 2., icon_radius * 2.);
|
||||
|
||||
@ -558,7 +561,7 @@ const INTERFACE = {
|
||||
ctx.fillText(GAME_DATA.turn, width - gui_margin, gui_margin);
|
||||
|
||||
// Game state message
|
||||
let message = null;
|
||||
let message = "Info";
|
||||
ctx.fillStyle = INTERFACE.Color.Text;
|
||||
|
||||
if(GAME_DATA.state.check) {
|
||||
@ -593,6 +596,9 @@ const INTERFACE = {
|
||||
|
||||
hints(piece) {
|
||||
let movement = piece.moves();
|
||||
if((INTERFACE_DATA.player & 1) ^ INTERFACE_DATA.rotate) {
|
||||
movement = movement.rotate();
|
||||
}
|
||||
let moves = movement.direction;
|
||||
|
||||
for(let mask = BITWISE.lsb(moves); moves > 0; mask = BITWISE.lsb(moves)) {
|
||||
@ -703,6 +709,7 @@ const INTERFACE = {
|
||||
|
||||
player: player,
|
||||
rotate: 0,
|
||||
mirror: false,
|
||||
|
||||
hover: null,
|
||||
select: null,
|
||||
@ -805,9 +812,14 @@ const INTERFACE = {
|
||||
},
|
||||
|
||||
rotate() {
|
||||
INTERFACE_DATA.rotate = +(!INTERFACE_DATA.rotate);
|
||||
INTERFACE_DATA.rotate ^= 1;
|
||||
INTERFACE.draw();
|
||||
}
|
||||
},
|
||||
|
||||
mirror() {
|
||||
INTERFACE_DATA.mirror = !INTERFACE_DATA.mirror;
|
||||
INTERFACE.draw();
|
||||
},
|
||||
};
|
||||
|
||||
INTERFACE.Radius = 2.0 / Math.sqrt(3.0);
|
||||
|
@ -506,6 +506,7 @@ const SCENES = {
|
||||
|
||||
UI.nav([
|
||||
UI.button("Rotate", () => { INTERFACE.rotate(); }),
|
||||
UI.button("Mirror", () => { INTERFACE.mirror(); }),
|
||||
], buttons_bottom);
|
||||
|
||||
let canvas = document.createElement("canvas");
|
||||
@ -546,6 +547,7 @@ const SCENES = {
|
||||
|
||||
UI.nav([
|
||||
UI.button("Rotate", () => { INTERFACE.rotate(); }),
|
||||
UI.button("Mirror", () => { INTERFACE.mirror(); }),
|
||||
], buttons_bottom);
|
||||
|
||||
let canvas = document.createElement("canvas");
|
||||
|
Loading…
x
Reference in New Issue
Block a user