From 4ca74f3f47b7c8e754f4252b2f41c66e4ae6cccc Mon Sep 17 00:00:00 2001 From: aronmal Date: Sat, 7 Jan 2023 13:53:58 +0100 Subject: [PATCH] Adapt to assets --- leaky-ships/components/Gamefield.tsx | 11 +++++------ leaky-ships/components/Ships.tsx | 27 ++++++++++++++++----------- leaky-ships/styles/App.scss | 28 +++++++++++----------------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/leaky-ships/components/Gamefield.tsx b/leaky-ships/components/Gamefield.tsx index a1110d8..8c3d328 100644 --- a/leaky-ships/components/Gamefield.tsx +++ b/leaky-ships/components/Gamefield.tsx @@ -1,5 +1,3 @@ -import { faCrosshairs } from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { CSSProperties, useEffect, useReducer, useState } from 'react'; import Bluetooth from './Bluetooth'; import BorderTiles from './BorderTiles'; @@ -21,13 +19,14 @@ function Gamefield() { useEffect(() => { const { newX, newY, shouldShow, appearOK, eventReady, show, x, y } = targetPreview; const positionChange = !(x === newX && y === newY); + const alreadyTargeting = target.show && target.x === targetPreview.newX && target.y === targetPreview.newY // if not ready or no new position if (!eventReady || (!positionChange && show)) return; if (show) { // hide preview to change position when hidden setTargetPreview(e => ({ ...e, appearOK: false, eventReady: false, show: false })); - } else if (shouldShow && appearOK && !isHit(hits, newX, newY).length) { + } else if (shouldShow && appearOK && !isHit(hits, newX, newY).length && !alreadyTargeting) { // BUT only appear again if it's supposed to (in case the mouse left over the edge) and () setTargetPreview(e => ({ ...e, appearOK: false, eventReady: false, show: true, x: newX, y: newY })); } @@ -102,10 +101,10 @@ function Gamefield() { {/* Fog images */} {/* */}
- + Crosshair
-
- +
+ Crosshair
{/*

diff --git a/leaky-ships/components/Ships.tsx b/leaky-ships/components/Ships.tsx index 11513b2..9eb2f58 100644 --- a/leaky-ships/components/Ships.tsx +++ b/leaky-ships/components/Ships.tsx @@ -1,19 +1,24 @@ -import Image from 'next/image'; import { CSSProperties } from 'react' function Ships() { - let shipIndexes: number[] = []; - - for (let i = 1; i <= 6; i++) { - shipIndexes.push(i); - } + let shipIndexes = [ + { size: 2, index: null }, + { size: 3, index: 1 }, + { size: 3, index: 2 }, + { size: 3, index: 3 }, + { size: 4, index: 1 }, + { size: 4, index: 2 } + ]; return <> - {shipIndexes.map(i => -

- {`${i}.svg`}/ -
- )} + {shipIndexes.map(({ size, index }, i) => { + const filename = `/assets/ship_blue_${size}x${index ? '_' + index : ''}.gif` + return ( +
+ {filename} +
+ ) + })} } diff --git a/leaky-ships/styles/App.scss b/leaky-ships/styles/App.scss index 8aea763..7b0ba22 100644 --- a/leaky-ships/styles/App.scss +++ b/leaky-ships/styles/App.scss @@ -52,7 +52,7 @@ body { #game-frame { // border: 1px solid orange; // position: relative; - $height: 945px; + $height: 864px; $width: $height; height: $height; width: $width; @@ -113,31 +113,15 @@ body { // object-fit: cover; } - &.s1 { - grid-column: 3 / 7; - } - &.s2 { grid-column: 3 / 5; } &.s3 { grid-column: 3 / 6; - - img { - margin-top: -2%; - } } &.s4 { - grid-column: 3 / 6; - } - - &.s5 { - grid-column: 3 / 6; - } - - &.s6 { grid-column: 3 / 7; } } @@ -174,6 +158,11 @@ body { &.target { color: red; opacity: 0; + + img { + height: inherit; + width: inherit; + } } &.target-preview { @@ -181,6 +170,11 @@ body { opacity: 0; @include transition(.2s); + img { + height: inherit; + width: inherit; + filter: sepia() saturate(2000%) hue-rotate(20deg) + } } &.show {