-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev-map' into feat-mvp
# Conflicts: # pnpm-lock.yaml
- Loading branch information
Showing
38 changed files
with
1,295 additions
and
101 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,60 +1,20 @@ | ||
import { loadMapData } from './utils'; | ||
import { useEffect, useState, useRef } from 'react'; | ||
import Map from './components/Map'; | ||
import { MapConfig } from './config'; | ||
import { BrowserRouter, Route, Routes } from 'react-router-dom'; | ||
import './App.scss'; | ||
import Home from './pages/home'; | ||
import Game from './pages/game'; | ||
|
||
export const App = () => { | ||
|
||
const [renderMapData, setRenderMapData] = useState([]); | ||
const [vertexCoordinate, setVertexCoordinate] = useState({ | ||
x: 0, | ||
y: 0 | ||
}); | ||
|
||
const mapDataRef = useRef([]); | ||
|
||
const onKeyDown = (e) => { | ||
const mapData = mapDataRef.current; | ||
if (mapData.length === 0 || e.keyCode < 37 || e.keyCode > 40) { | ||
return; | ||
} | ||
switch (e.keyCode) { | ||
case 37: | ||
vertexCoordinate.x = Math.max(0, vertexCoordinate.x - 1); | ||
break; | ||
case 38: | ||
vertexCoordinate.y = Math.max(0, vertexCoordinate.y - 1); | ||
break; | ||
case 39: | ||
vertexCoordinate.x = Math.min(mapData[0].length - 1 - MapConfig.visualWidth, vertexCoordinate.x + 1); | ||
break; | ||
case 40: | ||
vertexCoordinate.y = Math.min(mapData.length - 1 - MapConfig.visualHeight, vertexCoordinate.y + 1); | ||
break; | ||
} | ||
setVertexCoordinate({ | ||
...vertexCoordinate | ||
}); | ||
} | ||
|
||
useEffect(() => { | ||
loadMapData().then((csv) => { | ||
setRenderMapData(csv); | ||
mapDataRef.current = csv; | ||
}); | ||
|
||
}, []); | ||
|
||
return ( | ||
<div className="mi-app" onKeyDown={onKeyDown} tabIndex={0}> | ||
<Map | ||
width={MapConfig.visualWidth} | ||
height={MapConfig.visualHeight} | ||
players={[]} | ||
data={renderMapData} | ||
vertexCoordinate={vertexCoordinate} | ||
/> | ||
<div className="mi-app"> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/"> | ||
<Route index element={<Home />} /> | ||
<Route path="game" element={<Game />} /> | ||
</Route> | ||
</Routes> | ||
</BrowserRouter> | ||
</div> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,8 +1,27 @@ | ||
$avatars: 'elephant', 'hippo', 'panda', 'penguin', 'rabbit', 'giraffe', 'monkey', 'parrot', 'pig', 'snake'; | ||
$avatarsPath: './assets/avatar/'; | ||
|
||
@for $i from 1 through 10 { | ||
.avatar-#{nth($avatars, $i)} { | ||
background-image: url("#{$avatarsPath}#{nth($avatars, $i)}.png"); | ||
} | ||
} | ||
|
||
.avatar-box { | ||
background-size: contain; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
background: #dfc380; | ||
} | ||
|
||
ul, li, ol { | ||
list-style: none; | ||
} |
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,57 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Button } from 'antd'; | ||
import './styles.scss'; | ||
|
||
const Avatars = ['elephant', 'hippo', 'panda', 'penguin', 'rabbit', 'giraffe', 'monkey', 'parrot', 'pig', 'snake']; | ||
|
||
interface IProps { | ||
onChange: (avatar: string | null) => void; | ||
} | ||
|
||
const AvatarSelector = (props: IProps) => { | ||
|
||
const [avatarsVisible, setAvatarsVisible] = useState(false); | ||
const [avatar, setAvatar] = useState<null | string>(null); | ||
|
||
useEffect(() => { | ||
props.onChange(avatar); | ||
}, [avatar]) | ||
|
||
const toggleAvatars = () => { | ||
setAvatarsVisible(!avatarsVisible); | ||
} | ||
|
||
return ( | ||
<div className="mi-c-avatars-wrap"> | ||
{ | ||
avatar ? | ||
<div className={`avatar-selected avatar-box avatar-${avatar}`} onClick={toggleAvatars} /> | ||
: | ||
<Button onClick={toggleAvatars}>Choose avatar</Button> | ||
} | ||
{ | ||
avatarsVisible && ( | ||
<ul className="avatars"> | ||
{ | ||
Avatars.map((avatar) => { | ||
return ( | ||
<li | ||
key={avatar} | ||
className={`avatar-item avatar-box avatar-${avatar}`} | ||
onClick={() => { | ||
setAvatar(avatar); | ||
setAvatarsVisible(false); | ||
}} | ||
/> | ||
) | ||
}) | ||
} | ||
</ul> | ||
) | ||
} | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
export default AvatarSelector; |
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,25 @@ | ||
|
||
.mi-c-avatars-wrap { | ||
position: relative; | ||
width: 100px; | ||
height: 100px; | ||
|
||
.avatars { | ||
position: absolute; | ||
top: 100%; | ||
display: grid; | ||
width: 400px; | ||
grid-template-columns: repeat(5, 1fr); | ||
background: #fff; | ||
|
||
.avatar-item { | ||
height: 80px; | ||
} | ||
} | ||
|
||
.avatar-selected { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
.mi-map-content { | ||
border: 1px solid; | ||
width: $cellSize * 24; | ||
font-size: 0; | ||
} | ||
|
||
.mi-map-row { | ||
|
Oops, something went wrong.