profile
Why?에서 시작해 How를 찾는 과정을 좋아합니다. 그 고민과 성장의 과정을 꾸준히 기록하고자 합니다.
태그 목록
전체보기 (465)error(9)알고리즘(8)DFS(7)Algorythm(7)Two pointers(7)git(7)js(6)BFS(5)webpack(5)React(5)redux(5)leetcode(4)breadth first search(4)ts(4)test(4)리액트(4)State(3)백준(3)shallow copy(3)DP(3)depth first search(3)offsetX(3)TIL(3)keydown(3)Binary Search(3)rotate(3)recursion(3)transform(3)bindActionCreators(3)JS30(3)getBoundingClientRect(2)자바스크립트(2)프로그래머스(2)hash set(2)mapstatetoprops(2)next.js(2)slice(2)Node(2)transform-origin(2)innerHeight(2)절대경로(2)Bit manipulation(2)offsetTop(2)scrollY(2)Constructor(2)Array.from(2)ghost defense(2)pageX(2)transitionend(2)semantic(2)scroll(2)async(2)Sliding Window(2)mapdispatchtoprops(2)Map(2)repository(2)reduce(2)algo(2)currentTime(2)router(2)얕은복사(2)fromIndex(2)refactoring(2)connect()(2)type(2)convention(2)프로토타입(2)vanilla js(2)modal(2)Suspense(2)Next.js 13(2)입출력과사칙연산(2)indexOf(2)linked list(2)stack(2)unit test(2)Recoil(2)login(2)컴포넌트(2)Prototype(2)tsconfig(2)path parameter(2)dynamic programming(2)jest(2)offsetWidth(2)rebase(1)약수(1)평균(1)http(1)동적 라우팅(1)CRA(1)googleid(1)next error(1)댓글삭제(1)queue(1)Absolute Path(1)S3(1)TWIL(1)git revert(1)unit(1)해시(1)serialize(1)성능개선(1)REST(1)얕은복사 전개연산자(1)iteration(1)가운데정렬(1)serializes(1)atom(1)once(1)카카오(1)oAuth(1)reword(1)absolutepath(1)premitive(1)findIndex(1)iterable(1)iterator(1)소수찾기(1)toEqual(1)cypress(1)path(1)flatmap(1)mouseenter(1)FileReader(1)forinloop(1)callback(1)shiftKey(1)useSetRecoilState(1)blur(1)Module(1)실행컨텍스트(1)legacy-peer-deps(1)arguments(1)Rollup(1)라우팅(1)MVC(1)reference(1)행렬(1)@compound component(1)hamming weight(1)매개변수(1)콜라츠(1)capturing(1)끝까지 스크롤했는지 판별(1)Object.assign(1)dotenv(1)input: range(1)await(1)naming convention(1)functionComponent(1)원시값(1)useEffect(1)event loop(1)유사배열객체(1)짝수(1)환경변수(1)scrollLeft(1)교육과정 설계(1)margin:auto(1)revert(1)바닐라 자바스크립트(1)cryptowallet(1)참조값(1)(1)leeetCode(1)react-icon(1)node.js(1)hasOwnProperty(1)class(1)while(1)for(1)textShadow(1)in(1)&&(1)useParams(1)pagination(1)react-modal(1)useRecoilValue(1)mouseenter event(1)cubic-bezier(1)ESLint(1)paddingTop(1)ts error(1)nodeList(1)return-type(1)charCodeAt(1)Flexbox(1)offset(1)pointer-events(1)생성자함수(1)query(1)env(1)DROP(1)selector(1)인터넷(1)SOME(1)배열 안 모든 요소 인덱스 찾기(1)Web3(1)Depth-first searach(1)classList(1)테스트(1)OAuth2.0(1)git log(1)switch(1)bundler(1)unhandledPromiseRejection(1)REST API(1)JWT(1)find(1)pathname(1)토큰(1)next(1)concat(1)sytaxError(1)event.preventDefault()(1)클로저(1)(1)라우터(1)textContent(1)CS(1)원티드 프리온보딩(1)offsetLeft(1)filter(1)소셜 로그인(1)module format(1)eth(1)input event(1)data binding(1)for...in(1)regex(1)온보딩(1)댓글추가(1)npm error(1)build(1)복사(1)base64(1)clientHeight(1)blockchain(1)commit(1)context(1)소셜로그인(1)연결리스트(1)local storage(1)entries(1)mouseleave(1)코드스플리팅(1)Sort(1)vite(1)keyCode(1)this(1)challenge(1)preonboarding(1)DOM(1)transition-timing-function(1)tofixed(1)toBe(1)테스트코드(1)offsetHeight(1)예외처리(1)E2ETest(1)CSS(1)함수선언(1)중복값제거(1)소수(1)Sementic web(1)reset(1)object.entries(1)arrayLike(1)Design Pattern(1)fork(1)data-*(1)shift(1)Context API(1)기프티콘 앱(1)DevTool(1)SSR(1)static method(1)line height(1)dependency(1)React18(1)innerText(1)handleActions(1)transform:rotate(1)--force(1)좋은 컴포넌트(1)execution context(1)시멘틱(1)state 끌어올리기(1)git reset(1)InnerHTML(1)정적 메서드(1)METAMASK(1)transition(1)클래스(1)moduleFormat(1)KeyboardEvent.shiftkey(1)mock(1)for...of(1)provider(1)재귀(1)array(1)spread operator(1)text-align:center(1)super(1)프로젝트(1)coordinates(1)innderHeight(1)display(1)translate(1)useLocation(1)aws(1)github(1)IntersectionObserver(1)icon(1)RenderTree(1)bundle(1)lazy(1)cornify_add()(1)evendigits(1)JSX(1)express(1)semantic web(1)CSSOM(1)git push -f origin(1)setAttribute(1)LIMIT(1)원티드 프리온보딩 프론트엔드(1)path variable(1)squash(1)비트연산(1)redux-devtools-extension(1)event delegation(1)rendering(1)immutability(1)createAction(1)재사용성(1)HTMLCollection(1)object.keys(1)Database(1)yield(1)outerHeight(1)input: color(1).env(1)디자인 패턴(1)(1)again(1)hash(1)streaming SSR(1)duration(1)race condition(1)origin(1)object.values(1)니콘내콘(1)radix-ui(1)SDK(1)bubbling(1)code_splitting(1)drag(1)array replace(1)Singleton(1)playbackRate(1)deep copy(1)closure(1)fallback(1)rm --cached(1)Routes(1)NFT(1)KeyboardEvent(1)유닛테스트(1)교육과정(1)싱글턴 패턴(1)event.isComposing()(1)dynamic programing(1)headless(1)cloudfront(1)sop(1)screenX(1)--legacy-peer-deps(1)query parameter(1)과반수(1)routing(1)pick(1)keyup(1)정규표현식(1)nextjs(1)screenHeight(1)Maximum call stack size exceeded(1)인증(1)배열(1)cors(1)인가(1)asynchronous(1)스테이메모리(1)유닛 테스트(1)Flux(1)position(1)ListNode(1)headless ui(1)semantic tag(1)숙박플랫폼(1)promise(1)formData(1)clientX(1)import(1)video(1)every(1)useRecoilState(1)ScrollIntoView(1)깊은복사(1)자료구조(1)Center(1)social-login(1)dynamic routing(1)API(1)npm(1)URI(1)esbuild(1)parsing(1)timeupdate(1)localeCompare(1)testingLibraryElementError(1)배열 요소의 모든 위치 찾기(1)setProperty()(1)stopPropagation(1)merge(1)
post-thumbnail

ghost defense - 5) refactoring(2)

1차로 4~5일간 만든 Ghost Defense 게임. 누군가에게 보여줄 수 있을 만큼 제대로 완성도 있게 마무리한 게임은 이번이 처음이다. 그만큼 한 번 완성한 것에서 그치지 않고 한 번 더 코드를 뜯어보고, 단순한 기능 구현이 아닌 코드 자체에 대한 고민을 조금 더 깊이있게 하는 시간을 꼭 가지고 싶었다. 💎 Refactoring - point 1. bullet class를 따로 생성해 hero class와 분리하자. hero의 동작으로 인해 bullet이 작동했기 때문에 hero안에 포함시켜놓았는데, hero와 bullet의 상호작용으로 동작이 일어나기 때문에 각각의 클래스를 지니는 것이 더 자연스러울 수 있기 때문 2. ghost class를 활용해 인스턴스를 독립적으로 구성하자. 지금까지는 Ghost class 내부에서 여러개의 ghost를 만들었다. init.js에서 ghost 인스턴스를 만든 뒤 createRandomGhost()를 호출해

2021년 12월 6일
·
0개의 댓글
·
post-thumbnail

enemy rain - refactoring

innerHeight ghostField안에 ghost가 랜덤으로 생성되고 나면, ghostField를 좌우로 흔들며 아래로 움직여 ghost들을 위에서 아래로 함께 내려가는 것처럼 보이도록 만들었다. 이 때 모든 ghost가 hero를 지나가 화면 밖으로 이동하고 나면, 이동을 끝내고 해당 라운드의 게임을 멈춰야 한다. 이전에는 임시로 화면 밖으로 가도록 800이라는 숫자를 주었다. transition이 끝날때마다 getBoundingClientRect.top()을 이용해 ghostField의 현재위치를 받아오고, 800보다 커지면 ghostField를 translate으로 움직이고 있던 setInterval함수를 clearInterval로 중단시켰다. 그러나 게임을 하는 사용자의 브라우저 창의 크기를 알 수 없기 때문에, 어떤 사람은 ghost가 모두 지나간 뒤 한참 후에야 다음 게임으로 넘어간다고 느낄 수도 있고, 어떤 사람은 ghost가 모두 지나가기도 전에 다음

2021년 12월 3일
·
0개의 댓글
·