-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: n,e,s,w punch via spacebar * dist * diagonals * connect punch to socket
- Loading branch information
1 parent
338d0e7
commit 1949760
Showing
7 changed files
with
128 additions
and
22 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,9 @@ | |
.player { | ||
position: absolute; | ||
} | ||
|
||
.punch-line { | ||
width: 24px; | ||
height: 2px; | ||
position: absolute; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useEffect } from 'react'; | ||
|
||
interface Props { | ||
punchDirection: string; | ||
posX: number; | ||
posY: number; | ||
color: string; | ||
} | ||
|
||
function PunchLine({ punchDirection, posX, posY, color }: Props) { | ||
useEffect(() => { | ||
console.log({ punchDirection }); | ||
}, [punchDirection]); | ||
|
||
const punchDirectionMap = { | ||
n: { top: posY - 10, left: posX }, | ||
e: { top: posY + 11, left: posX + 21, transform: 'rotate(90deg)' }, | ||
s: { top: posY + 32, left: posX }, | ||
w: { top: posY + 11, left: posX - 21, transform: 'rotate(90deg)' }, | ||
ne: { top: posY - 5, left: posX + 16, transform: 'rotate(45deg)' }, | ||
en: { top: posY - 5, left: posX + 16, transform: 'rotate(45deg)' }, | ||
se: { top: posY + 28, left: posX + 17, transform: 'rotate(135deg)' }, | ||
es: { top: posY + 28, left: posX + 17, transform: 'rotate(135deg)' }, | ||
sw: { top: posY + 28, left: posX - 16, transform: 'rotate(45deg)' }, | ||
ws: { top: posY + 28, left: posX - 16, transform: 'rotate(45deg)' }, | ||
nw: { top: posY - 5, left: posX - 16, transform: 'rotate(135deg)' }, | ||
wn: { top: posY - 5, left: posX - 16, transform: 'rotate(135deg)' }, | ||
}; | ||
|
||
return ( | ||
<div | ||
className='punch-line' | ||
style={{ | ||
...punchDirectionMap[punchDirection as keyof typeof punchDirectionMap], | ||
backgroundColor: color, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export default PunchLine; |