We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
現状、 むき に関する表現方法は 0~3 の数値、 Vector2、 Vector2 を返す関数が入り混じっている。これでは比較や計算がしづらいし、利用者にとって分かりやすくない
むき
Vector2
比較が容易にできる enum を実装し、0~3 の数値で表現されているコードを置き換える。また、 「Vector2 を返す関数」を関数の引数に与えるのをやめて、これも enum に置き換える ただし、内部的にも enum を持っておき、 forward などのプロパティは Vector2 インスタンスを生成して返す getter にした方が良いだろう
forward
import Vector2 from './math/vector2'; export enum Direction { Up = 'up', Right = 'right', Down = 'down', Left = 'left', RightHand = 'right hand', LeftHand = 'left hand', Behind = 'behind', Random = 'random', RandomDiagonal = 'random diagonal' } /** * * @param current 現在の向き(ベクトル) * @param dir */ export function getDirection() {} const m = -1; /** * 0 * 3 1 * 2 */ const _xRandom4 = [0, 1, 0, m]; const _yRandom4 = [m, 0, 1, 0]; export const random4 = () => { const n = (Math.random() * 4) >> 0; return new Vector2(_xRandom4[n], _yRandom4[n]); }; export const random = random4; /** * 0 1 2 * 7 3 * 6 5 4 */ const _xRandom8 = [m, 0, 1, 1, 1, 0, m, m]; const _yRandom8 = [m, m, m, 0, 1, 1, 1, 0]; export const random8 = () => { const n = (Math.random() * 8) >> 0; return new Vector2(_xRandom8[n], _yRandom8[n]); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
現状、
むき
に関する表現方法は 0~3 の数値、Vector2
、Vector2
を返す関数が入り混じっている。これでは比較や計算がしづらいし、利用者にとって分かりやすくない比較が容易にできる enum を実装し、0~3 の数値で表現されているコードを置き換える。また、 「
Vector2
を返す関数」を関数の引数に与えるのをやめて、これも enum に置き換えるただし、内部的にも enum を持っておき、
forward
などのプロパティはVector2
インスタンスを生成して返す getter にした方が良いだろうThe text was updated successfully, but these errors were encountered: