2009. 6. 3.

HTML5 의 Web 게임 가능성..

Google Chrome 이후로 자바스크립트에 많은 관심이 간다.
그중에 하나가 브라우저 상에서의 애니메이션을 제어하는 기술이다.
HTML 5 상에서의 CANVAS로 수행하는 상당히 많은 예제를 보고 있자면 실제로 사용이 가능한 경우가 상당히 많을 것으로 생각한다.
오늘자 Slashdot에서는 플래시 없이 동영상을 VIDEO태그로 실행하는 사이트가 올라왔다. Firefox 3.5 에서만 볼 수 있는 것이 아쉽지만, 앞으로 HTML 5 가 플러그인 시장에 얼마나 엄청난 타격을 입힐지는 기대가 된다.

말하자면 컴퓨터쪽에서의 강력한 연산기능대신 비디오/오디오 등에 특화된 CPU가 있다면, 서버쪽에서 대부분의 연산을 담당하고 클라이언트에서는 웹브라우저가 실제 플랫폼을 대신하는 상황도 생각할 수 있다.

Erlang , LISP으로 만든 게임에서 플레이어 DB데이터와 게임액션을 Erlang이 담당하고, 게임상의 상태처리, 길찾기, API등을 Lisp으로 처리하는 방식은 상당히 좋은 Role Model이 될 수 있을듯하다.

ARM등의 비디오/오디오 강화 CPU에 실연산처리는 클라우드를 포함하는 대규모 서버군이 처리하고, 광대역 처리만 제대로 된다면 기존의 플러그인없이도 HTML 5 만으로도 훌륭한 게임이 나올 수 있을 듯하다.



관련링크


2009. 6. 1.

LISP으로 어드벤처 게임을... Ch 12

이제 각 방별로 해당 방에 들어갔을때 설명을 출력하도록 한다.

;;;; 게임의 Castle 구성하기..
;;; north south east west up down mobs
(defvar *castle*
  '((0 2 0 0 0 0 0 ("You are in the hall way." "There is a door in south." "Through window to the north you can see secret herb garden"))
    (1 3 3 3 0 0 0 ("This is the audience chamber" "There is a window to the south. By looking to the right" "Through it you can see the entrance of the castle" "Doors leave this room to the north, east, and south" ))
    (2 0 5 2 0 0 0 ("You are in great hall, all-shaped room" "There is doors to the east and to the north" "In the alcove is a door to the west"))
    (0 5 0 0 0 0 0 ("This is the monarch's private meeting room" "There is a single exit to the south"))
    (4 0 0 3 15 13 0 ("This inner hallway contains a door to the north." "And one to the west, and a circular stairwell" "passes though the room" "You can see ornamental lake through here"))
    (0 0 1 0 0 0 0 ("You are at the entrance to a fobidding-looking" "stone castle. You are facing east"))
    (0 8 0 0 0 0 0 ("This is castle's kitchen. Though windows in" "The north wall you can see secret herb garden." "A door leave the kitchen to the south" ))
    (7 10 0 0 0 0 0 ("You are in store room admist spices" "vegatables, and vast sacks of floud and" "Other provisions. There is a door to the north" "and one to the south"))
    (0 19 0 8 0 8 0 ("You are slowly descends."))
    (8 0 11 0 0 0 0 ("You are in the real vestibule." "There are windows to the south from which" "you can see ornamental lake" "There is an exit to the east and " "one to north"))
    (0 0 10 0 0 0 0 () )
    (0 0 0 13 0 0 0 ("you are in dank dark dungeon" "There is single exit, a small hole in" "wall towards to east"))
    (0 0 12 0 5 0 0 ("You are in the prison guardroom in the " "basement of the castle. The staiwell" "ends in the room. There is one other" "exit, a small hole in the east wall") )
    (0 15 17 0 0 0 0 ("You are in the master bedroom on the upper" "level of the castle..." "Looking down from the window to the west, you" "can see the entrance to the castle, while the" "secret herb garden is visible below to the north" "window. There are doors to the east and" "to the south"))
    (14 0 0 0 0 5 0 ("This is L-shaped upper hallway." "To the north is a door, and there is a strairwell in the hall as well. You can see" "the lake through the south windows."))
    (17 0 19 0 0 0 0 ("This room was used as the castle treasury in" "by-gone years..." "There are no windows, just exits to the" "north and to the east"))
    (18 16 0 14 0 0 0 ("Ooooh.. you are in the chembermaids' bedroom" "There is an exit to the west and a door " "TO the south"))
    (0 17 0 0 0 0 0 ("This tiny room on the upper level is the" "dressing chamber. There is a window to the" "north. with a view of the here garden down" "below. A door leaves to the south."))
    (9 0 16 0 0 0 0 ("This is a small room outside the castle" "lift which can be entered by a door to the north" "another door leads to the west, you can see" "the lake through the southern windows"))))

설명을 출력할 부분을 만든다.

먼저 방에서 각 요소를 가져오는 함수에, 새로 설명을 출력할 부분을 추가한다.

;;; 방의 리스트에서 각 요소를 가져오는 함수
(defun get-rooms-element (room element)
  (cond ((char= element #\n) (car room))
        ((char= element #\s) (nth 1 room))
        ((char= element #\e) (nth 2 room))
        ((char= element #\w) (nth 3 room))
        ((char= element #\u) (nth 4 room))
        ((char= element #\d) (nth 5 room))
        ((char= element #\m) (nth 6 room))
        ((char= element #\v) (nth 7 room))
        (t
         nil)))

다음으로 해당하는 방의 설명을 출력하는 함수를 만든다.

;;; 방의 모습을 설명하는 루틴
(defun describe-room ()
  (format t "The room is ~A~%" *room*)
  (print-room *room*)
  (if (= *room* 9) (setf *room* 10)))

9번방에 들어온 경우에는 자동으로 10번방으로 이동한다.

;;; 방의 내역을 출력하기
(defun print-room (which-room)
  (let ((desc-list (get-rooms-element (get-room which-room ) #\v)))
    (labels ((iter (field)
               (cond ((null field) )
                     (t
                      (format t "~a~%" (car field))
                      (iter (cdr field))))))
      (iter desc-list))))

마지막으로 플레이어가 11번방으로 들어왔다면 게임을 종료한다.

;;; 전체 이벤트 루프

(defun event-loop ()
  (let ((k (get-rooms-element (get-room *room*) #\m))
        (game-over nil))
    (loop
       (status-report)
       (cond ((= *room* 11)
              (progn
                (format t "Congratulation, you escape the castle")
                (setf game-over t)))
             (t
              (let ((input-key (keyboard-event)))
                (cond ((string= input-key "n") (go-direction #\n))
                      ((string= input-key "s") (go-direction #\s))
                      ((string= input-key "e") (go-direction #\e))
                      ((string= input-key "w") (go-direction #\w))
                      ((string= input-key "u") (go-direction #\u))
                      ((string= input-key "d") (go-direction #\d))
                      ((string= input-key "c") (consume-food))
                      ((string= input-key "f") (fight))
                      ((string= input-key "r") (runaway))
                      ((string= input-key "q") (setf game-over t))
                      ((string= input-key "m") (magic-amulet))
                      ((string= input-key "p") (picking-up))
                      ((string= input-key "i") (inventory))))))
       (if (eq game-over t)
           (return-from event-loop)))))

다음 부터는 완성된 버전을 LISP식으로 조금씩 변화시켜나가보도록 하겠다.