Skip to content

brycecovert/play-clj-nrepl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

play-clj-nrepl

If you want to edit a running game from play-clj within emacs, you're probably going to want to start an nrepl server. But if you make changes to :on-show, they won't be run.

This small library makes it easy to start an nrepl server, and whenever you recompile, it'll reload your screen(s).

Usage

Add the following dependency to your project.clj: clojure [play-clj-nrepl "0.1.0" :exclusions [play-clj]]

start an nrepl server when your game starts up:

(defgame your-game
  :on-create
  (ƒ [this]
    (play-clj-nrepl.core/start-nrepl your-game 2000)
    (set-screen! this main-screen)))

This will start an nrepl server on port 2000. If you attach to this nrepl and recompile, it will reload (that is, call :on-show on) your screens automatically.

Example

Here's a play-clj hello world game:

(ns test-hello.core
  (:require [play-clj.core :refer :all]
            [play-clj.ui :refer :all]
            [play-clj-nrepl.core :as nr]))

(defscreen main-screen
  :on-show
  (ƒ [screen entities]

    (update! screen :renderer (stage))
    (label "Hello World!" (color :white)))

  :on-render
  (ƒ [screen entities]
    (clear!)
    (render! screen entities)))
  
(defgame your-game
  :on-create
  (ƒ [this]
    (nr/start-nrepl your-game 2000)
    (set-screen! this main-screen)))

If you run this using lein run, it'll start an nrepl on port 2000.

Then, you can attach to it using M-X cider in emacs.

If you change (label "Hello World!" (color :white)) to say (label "Hello Red!" (color :red)). Hit C-c C-k and return to your game. You'll see your changes immediately.

License

Copyright © 2016 Bryce Covert

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published