common-main-loop.nv
· 357 B · Text
原始文件
Playground
|#|start exhaustive
|#|constant, @resolution-x, 800
|#|constant, @resolution-y, 600
||start
|start|
@resolution-x:800,
@resolution-y:600,
set the window resolution,
main loop
|set the window resolution| @set-resolution
|main loop, @quit|
|main loop|
poll for input,
main
|poll for input| @poll-input
|clear the screen| @clear-screen
| 1 | |#|start exhaustive |
| 2 | |#|constant, @resolution-x, 800 |
| 3 | |#|constant, @resolution-y, 600 |
| 4 | ||start |
| 5 | |start| |
| 6 | @resolution-x:800, |
| 7 | @resolution-y:600, |
| 8 | set the window resolution, |
| 9 | main loop |
| 10 | |set the window resolution| @set-resolution |
| 11 | |main loop, @quit| |
| 12 | |main loop| |
| 13 | poll for input, |
| 14 | main |
| 15 | |poll for input| @poll-input |
| 16 | |clear the screen| @clear-screen |
| 17 |
triangle.nv
· 980 B · Text
原始文件
Playground
|#|constant, @line-x-1, 50
|#|constant, @line-y-1, 50
|#|constant, @line-x-2, 400
|#|constant, @line-y-2, 200
|#|constant, @line-x-1, 400
|#|constant, @line-y-1, 200
|#|constant, @line-x-2, 500
|#|constant, @line-y-2, 500
|#|constant, @line-x-1, 500
|#|constant, @line-y-1, 500
|#|constant, @line-x-2, 50
|#|constant, @line-y-2, 50
|#|constant, @line-r, 255
|#|constant, @line-g, 255
|#|constant, @line-b, 255
|main|
clear the screen,
draw side A,
draw side B,
draw side C,
display,
yield
|draw a side|,
@line-r:255,
@line-g:255,
@line-b:255,
draw a line
|draw a line| @draw-line
|draw side A|
@line-x-1:50,
@line-y-1:50,
@line-x-2:400,
@line-y-2:200,
draw a side
|draw side B|
@line-x-1:400,
@line-y-1:200,
@line-x-2:500,
@line-y-2:500,
draw a side
|draw side C|
@line-x-1:500,
@line-y-1:500,
@line-x-2:50,
@line-y-2:50,
draw a side
|display| @display
|yield| main loop
| 1 | |#|constant, @line-x-1, 50 |
| 2 | |#|constant, @line-y-1, 50 |
| 3 | |#|constant, @line-x-2, 400 |
| 4 | |#|constant, @line-y-2, 200 |
| 5 | |
| 6 | |#|constant, @line-x-1, 400 |
| 7 | |#|constant, @line-y-1, 200 |
| 8 | |#|constant, @line-x-2, 500 |
| 9 | |#|constant, @line-y-2, 500 |
| 10 | |
| 11 | |#|constant, @line-x-1, 500 |
| 12 | |#|constant, @line-y-1, 500 |
| 13 | |#|constant, @line-x-2, 50 |
| 14 | |#|constant, @line-y-2, 50 |
| 15 | |
| 16 | |#|constant, @line-r, 255 |
| 17 | |#|constant, @line-g, 255 |
| 18 | |#|constant, @line-b, 255 |
| 19 | |
| 20 | |main| |
| 21 | clear the screen, |
| 22 | draw side A, |
| 23 | draw side B, |
| 24 | draw side C, |
| 25 | display, |
| 26 | yield |
| 27 | |
| 28 | |draw a side|, |
| 29 | @line-r:255, |
| 30 | @line-g:255, |
| 31 | @line-b:255, |
| 32 | draw a line |
| 33 | |
| 34 | |draw a line| @draw-line |
| 35 | |
| 36 | |draw side A| |
| 37 | @line-x-1:50, |
| 38 | @line-y-1:50, |
| 39 | @line-x-2:400, |
| 40 | @line-y-2:200, |
| 41 | draw a side |
| 42 | |
| 43 | |draw side B| |
| 44 | @line-x-1:400, |
| 45 | @line-y-1:200, |
| 46 | @line-x-2:500, |
| 47 | @line-y-2:500, |
| 48 | draw a side |
| 49 | |
| 50 | |draw side C| |
| 51 | @line-x-1:500, |
| 52 | @line-y-1:500, |
| 53 | @line-x-2:50, |
| 54 | @line-y-2:50, |
| 55 | draw a side |
| 56 | |
| 57 | |display| @display |
| 58 | |yield| main loop |