Completely change naming conventions of field forms and definition macros. Close #32
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
(defun :Void main []
|
||||
(print "Hello world!"))
|
||||
(function :Void main []
|
||||
(print "Hello world!"))
|
||||
|
@@ -2,11 +2,11 @@
|
||||
[:Map<String,Surface> _surfaces (new Map)])
|
||||
|
||||
// TODO don't allow overriding a key -- use a macro so all load___() calls check their maps first
|
||||
(defmethod loadSurface [key path]
|
||||
(method loadSurface [key path]
|
||||
(dictSet _surfaces key (Surface.fromString (backend.loadText path))))
|
||||
|
||||
// TODO runtime-assert that the key exists. Use a macro so all get___() calls check their maps first
|
||||
(defmethod getSurface [key]
|
||||
(method getSurface [key]
|
||||
(dictGet _surfaces key))
|
||||
|
||||
// TODO freeSurface() etc.
|
||||
// TODO freeSurface() etc.
|
||||
|
@@ -8,33 +8,33 @@
|
||||
|
||||
(fill (or fillColor Black)))
|
||||
|
||||
(defmethod fill [:Color color]
|
||||
(method fill [:Color color]
|
||||
(red.fill 0 area color.r)
|
||||
(green.fill 0 area color.g)
|
||||
(blue.fill 0 area color.b))
|
||||
|
||||
(defmethod _index [x y]
|
||||
(method _index [x y]
|
||||
(+ x (* y width)))
|
||||
|
||||
(defmacro withIndex [idxName xName yName &body body]
|
||||
`(let [,idxName (_index ,xName ,yName)]
|
||||
,@body))
|
||||
|
||||
(defmethod getPixel [x y]
|
||||
(method getPixel [x y]
|
||||
(withIndex idx x y
|
||||
(object r (red.get idx) g (green.get idx) b (blue.get idx))))
|
||||
|
||||
(defmethod setPixel [x y color]
|
||||
(method setPixel [x y color]
|
||||
(withIndex idx x y
|
||||
(red.set idx color.r)
|
||||
(green.set idx color.g)
|
||||
(blue.set idx color.b)))
|
||||
|
||||
(defun equal [c1 c2]
|
||||
(function equal [c1 c2]
|
||||
(and (= c1.r c2.r) (= c1.g c2.g) (= c1.b c2.b)))
|
||||
|
||||
(defvar Black (object r 0 g 0 b 0))
|
||||
(defvar Red (object r 255 g 0 b 0))
|
||||
(defvar Green (object r 0 g 255 b 0))
|
||||
(defvar Blue (object r 0 g 0 b 255))
|
||||
(defvar White (object r 255 g 255 b 255))
|
||||
(var Black (object r 0 g 0 b 0))
|
||||
(var Red (object r 255 g 0 b 0))
|
||||
(var Green (object r 0 g 255 b 0))
|
||||
(var Blue (object r 0 g 0 b 255))
|
||||
(var White (object r 255 g 255 b 255))
|
||||
|
@@ -16,10 +16,10 @@
|
||||
(graphicsBackend.initialize title width height letterWidth letterHeight)
|
||||
(gameLogic.initialize assets))
|
||||
|
||||
(defmethod update [:Float deltaSeconds]
|
||||
(method update [:Float deltaSeconds]
|
||||
(gameLogic.update this deltaSeconds))
|
||||
|
||||
(defmethod draw []
|
||||
(method draw []
|
||||
(let [&mut changedGraphics false]
|
||||
(gameLogic.draw (lambda [] (set changedGraphics true) graphics) assets)
|
||||
(when changedGraphics (graphicsBackend.draw graphics))))
|
||||
(when changedGraphics (graphicsBackend.draw graphics))))
|
||||
|
@@ -1,2 +1,2 @@
|
||||
(defmethod new [width height]
|
||||
(super width height))
|
||||
(method new [width height]
|
||||
(super width height))
|
||||
|
@@ -3,5 +3,5 @@
|
||||
:Int height _height
|
||||
:Array<Array<T>> rows (for _ (range height) (for _ (range width) defaultValue))])
|
||||
|
||||
(defmethod getCell [x y] (nth (nth rows y) x))
|
||||
(defmethod setCell [x y value] (setNth (nth rows y) x value))
|
||||
(method getCell [x y] (nth (nth rows y) x))
|
||||
(method setCell [x y value] (setNth (nth rows y) x value))
|
||||
|
@@ -3,11 +3,11 @@
|
||||
:Int height _height
|
||||
:Array<String> rows (for _ (range height) (* (or letter " ") width))])
|
||||
|
||||
(defmethod getChar [x y]
|
||||
(method getChar [x y]
|
||||
(.charAt (nth rows y) x))
|
||||
|
||||
(defmethod setChar [x y char]
|
||||
(method setChar [x y char]
|
||||
(let [row (nth rows y)
|
||||
left (row.substr 0 x)
|
||||
right (row.substr (+ x 1))]
|
||||
(setNth rows y "${left}${char}${right}")))
|
||||
(setNth rows y "${left}${char}${right}")))
|
||||
|
@@ -7,34 +7,34 @@
|
||||
:Grid<Bool> opacity (new Grid width height true)
|
||||
:Grid<String> specialInfo (new Grid width height "")])
|
||||
|
||||
(defmethod getBackgroundColor [x y]
|
||||
(method getBackgroundColor [x y]
|
||||
(backgroundColors.getPixel x y))
|
||||
|
||||
(defmethod setBackgroundColor [x y color]
|
||||
(method setBackgroundColor [x y color]
|
||||
(backgroundColors.setPixel x y color))
|
||||
|
||||
(defmethod getLetter [x y]
|
||||
(method getLetter [x y]
|
||||
(object char (letters.getChar x y) color (letterColors.getPixel x y)))
|
||||
|
||||
(defmethod setLetter [x y letter]
|
||||
(method setLetter [x y letter]
|
||||
(letters.setChar x y letter.char)
|
||||
(letterColors.setPixel x y letter.color))
|
||||
|
||||
(defmethod isCellOpaque [x y]
|
||||
(method isCellOpaque [x y]
|
||||
(opacity.getCell x y))
|
||||
|
||||
(defmethod setCellOpacity [x y value]
|
||||
(method setCellOpacity [x y value]
|
||||
(opacity.setCell x y value))
|
||||
|
||||
(defmethod getSpecialInfo [x y]
|
||||
(method getSpecialInfo [x y]
|
||||
(specialInfo.getCell x y))
|
||||
|
||||
(defmethod setSpecialInfo [x y value]
|
||||
(method setSpecialInfo [x y value]
|
||||
(specialInfo.setCell x y value))
|
||||
|
||||
// TODO rectangle type
|
||||
// TODO optional source rectangle argument
|
||||
(defmethod blitSurface [:Surface surface x y]
|
||||
(method blitSurface [:Surface surface x y]
|
||||
(doFor [srcX destX] (the kiss.List<kiss.List<Int>> (zipDrop (range surface.width) (range x (+ x surface.width))))
|
||||
(when (< -1 destX width)
|
||||
(doFor [srcY destY] (the kiss.List<kiss.List<Int>> (zipDrop (range 0 surface.height) (range y (+ y surface.height))))
|
||||
@@ -46,7 +46,7 @@
|
||||
// Cover transparent cells in the lower surface with opaque ones
|
||||
(setCellOpacity destX destY true)))))))
|
||||
|
||||
(defun fromString [text]
|
||||
(function fromString [text]
|
||||
(let [stream (Stream.fromString text)
|
||||
:Map<String,Color> colors (new Map)
|
||||
:Map<String,String> infoCodes (new Map)
|
||||
@@ -95,4 +95,4 @@
|
||||
(doFor x (range width)
|
||||
(surface.specialInfo.setCell x y (dictGet infoCodes (stream.expect "a special info code" ->{(stream.takeChars 1)}))))
|
||||
(stream.dropString "\n"))
|
||||
surface)))))
|
||||
surface)))))
|
||||
|
@@ -1,3 +1,3 @@
|
||||
(defnew [])
|
||||
|
||||
(defmethod loadText [filePath] (Assets.getText filePath))
|
||||
(method loadText [filePath] (Assets.getText filePath))
|
||||
|
@@ -1,8 +1,8 @@
|
||||
(defprop &mut :FlxGroup backgroundColors null)
|
||||
(defprop &mut :FlxGroup letters null)
|
||||
(defprop &mut :Int letterWidth 0)
|
||||
(defprop &mut :Int letterHeight 0)
|
||||
(defprop &mut :FlxBitmapFont font null)
|
||||
(prop &mut :FlxGroup backgroundColors null)
|
||||
(prop &mut :FlxGroup letters null)
|
||||
(prop &mut :Int letterWidth 0)
|
||||
(prop &mut :Int letterHeight 0)
|
||||
(prop &mut :FlxBitmapFont font null)
|
||||
|
||||
(defnew [_state
|
||||
_fontAsset
|
||||
@@ -13,14 +13,14 @@
|
||||
:FlxRect region _region
|
||||
:FlxPoint spacing _spacing])
|
||||
|
||||
(defmethod :Void initialize [:String title :Int width :Int height :Int _letterWidth :Int _letterHeight]
|
||||
(method :Void initialize [:String title :Int width :Int height :Int _letterWidth :Int _letterHeight]
|
||||
(set letterWidth _letterWidth)
|
||||
(set letterHeight _letterHeight)
|
||||
(set font (FlxBitmapFont.fromMonospace fontAsset fontLetters (new FlxPoint letterWidth letterHeight) region spacing))
|
||||
(set backgroundColors (new FlxGroup))
|
||||
(set letters (new FlxGroup)))
|
||||
|
||||
(defmethod :Void draw [:Graphics graphics]
|
||||
(method :Void draw [:Graphics graphics]
|
||||
(backgroundColors.kill)
|
||||
(set backgroundColors (new FlxGroup))
|
||||
(letters.kill)
|
||||
@@ -42,4 +42,4 @@
|
||||
(set text.textColor (FlxColor.fromRGB color.r color.g color.b))
|
||||
(letters.add text))))))
|
||||
(state.add backgroundColors)
|
||||
(state.add letters))
|
||||
(state.add letters))
|
||||
|
@@ -1,3 +1,3 @@
|
||||
(defnew [])
|
||||
|
||||
(defmethod loadText [filePath] (File.getContent filePath))
|
||||
(method loadText [filePath] (File.getContent filePath))
|
||||
|
@@ -1,12 +1,12 @@
|
||||
(defprop &mut :Int letterWidth 0)
|
||||
(defprop &mut :Int letterHeight 0)
|
||||
(defprop &mut :Int drawCalled 0)
|
||||
(prop &mut :Int letterWidth 0)
|
||||
(prop &mut :Int letterHeight 0)
|
||||
(prop &mut :Int drawCalled 0)
|
||||
|
||||
(defnew [])
|
||||
|
||||
(defmethod :Void initialize [:String title :Int width :Int height :Int _letterWidth :Int _letterHeight]
|
||||
(method :Void initialize [:String title :Int width :Int height :Int _letterWidth :Int _letterHeight]
|
||||
(set letterWidth _letterWidth)
|
||||
(set letterHeight _letterHeight))
|
||||
|
||||
(defmethod :Void draw [:Graphics graphics]
|
||||
(+= drawCalled 1))
|
||||
(method :Void draw [:Graphics graphics]
|
||||
(+= drawCalled 1))
|
||||
|
Reference in New Issue
Block a user