Skip to content

Commit

Permalink
Exctract init code to a function (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Oct 18, 2015
1 parent a0d9c1b commit bfb089d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
10 changes: 7 additions & 3 deletions pacmacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,23 @@
;;;###autoload
(defun pacmacs-start ()
(interactive)
(pacmacs--initialize-game 'pacmacs-tick)
(pacmacs-mode))

(defun pacmacs--initialize-game (tick-function)
(switch-to-buffer pacmacs-buffer-name)
(pacmacs-mode)

(setq pacmacs-lives 3)
(setq pacmacs-score 0)
(setq pacmacs-levels (pacmacs--get-list-of-levels))
(setq pacmacs-current-level 0)

(pacmacs--load-current-level)
(pacmacs--switch-to-play-state)

(unless pacmacs-timer
(setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001) 'pacmacs-tick))))
(setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001)
tick-function))))

(defun pacmacs-destroy ()
(when pacmacs-timer
Expand Down
15 changes: 2 additions & 13 deletions tools/it-recorder.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@

(defun pacmacs--start-it-recorder ()
(interactive)
(switch-to-buffer pacmacs-buffer-name)
(pacmacs--initialize-game 'pacmacs-record-tick)
(pacmacs-it-recorder-mode)

(setq pacmacs-lives 3)
(setq pacmacs-score 0)
(setq pacmacs-levels (pacmacs--get-list-of-levels))
(setq pacmacs-current-level 0)
(pacmacs--reset-recorder)

(pacmacs--load-current-level)
(pacmacs--switch-to-play-state)

(unless pacmacs-timer
(setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001) 'pacmacs-record-tick))))
(pacmacs--reset-recorder))

0 comments on commit bfb089d

Please sign in to comment.