git.s-ol.nu alive / wip
wip s-ol 2 months ago
2 changed file(s) with 52 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
6565 --
6666 -- Marks this stream as dirty for the remainder of the current tick.
6767 -- If `event` is nil, does nothing.
68 set: (event) =>
68 set: (event, force=false) =>
6969 return if event == nil
70 assert not @dirty!, "#{@} is already dirty!"
70 assert force or not @dirty!, "#{@} is already dirty!"
7171 @updated = COPILOT.T
7272 @value = event
7373
1111 draw = Constant.meta
1212 meta:
1313 name: 'draw'
14 summary: "draw a love/shape shape."
15 examples: { '(love/draw shape)' }
14 summary: "draw one or more love/shape shapes."
15 examples: { '(love/draw shape1 …)', '(love/draw shapes)' }
1616
1717 value: class extends Op
1818 new: (...) =>
2121
2222 pattern = any['love/shape']*0
2323 setup: (inputs, scope) =>
24 if #inputs == 1
25 only = inputs[1]
26 type = only\type!
27 if type.__class == Array and type.type == T['love/shape']
28 super Input.hot only
29 return
30
2431 shapes = pattern\match inputs
2532 inputs = [Input.hot shape for shape in *shapes]
2633 inputs.num = Input.cold Constant.num #shapes
2835
2936 tick: =>
3037 shapes = @unwrap_all!
31 for i=1, shapes.num do shapes[i] or= ->
38 num = shapes.num or #shapes
39 for i=1, num do shapes[i] or= ->
3240 COPILOT.drawlist[@state] = shapes
3341
3442 destroy: =>
267275 tick: =>
268276 @out\set { @state.x, @state.y }
269277
278 mouse_pos = Constant.meta
279 meta:
280 name: 'mouse-pos'
281 summary: "vec2 ~-stream of the current mouse position."
282
283 value: COPILOT.mouse_pos
284
285 mouse_delta = Constant.meta
286 meta:
287 name: 'mouse-delta'
288 summary: "vec2 !-stream of mouse movements."
289
290 value: COPILOT.mouse_delta
291
292 wheel_delta = Constant.meta
293 meta:
294 name: 'wheel-delta'
295 summary: "vec2 !-stream of mouse wheel movements."
296
297 value: COPILOT.wheel_delta
298
299 key_presses = Constant.meta
300 meta:
301 name: 'key-presses'
302 summary: "str !-stream of key presses."
303
304 value: COPILOT.key_presses
305
306 key_releases = Constant.meta
307 meta:
308 name: 'key-releases'
309 summary: "str !-stream of key releases."
310
311 value: COPILOT.key_releases
312
270313 Constant.meta
271314 meta:
272315 name: 'love'
309352 :color, 'line-width': line_width
310353
311354 'mouse-pos': mouse_pos
355 'mouse-delta': mouse_delta
356 'wheel-data': wheel_delta
357 'key-presses': key_presses
358 'key-releases': key_releases