자바스크립트 팩맨 Pacman 소스코드 알고리즘 분석

행복햐 2017. 8. 18. 13:28

출처: http://www.masswerk.at/JavaPac/pacman-howto.html

 

참고: https://codepen.io/hellokatili/pen/xwKRmo

 

object

  1. Pacman.Ghost : 26
  2. Pacman.User   : 279
  3. Pacman.Map   : 532
  4. PACMAN        : 773
  5. KEY               : 1099

constant

    Pacman.WALL : 1120

    Pacman.BISCUIT

    Pacman.EMPTY

    Pacman.BLOCK

    Pacman.PILL

    Pacman.MAP      : 1126

    Pacman.WALLS   :  1151       

method
  • Pacman.Ghost
draw
  • Pacman.User
draw
drawDead
방향전환
keyDown
getNewCoord
좌표변환, 충돌검사, 알약 존재유무 설정
isOnSamePlane
move
입모양
calcAngle
  • Pacman.Map
drawWall
drawPills
drawBlock
  • PACMAN

 

충돌검사
collided
 startNewGame : 826
키입력
      keyDown : 835

 

      map.draw : 
      startLevel : 816
 mainDraw : 913

        

        init :  1030

              loaded : 1082

              mainLoop      : 956      

 setInterval (mainLoop,) : 1089

 

global NONE      
  UP      
  LEFT      
  DOWN      
  RIGHT      
  WAITING      
  PAUSE      
  PALYING      
  COUNTDOWN      
  EATEN_PAUSE      
  DYING      
  Pacman      
         
object Pacman.Ghost Pacman.User Pacman.Map PACMAN
         
variable position position height state
  direction direction width audio
  eatable   blockSize ghosts
  eaten eaten pillSize ghostSpecs
  due due map eatenCount
    lives   level
    scrore   tick
    keyMap   ghostPos
        userPos
        stateChanged
        timerStart
        lastTime
        ctx
        timer 
        map
        user 
        stored
         
method   addScore withinBounds getTick
  addBounded theScore isWall  
    loseLife   dialog
  isDangerous getLives isFloorSpace soundDisabled
  isVunerable initUser   startLevel
  isHidden newLevel    
  getNewCoord getNewCoord   startNewGame
  getRandomDirection keyDown   keyDown
        keyPress
        loseLife
  reset reset reset setState
  oppositeDirection resetPosition block collided
      setBlock  
  makeEatable      
         
        mainLoop
    next    compltedLevel
  nextSquare nextSquare   eatenPill
  onGridSquare onGridSquare    
  onWholeSquare onWholeSquare    
    isMidSquare    
  pointToCoord pointToCoord    
    isOnSamePlane   init
  secondsAgo     load
  pane     loaded
  move move   setInterval
  getColour      
    calcAngle    
  eat      
  draw draw  draw mainDraw
    drawDead drawBlock drawScore
      drawWall drawFooter
      drawPills redrawBlock

 

https://mind42.com/public/cb6576b6-9983-43ce-ad03-56a57c1feaf7

불러오는 중입니다...