├── New Document.txt
├── docs
├── index.html
├── CNAME
└── Java
│ └── sudoku-javafx
│ └── docs
│ ├── package-list
│ ├── allclasses-noframe.html
│ ├── allclasses-frame.html
│ ├── script.js
│ ├── application
│ ├── package-frame.html
│ └── class-use
│ │ ├── Main.html
│ │ └── Controller.html
│ ├── index.html
│ ├── deprecated-list.html
│ └── constant-values.html
├── README.md
├── WeatherApp
├── README.md
├── complete
│ ├── html.zip
│ ├── imgs
│ │ ├── codes
│ │ │ ├── 200.png
│ │ │ ├── 201.png
│ │ │ ├── 202.png
│ │ │ ├── 210.png
│ │ │ ├── 211.png
│ │ │ ├── 212.png
│ │ │ ├── 221.png
│ │ │ ├── 230.png
│ │ │ ├── 231.png
│ │ │ ├── 232.png
│ │ │ ├── 300.png
│ │ │ ├── 301.png
│ │ │ ├── 302.png
│ │ │ ├── 310.png
│ │ │ ├── 311.png
│ │ │ ├── 312.png
│ │ │ ├── 313.png
│ │ │ ├── 314.png
│ │ │ ├── 321.png
│ │ │ ├── 500.png
│ │ │ ├── 501.png
│ │ │ ├── 502.png
│ │ │ ├── 503.png
│ │ │ ├── 504.png
│ │ │ ├── 511.png
│ │ │ ├── 520.png
│ │ │ ├── 521.png
│ │ │ ├── 522.png
│ │ │ ├── 531.png
│ │ │ ├── 600.png
│ │ │ ├── 601.png
│ │ │ ├── 602.png
│ │ │ ├── 603.png
│ │ │ ├── 611.png
│ │ │ ├── 612.png
│ │ │ ├── 615.png
│ │ │ ├── 616.png
│ │ │ ├── 620.png
│ │ │ ├── 621.png
│ │ │ ├── 622.png
│ │ │ ├── 701.png
│ │ │ ├── 711.png
│ │ │ ├── 721.png
│ │ │ ├── 731.png
│ │ │ ├── 741.png
│ │ │ ├── 751.png
│ │ │ ├── 761.png
│ │ │ ├── 762.png
│ │ │ ├── 771.png
│ │ │ ├── 781.png
│ │ │ ├── 800.png
│ │ │ ├── 801.png
│ │ │ ├── 803.png
│ │ │ └── 804.png
│ │ └── humidity.png
│ ├── WeatherAppComplete.zip
│ ├── index.html
│ ├── styles.css
│ └── app.js
├── imgs
│ ├── humidity.png
│ └── codes
│ │ ├── 200.png
│ │ ├── 201.png
│ │ ├── 202.png
│ │ ├── 210.png
│ │ ├── 211.png
│ │ ├── 212.png
│ │ ├── 221.png
│ │ ├── 230.png
│ │ ├── 231.png
│ │ ├── 232.png
│ │ ├── 300.png
│ │ ├── 301.png
│ │ ├── 302.png
│ │ ├── 310.png
│ │ ├── 311.png
│ │ ├── 312.png
│ │ ├── 313.png
│ │ ├── 314.png
│ │ ├── 321.png
│ │ ├── 500.png
│ │ ├── 501.png
│ │ ├── 502.png
│ │ ├── 503.png
│ │ ├── 504.png
│ │ ├── 511.png
│ │ ├── 520.png
│ │ ├── 521.png
│ │ ├── 522.png
│ │ ├── 531.png
│ │ ├── 600.png
│ │ ├── 601.png
│ │ ├── 602.png
│ │ ├── 603.png
│ │ ├── 611.png
│ │ ├── 612.png
│ │ ├── 615.png
│ │ ├── 616.png
│ │ ├── 620.png
│ │ ├── 621.png
│ │ ├── 622.png
│ │ ├── 701.png
│ │ ├── 711.png
│ │ ├── 721.png
│ │ ├── 731.png
│ │ ├── 741.png
│ │ ├── 751.png
│ │ ├── 761.png
│ │ ├── 762.png
│ │ ├── 771.png
│ │ ├── 781.png
│ │ ├── 800.png
│ │ ├── 801.png
│ │ ├── 803.png
│ │ └── 804.png
├── WeatherAppStarter.zip
├── index.html
└── styles.css
├── Java
└── sudoku-javafx
│ ├── docs
│ ├── package-list
│ ├── allclasses-noframe.html
│ ├── allclasses-frame.html
│ ├── script.js
│ ├── application
│ │ ├── package-frame.html
│ │ └── class-use
│ │ │ ├── Main.html
│ │ │ └── Controller.html
│ ├── index.html
│ ├── deprecated-list.html
│ └── constant-values.html
│ ├── sudoku-tutorial.zip
│ ├── tutorial_img
│ ├── 7qEWLHs.png
│ ├── EDakzfE.png
│ ├── EdobWTw.png
│ ├── HM2Hm8F.png
│ ├── Og7iwSG.png
│ ├── QnNXidl.png
│ ├── UpXVYuT.png
│ ├── VJReJUB.png
│ ├── VgIs8mV.png
│ ├── aPrt9Wh.png
│ ├── kWnIoVh.png
│ ├── nJfgXaC.png
│ ├── reiNKak.png
│ ├── v46MmtA.png
│ ├── xFXYxzy.png
│ └── yMnWaHK.png
│ ├── sudoku-tutorial
│ ├── bin
│ │ └── application
│ │ │ ├── Main.class
│ │ │ ├── Controller.class
│ │ │ ├── GameBoard.class
│ │ │ ├── Controller$1.class
│ │ │ ├── application.css
│ │ │ └── layout.fxml
│ ├── build.fxbuild
│ └── src
│ │ └── application
│ │ ├── application.css
│ │ ├── Main.java
│ │ └── layout.fxml
│ └── links
│ └── GameBoard.java
└── TetrisElm
├── Part10
├── .#Controller.elm
├── Part10.zip
├── Block.elm
├── Controller.elm
├── Board.elm
├── State.elm
└── Tetromino.elm
├── Part2
├── Part2.zip
└── Block.elm
├── Part3
├── Part3.zip
├── Block.elm
└── Tetromino.elm
├── Part4
├── Part4.zip
├── Block.elm
└── Tetromino.elm
├── Part5
├── Part5.zip
├── Block.elm
└── Tetromino.elm
├── Part6
├── Part6.zip
├── Block.elm
├── Controller.elm
└── Tetromino.elm
├── Part7
├── Part7.zip
├── Block.elm
├── Controller.elm
├── State.elm
└── Tetromino.elm
├── Part8
├── Part8.zip
├── Block.elm
├── Controller.elm
├── State.elm
└── Tetromino.elm
├── Part9
├── Part9.zip
├── Block.elm
├── Controller.elm
└── State.elm
├── Part11
├── Part11.zip
├── Block.elm
├── Controller.elm
├── State.elm
├── Board.elm
└── Tetromino.elm
├── Part12
├── Part12.zip
├── Block.elm
├── Controller.elm
├── State.elm
├── Board.elm
└── Tetromino.elm
├── Part13
├── Part13.zip
├── Block.elm
├── Controller.elm
├── State.elm
├── Board.elm
└── Tetromino.elm
├── Part14
├── Part14.zip
├── Block.elm
├── Controller.elm
├── State.elm
└── Board.elm
├── Part15
├── Part15.zip
├── Block.elm
├── Controller.elm
└── Board.elm
├── Block.elm
├── Board.elm
└── Tetromino.elm
/New Document.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # captaincodertest
2 |
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | www.captaincoder.net
--------------------------------------------------------------------------------
/WeatherApp/README.md:
--------------------------------------------------------------------------------
1 | # captaincoder
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/package-list:
--------------------------------------------------------------------------------
1 | application
2 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/package-list:
--------------------------------------------------------------------------------
1 | application
2 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/.#Controller.elm:
--------------------------------------------------------------------------------
1 | jcollard@clark.11288:1455561102
--------------------------------------------------------------------------------
/TetrisElm/Part2/Part2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part2/Part2.zip
--------------------------------------------------------------------------------
/TetrisElm/Part3/Part3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part3/Part3.zip
--------------------------------------------------------------------------------
/TetrisElm/Part4/Part4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part4/Part4.zip
--------------------------------------------------------------------------------
/TetrisElm/Part5/Part5.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part5/Part5.zip
--------------------------------------------------------------------------------
/TetrisElm/Part6/Part6.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part6/Part6.zip
--------------------------------------------------------------------------------
/TetrisElm/Part7/Part7.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part7/Part7.zip
--------------------------------------------------------------------------------
/TetrisElm/Part8/Part8.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part8/Part8.zip
--------------------------------------------------------------------------------
/TetrisElm/Part9/Part9.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part9/Part9.zip
--------------------------------------------------------------------------------
/TetrisElm/Part10/Part10.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part10/Part10.zip
--------------------------------------------------------------------------------
/TetrisElm/Part11/Part11.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part11/Part11.zip
--------------------------------------------------------------------------------
/TetrisElm/Part12/Part12.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part12/Part12.zip
--------------------------------------------------------------------------------
/TetrisElm/Part13/Part13.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part13/Part13.zip
--------------------------------------------------------------------------------
/TetrisElm/Part14/Part14.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part14/Part14.zip
--------------------------------------------------------------------------------
/TetrisElm/Part15/Part15.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/TetrisElm/Part15/Part15.zip
--------------------------------------------------------------------------------
/WeatherApp/complete/html.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/html.zip
--------------------------------------------------------------------------------
/WeatherApp/imgs/humidity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/humidity.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/200.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/201.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/201.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/202.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/202.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/210.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/210.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/211.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/211.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/212.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/212.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/221.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/221.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/230.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/230.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/231.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/231.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/232.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/232.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/300.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/300.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/301.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/301.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/302.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/302.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/310.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/310.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/311.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/311.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/312.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/312.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/313.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/313.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/314.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/314.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/321.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/321.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/500.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/501.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/501.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/502.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/502.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/503.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/503.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/504.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/504.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/511.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/511.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/520.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/520.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/521.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/521.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/522.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/522.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/531.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/531.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/600.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/600.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/601.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/601.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/602.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/602.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/603.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/603.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/611.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/611.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/612.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/612.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/615.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/615.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/616.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/616.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/620.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/620.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/621.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/621.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/622.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/622.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/701.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/701.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/711.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/711.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/721.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/721.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/731.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/731.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/741.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/741.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/751.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/751.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/761.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/761.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/762.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/762.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/771.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/771.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/781.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/781.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/800.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/800.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/801.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/801.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/803.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/803.png
--------------------------------------------------------------------------------
/WeatherApp/imgs/codes/804.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/imgs/codes/804.png
--------------------------------------------------------------------------------
/WeatherApp/WeatherAppStarter.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/WeatherAppStarter.zip
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/sudoku-tutorial.zip
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/200.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/201.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/201.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/202.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/202.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/210.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/210.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/211.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/211.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/212.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/212.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/221.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/221.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/230.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/230.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/231.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/231.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/232.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/232.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/300.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/300.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/301.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/301.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/302.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/302.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/310.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/310.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/311.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/311.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/312.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/312.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/313.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/313.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/314.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/314.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/321.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/321.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/500.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/501.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/501.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/502.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/502.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/503.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/503.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/504.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/504.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/511.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/511.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/520.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/520.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/521.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/521.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/522.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/522.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/531.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/531.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/600.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/600.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/601.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/601.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/602.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/602.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/603.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/603.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/611.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/611.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/612.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/612.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/615.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/615.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/616.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/616.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/620.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/620.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/621.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/621.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/622.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/622.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/701.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/701.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/711.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/711.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/721.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/721.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/731.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/731.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/741.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/741.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/751.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/751.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/761.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/761.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/762.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/762.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/771.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/771.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/781.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/781.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/800.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/800.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/801.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/801.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/803.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/803.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/codes/804.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/codes/804.png
--------------------------------------------------------------------------------
/WeatherApp/complete/imgs/humidity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/imgs/humidity.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/7qEWLHs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/7qEWLHs.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/EDakzfE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/EDakzfE.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/EdobWTw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/EdobWTw.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/HM2Hm8F.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/HM2Hm8F.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/Og7iwSG.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/Og7iwSG.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/QnNXidl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/QnNXidl.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/UpXVYuT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/UpXVYuT.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/VJReJUB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/VJReJUB.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/VgIs8mV.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/VgIs8mV.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/aPrt9Wh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/aPrt9Wh.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/kWnIoVh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/kWnIoVh.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/nJfgXaC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/nJfgXaC.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/reiNKak.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/reiNKak.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/v46MmtA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/v46MmtA.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/xFXYxzy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/xFXYxzy.png
--------------------------------------------------------------------------------
/Java/sudoku-javafx/tutorial_img/yMnWaHK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/tutorial_img/yMnWaHK.png
--------------------------------------------------------------------------------
/WeatherApp/complete/WeatherAppComplete.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/WeatherApp/complete/WeatherAppComplete.zip
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/sudoku-tutorial/bin/application/Main.class
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/sudoku-tutorial/bin/application/Controller.class
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/GameBoard.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/sudoku-tutorial/bin/application/GameBoard.class
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/Controller$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcollard/captaincoder/HEAD/Java/sudoku-javafx/sudoku-tutorial/bin/application/Controller$1.class
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/build.fxbuild:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part11/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part12/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part13/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part14/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part15/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part2/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part3/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part4/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part5/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part6/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part7/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part8/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part9/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (..)
7 |
8 | type alias Block = { color : Color }
9 |
10 | {- The length of the edges of each block -}
11 | size : Float
12 | size = 25
13 |
14 | {- Given a Block, converts it to a Form. -}
15 | toForm : Block -> Form
16 | toForm block =
17 | let shape = square size
18 | border = outlined (solid Color.black) shape
19 | in group [filled block.color shape, border]
20 |
21 | main : Element
22 | main = collage 400 400 [toForm (Block Color.blue)]
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TetrisElm/Part6/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 |
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int)
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs = Signal.map arrowsToInput arrows
20 |
21 | main : Signal Element
22 | main = Signal.map show inputs
23 |
--------------------------------------------------------------------------------
/TetrisElm/Part7/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 |
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int)
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs = Signal.map arrowsToInput arrows
20 |
21 | main : Signal Element
22 | main = Signal.map show inputs
23 |
--------------------------------------------------------------------------------
/TetrisElm/Block.elm:
--------------------------------------------------------------------------------
1 | module Block where
2 |
3 | import Basics exposing (..)
4 | import Color exposing (Color)
5 | import Color as Color
6 |
7 | import Graphics.Element exposing (Element)
8 | import Graphics.Element as Element
9 |
10 | import Graphics.Collage exposing (Form)
11 | import Graphics.Collage as Collage
12 |
13 | type alias Block = { color : Color }
14 |
15 | width : Float
16 | width = 25
17 |
18 | height : Float
19 | height = 25
20 |
21 | toForm : Block -> Form
22 | toForm block =
23 | let shape = Collage.rect width height
24 | in Collage.group [ Collage.filled block.color shape
25 | , Collage.outlined (Collage.solid Color.black) shape
26 | ]
27 |
28 | main : Element
29 | main = Collage.collage 400 400
30 | [(toForm (Block Color.green))]
31 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part11/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part12/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part13/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part14/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part15/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part8/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/TetrisElm/Part9/Controller.elm:
--------------------------------------------------------------------------------
1 | module Controller where
2 |
3 | import Basics exposing (..)
4 | import Graphics.Element exposing (Element, show)
5 | import Keyboard exposing (arrows)
6 | import Signal exposing (Signal)
7 | import Time exposing (Time, fps)
8 |
9 | {- The various inputs that change the State of a Tetris Game. -}
10 | type Input = Rotate | Shift (Int, Int) | Tick Time
11 |
12 | {- Converts a Record produced by Keyboard.arrows into an Input -}
13 | arrowsToInput : { x : Int, y : Int } -> Input
14 | arrowsToInput {x, y} =
15 | if (y == 1) then Rotate else Shift (y, x)
16 |
17 | {- A Signal of Inputs -}
18 | inputs : Signal Input
19 | inputs =
20 | let ticks = Signal.map Tick (fps 30)
21 | keys = Signal.map arrowsToInput arrows
22 | in Signal.merge ticks keys
23 |
24 | main : Signal Element
25 | main = Signal.map show inputs
26 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/application.css:
--------------------------------------------------------------------------------
1 | /* Class definition for the base pane */
2 |
3 | .base_pane { /*using the base_pane class selector will style our pane */
4 |
5 | /*changes the background color of our pane to
6 | * dark blue, color code is in hexadecimal */
7 | -fx-background-color: #34495e;
8 |
9 | }
10 |
11 | .button { /*using the button class selector will style all nine buttons that carry it */
12 |
13 | /*changes the background color of our buttons to
14 | * light gray, color code is in hexadecimal */
15 | -fx-background-color: #bdc3c7;
16 |
17 | }
18 |
19 | .button:hover { /*using the button class selector with the hover state will
20 | * define the style of all nine buttons when hovered over with the cursor */
21 |
22 | /*changes the background color of our buttons to
23 | * soft white, color code is in hexadecimal */
24 | -fx-background-color: #ecf0f1;
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/src/application/application.css:
--------------------------------------------------------------------------------
1 | /* Class definition for the base pane */
2 |
3 | .base_pane { /*using the base_pane class selector will style our pane */
4 |
5 | /*changes the background color of our pane to
6 | * dark blue, color code is in hexadecimal */
7 | -fx-background-color: #34495e;
8 |
9 | }
10 |
11 | .button { /*using the button class selector will style all nine buttons that carry it */
12 |
13 | /*changes the background color of our buttons to
14 | * light gray, color code is in hexadecimal */
15 | -fx-background-color: #bdc3c7;
16 |
17 | }
18 |
19 | .button:hover { /*using the button class selector with the hover state will
20 | * define the style of all nine buttons when hovered over with the cursor */
21 |
22 | /*changes the background color of our buttons to
23 | * soft white, color code is in hexadecimal */
24 | -fx-background-color: #ecf0f1;
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + " ";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WeatherApp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Weather App
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
0 °
12 |
Unknown
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
0 %
24 |
25 |
26 |
27 | 0 mph N
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + " ";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WeatherApp/complete/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Weather App
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
0 °
12 |
Unknown
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
0 %
24 |
25 |
26 |
27 | 0 mph N
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/application/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | application
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/application/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | application
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WeatherApp/styles.css:
--------------------------------------------------------------------------------
1 | .weather-app {
2 | margin: auto;
3 | width: 300px;
4 | height: 160px;
5 | border: 1px solid black;
6 | border-radius: 20px;
7 | box-shadow: 10px 10px 50px #888888;
8 | overflow: hidden;
9 | text-align:center;
10 | font-family: "Mono";
11 | }
12 |
13 | .left {
14 | float: left;
15 | background: #262626;
16 | padding:10px;
17 | width:150px;
18 | height:100%;
19 | color:white;
20 | }
21 |
22 | .temperature {
23 | margin-top:30px;
24 | margin-bottom:5px;
25 | font-size:32px;
26 | font-weight: bold;
27 | width: 150px;
28 | }
29 |
30 | .location {
31 | font-size: 18px;
32 | width:100%;
33 | width:150px;
34 | }
35 |
36 | .right {
37 | float: right;
38 | width:130px;
39 | height:100%;
40 | }
41 |
42 | .top {
43 | height: 100px;
44 | width: 100%;
45 | margin: auto;
46 | background: #cec;
47 | }
48 |
49 | .top img {
50 | margin-top: 15px;
51 | }
52 |
53 | .bottom {
54 | height: 70px;
55 | background: #669999;
56 | color: white;
57 | font-weight: bold;
58 | }
59 |
60 | .humidity {
61 | padding: 8px;
62 | }
63 |
64 | .wind {
65 | }
66 |
--------------------------------------------------------------------------------
/WeatherApp/complete/styles.css:
--------------------------------------------------------------------------------
1 | .weather-app {
2 | margin: auto;
3 | width: 300px;
4 | height: 160px;
5 | border: 1px solid black;
6 | border-radius: 20px;
7 | box-shadow: 10px 10px 50px #888888;
8 | overflow: hidden;
9 | text-align:center;
10 | font-family: "Mono";
11 | }
12 |
13 | .left {
14 | float: left;
15 | background: #262626;
16 | padding:10px;
17 | width:150px;
18 | height:100%;
19 | color:white;
20 | }
21 |
22 | .temperature {
23 | margin-top:30px;
24 | margin-bottom:5px;
25 | font-size:32px;
26 | font-weight: bold;
27 | width: 150px;
28 | }
29 |
30 | .location {
31 | font-size: 18px;
32 | width:100%;
33 | width:150px;
34 | }
35 |
36 | .right {
37 | float: right;
38 | width:130px;
39 | height:100%;
40 | }
41 |
42 | .top {
43 | height: 100px;
44 | width: 100%;
45 | margin: auto;
46 | background: #cec;
47 | }
48 |
49 | .top img {
50 | margin-top: 15px;
51 | }
52 |
53 | .bottom {
54 | height: 70px;
55 | background: #669999;
56 | color: white;
57 | font-weight: bold;
58 | }
59 |
60 | .humidity {
61 | padding: 8px;
62 | }
63 |
64 | .wind {
65 | }
66 |
--------------------------------------------------------------------------------
/TetrisElm/Part7/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 |
10 |
11 | {- A Record describing the state of our game -}
12 | type alias State = { falling : Tetromino }
13 |
14 | {- Our default starting state -}
15 | defaultState : State
16 | defaultState = { falling = Tetromino.j }
17 |
18 | {- Given a state, create an Element that can be rendered to the screen. -}
19 | view : State -> Element
20 | view state =
21 | let
22 | screenWidth = 800
23 | screenHeight = 600
24 | fallingForm = Tetromino.toForm state.falling
25 | in collage screenWidth screenHeight [fallingForm]
26 |
27 | {- Given an Input and a State, produce the State that is a result of
28 | the input on the previous state. -}
29 | update : Input -> State -> State
30 | update input state =
31 | case input of
32 | Rotate -> { state | falling = Tetromino.rotate state.falling }
33 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
34 |
35 | {- A Signal of states for our Game -}
36 | states : Signal State
37 | states = Signal.foldp update defaultState inputs
38 |
39 | main : Signal Element
40 | main = Signal.map view states
41 |
--------------------------------------------------------------------------------
/TetrisElm/Part8/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 |
10 |
11 | {- A Record describing the state of our game -}
12 | type alias State = { falling : Tetromino }
13 |
14 | {- Our default starting state -}
15 | defaultState : State
16 | defaultState = { falling = Tetromino.j }
17 |
18 | {- Given a state, create an Element that can be rendered to the screen. -}
19 | view : State -> Element
20 | view state =
21 | let
22 | screenWidth = 800
23 | screenHeight = 600
24 | fallingForm = Tetromino.toForm state.falling
25 | in collage screenWidth screenHeight [fallingForm]
26 |
27 | {- Given an Input and a State, produce the State that is a result of
28 | the input on the previous state. -}
29 | update : Input -> State -> State
30 | update input state =
31 | case input of
32 | Rotate -> { state | falling = Tetromino.rotate state.falling }
33 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
34 |
35 | {- A Signal of states for our Game -}
36 | states : Signal State
37 | states = Signal.foldp update defaultState inputs
38 |
39 | main : Signal Element
40 | main = Signal.map view states
41 |
--------------------------------------------------------------------------------
/TetrisElm/Part3/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | }
18 |
19 | {- Converts a Tetromino to a Form that can be rendered -}
20 | toForm : Tetromino -> Form
21 | toForm { shape, block } =
22 | let form = Block.toForm block
23 | translate (row, col) = move ((toFloat col) * Block.size,
24 | (toFloat row) * Block.size) form
25 | forms = List.map translate shape
26 | in group forms
27 |
28 | i : Tetromino
29 | i = { shape = [ ( 1, 0)
30 | , ( 0, 0)
31 | , (-1, 0)
32 | , (-2, 0)]
33 | , block = Block Color.lightBlue
34 | }
35 |
36 | j : Tetromino
37 | j = { shape = [ ( 1, 0),
38 | ( 0, 0),
39 | (-1, -1), (-1, 0)
40 | ]
41 | , block = Block Color.blue
42 | }
43 |
44 | tetromino = j
45 |
46 | main : Element
47 | main = collage 400 400 [toForm tetromino]
48 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Tetromino exposing (Tetromino, Location)
8 |
9 | type alias Board = Dict Location Block
10 |
11 | new : List (Location, Block) -> Board
12 | new = Dict.fromList
13 |
14 | cols : Int
15 | cols = 10
16 |
17 | rows : Int
18 | rows = 20
19 |
20 | background : Form
21 | background =
22 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
23 | border = outlined (solid Color.black) shape --Added later
24 | in group [border, filled Color.black shape]
25 |
26 | addBlock : Location -> Block -> Form -> Form
27 | addBlock (row, col) block form =
28 | let
29 | offSetX = -(toFloat (cols - 1) * Block.size)/2
30 | offSetY = -(toFloat (rows - 1) * Block.size)/2
31 | x = toFloat col * Block.size
32 | y = toFloat row * Block.size
33 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
34 | in group [form, blockForm]
35 |
36 | toForm : Board -> Form
37 | toForm board = Dict.foldr addBlock background board
38 |
39 | testBoard : Board
40 | testBoard = new [ ( (0,0), Block Color.blue )
41 | , ( (0,1), Block Color.yellow )
42 | , ( (1,0), Block Color.red )
43 | , ( (1,1), Block Color.green )
44 | ]
45 |
46 |
47 | main = collage 600 600 [toForm testBoard]
48 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/src/application/Main.java:
--------------------------------------------------------------------------------
1 | package application;
2 |
3 | import javafx.application.Application;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.stage.Stage;
6 | import javafx.scene.Parent;
7 | import javafx.scene.Scene;
8 |
9 | /***
10 | * The application class; handles inflating the layout and launching itself.
11 | *
12 | * @author Captain Coder
13 | * @version 1
14 | * @see Application
15 | * @see FXMLLoader
16 | * @see Scene
17 | * @see Stage
18 | */
19 | public class Main extends Application {
20 | @Override
21 | /* modify the method declaration to throw generic Exception (in case any of the steps fail) */
22 | public void start(Stage primaryStage) throws Exception {
23 |
24 | /* load layout.fxml from file and assign it to a scene root object */
25 | Parent root = FXMLLoader.load(getClass().getResource("layout.fxml"));
26 |
27 | /* assign the root to a new scene and define its dimensions */
28 | Scene scene = new Scene(root, 720, 480);
29 |
30 | /* set the title of the stage (window) */
31 | primaryStage.setTitle("Sudoku");
32 | /* set the scene of the stage to our newly created from the layout scene */
33 | primaryStage.setScene(scene);
34 | /* show the stage */
35 | primaryStage.show();
36 | }
37 |
38 | /***
39 | *
40 | * @param args to configure launch with
41 | */
42 | public static void main(String[] args) {
43 | launch(args);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/links/GameBoard.java:
--------------------------------------------------------------------------------
1 | package application;
2 |
3 | public class GameBoard {
4 |
5 | /* Array that will contain the complete solution to the board */
6 | private int[][] solution;
7 | /* Array that will contain ONLY the numbers initially drawn on the board and that the player can't change */
8 | private int[][] initial;
9 | /* Array that will contain player's numbers */
10 | private int[][] player;
11 |
12 | public GameBoard() {
13 | solution = new int[][]
14 | {
15 | {5,3,8,4,6,1,7,9,2},
16 | {6,9,7,3,2,5,8,1,4},
17 | {2,1,4,7,8,9,5,6,3},
18 | {9,4,1,2,7,8,6,3,5},
19 | {7,6,2,1,5,3,9,4,8},
20 | {8,5,3,9,4,6,1,2,7},
21 | {3,8,9,5,1,2,4,7,6},
22 | {4,2,6,8,9,7,3,5,1},
23 | {1,7,5,6,3,4,2,8,9}
24 | };
25 |
26 | // 0's will be rendered as empty space and will be editable by player
27 | initial = new int[][]
28 | {
29 | {0,0,0,4,0,0,0,9,0},
30 | {6,0,7,0,0,0,8,0,4},
31 | {0,1,0,7,0,9,0,0,3},
32 | {9,0,1,0,7,0,0,3,0},
33 | {0,0,2,0,0,0,9,0,0},
34 | {0,5,0,0,4,0,1,0,7},
35 | {3,0,0,5,0,2,0,7,0},
36 | {4,0,6,0,0,0,3,0,1},
37 | {0,7,0,0,0,4,0,0,0}
38 | };
39 |
40 | // player's array is initialized as a 9x9 full of zeroes
41 | player = new int[9][9];
42 | }
43 |
44 | // returns the solution array
45 | public int[][] getSolution() {
46 | return solution;
47 | }
48 |
49 | // returns the initial filled-in numbers array
50 | public int[][] getInitial() {
51 | return initial;
52 | }
53 |
54 | // returns the player array
55 | public int[][] getPlayer() {
56 | return player;
57 | }
58 |
59 | // modifies a value in the player array
60 | public void modifyPlayer(int val, int row, int col) {
61 | if(val >=0 && val <= 9) // only values from 0 to 9 inclusive are permitted
62 | player[row][col] = val;
63 | else // print out an error message
64 | System.out.println("Value passed to player falls out of range");
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/TetrisElm/Part9/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 | import Time exposing (Time)
10 |
11 |
12 | {- A Record describing the state of our game -}
13 | type alias State = { falling : Tetromino
14 | , time : Time
15 | , nextShift : Time
16 | , shiftDelay : Time
17 | }
18 |
19 | {- Our default starting state -}
20 | defaultState : State
21 | defaultState = { falling = Tetromino.j
22 | , time = 0
23 | , nextShift = Time.second
24 | , shiftDelay = Time.second
25 | }
26 |
27 | {- Given a state, create an Element that can be rendered to the screen. -}
28 | view : State -> Element
29 | view state =
30 | let
31 | screenWidth = 800
32 | screenHeight = 600
33 | fallingForm = Tetromino.toForm state.falling
34 | in collage screenWidth screenHeight [fallingForm]
35 |
36 | checkTick : State -> State
37 | checkTick state =
38 | if (state.time < state.nextShift) then state
39 | else { state | falling = Tetromino.shift (-1, 0) state.falling
40 | , nextShift = state.time + state.shiftDelay
41 | }
42 |
43 | {- Given an Input and a State, produce the State that is a result of
44 | the input on the previous state. -}
45 | update : Input -> State -> State
46 | update input state =
47 | case input of
48 | Rotate -> { state | falling = Tetromino.rotate state.falling }
49 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
50 | Tick delta -> checkTick { state | time = state.time + delta }
51 |
52 | {- A Signal of states for our Game -}
53 | states : Signal State
54 | states = Signal.foldp update defaultState inputs
55 |
56 | main : Signal Element
57 | main = Signal.map view states
58 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 | import Time exposing (Time)
10 |
11 |
12 | {- A Record describing the state of our game -}
13 | type alias State = { falling : Tetromino
14 | , time : Time
15 | , nextShift : Time
16 | , shiftDelay : Time
17 | }
18 |
19 | {- Our default starting state -}
20 | defaultState : State
21 | defaultState = { falling = Tetromino.j
22 | , time = 0
23 | , nextShift = Time.second
24 | , shiftDelay = Time.second
25 | }
26 |
27 | {- Given a state, create an Element that can be rendered to the screen. -}
28 | view : State -> Element
29 | view state =
30 | let
31 | screenWidth = 800
32 | screenHeight = 600
33 | fallingForm = Tetromino.toForm state.falling
34 | in collage screenWidth screenHeight [fallingForm]
35 |
36 | {- Checks to see if it is time to move the Tetromino down. -}
37 | checkTick : State -> State
38 | checkTick state =
39 | if (state.time < state.nextShift) then state
40 | else { state | falling = Tetromino.shift (-1, 0) state.falling
41 | , nextShift = state.time + state.shiftDelay
42 | }
43 |
44 | {- Given an Input and a State, produce the State that is a result of
45 | the input on the previous state. -}
46 | update : Input -> State -> State
47 | update input state =
48 | case input of
49 | Rotate -> { state | falling = Tetromino.rotate state.falling }
50 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
51 | Tick delta -> checkTick { state | time = state.time + delta }
52 |
53 | {- A Signal of states for our Game -}
54 | states : Signal State
55 | states = Signal.foldp update defaultState inputs
56 |
57 | main : Signal Element
58 | main = Signal.map view states
59 |
--------------------------------------------------------------------------------
/TetrisElm/Part11/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 | import Time exposing (Time)
10 |
11 |
12 | {- A Record describing the state of our game -}
13 | type alias State = { falling : Tetromino
14 | , time : Time
15 | , nextShift : Time
16 | , shiftDelay : Time
17 | }
18 |
19 | {- Our default starting state -}
20 | defaultState : State
21 | defaultState = { falling = Tetromino.j
22 | , time = 0
23 | , nextShift = Time.second
24 | , shiftDelay = Time.second
25 | }
26 |
27 | {- Given a state, create an Element that can be rendered to the screen. -}
28 | view : State -> Element
29 | view state =
30 | let
31 | screenWidth = 800
32 | screenHeight = 600
33 | fallingForm = Tetromino.toForm state.falling
34 | in collage screenWidth screenHeight [fallingForm]
35 |
36 | {- Checks to see if it is time to move the Tetromino down. -}
37 | checkTick : State -> State
38 | checkTick state =
39 | if (state.time < state.nextShift) then state
40 | else { state | falling = Tetromino.shift (-1, 0) state.falling
41 | , nextShift = state.time + state.shiftDelay
42 | }
43 |
44 | {- Given an Input and a State, produce the State that is a result of
45 | the input on the previous state. -}
46 | update : Input -> State -> State
47 | update input state =
48 | case input of
49 | Rotate -> { state | falling = Tetromino.rotate state.falling }
50 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
51 | Tick delta -> checkTick { state | time = state.time + delta }
52 |
53 | {- A Signal of states for our Game -}
54 | states : Signal State
55 | states = Signal.foldp update defaultState inputs
56 |
57 | main : Signal Element
58 | main = Signal.map view states
59 |
--------------------------------------------------------------------------------
/TetrisElm/Part12/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Controller exposing (..)
5 | import Graphics.Collage exposing (..)
6 | import Graphics.Element exposing (Element)
7 | import Signal
8 | import Tetromino exposing (Tetromino)
9 | import Time exposing (Time)
10 |
11 |
12 | {- A Record describing the state of our game -}
13 | type alias State = { falling : Tetromino
14 | , time : Time
15 | , nextShift : Time
16 | , shiftDelay : Time
17 | }
18 |
19 | {- Our default starting state -}
20 | defaultState : State
21 | defaultState = { falling = Tetromino.j
22 | , time = 0
23 | , nextShift = Time.second
24 | , shiftDelay = Time.second
25 | }
26 |
27 | {- Given a state, create an Element that can be rendered to the screen. -}
28 | view : State -> Element
29 | view state =
30 | let
31 | screenWidth = 800
32 | screenHeight = 600
33 | fallingForm = Tetromino.toForm state.falling
34 | in collage screenWidth screenHeight [fallingForm]
35 |
36 | {- Checks to see if it is time to move the Tetromino down. -}
37 | checkTick : State -> State
38 | checkTick state =
39 | if (state.time < state.nextShift) then state
40 | else { state | falling = Tetromino.shift (-1, 0) state.falling
41 | , nextShift = state.time + state.shiftDelay
42 | }
43 |
44 | {- Given an Input and a State, produce the State that is a result of
45 | the input on the previous state. -}
46 | update : Input -> State -> State
47 | update input state =
48 | case input of
49 | Rotate -> { state | falling = Tetromino.rotate state.falling }
50 | Shift amount -> { state | falling = Tetromino.shift amount state.falling }
51 | Tick delta -> checkTick { state | time = state.time + delta }
52 |
53 | {- A Signal of states for our Game -}
54 | states : Signal State
55 | states = Signal.foldp update defaultState inputs
56 |
57 | main : Signal Element
58 | main = Signal.map view states
59 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/bin/application/layout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/sudoku-tutorial/src/application/layout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/TetrisElm/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Basics exposing (..)
4 |
5 | import Block exposing (Block)
6 | import Block as Block
7 |
8 | import Color exposing (Color)
9 | import Color as Color
10 |
11 | import Dict exposing (Dict)
12 | import Dict as Dict
13 |
14 | import Graphics.Collage exposing (Form)
15 | import Graphics.Collage as Collage
16 |
17 | import Graphics.Element exposing (Element)
18 | import Graphics.Element as Element
19 |
20 | import List as List
21 |
22 | import Tetromino exposing (Tetromino)
23 |
24 | type alias Location = (Int, Int)
25 | type alias Board = Dict Location Block
26 |
27 | rows : Int
28 | rows = 20
29 |
30 | cols : Int
31 | cols = 10
32 |
33 | new : List (Location, Block) -> Board
34 | new blocks = Dict.fromList blocks
35 |
36 | isOccupied : Location -> Board -> Bool
37 | isOccupied loc board = Dict.member loc board
38 |
39 | add : Tetromino -> Board -> Board
40 | add tetromino board =
41 | let helper location board = Dict.insert location tetromino.block board
42 | in List.foldr helper board tetromino.shape
43 |
44 | toFormHelper : (Int, Int) -> Block -> List Form -> List Form
45 | toFormHelper (row, col) block forms =
46 | let form = Block.toForm block
47 | moved = Collage.move ( (toFloat col) * Block.height
48 | , (toFloat row) * Block.width ) form
49 | in moved :: forms
50 |
51 |
52 | toForm : Board -> Form
53 | toForm board =
54 | let blockOffset = (-(toFloat (cols - 1)) * Block.height/2
55 | ,-(toFloat (rows - 1))*Block.width/2)
56 | blocks = Dict.foldr toFormHelper [] board |>
57 | Collage.group |>
58 | Collage.move blockOffset
59 | bgShape = Collage.rect ((toFloat cols) * Block.height)
60 | ((toFloat rows) * Block.width)
61 |
62 | background = Collage.filled Color.black bgShape
63 | outline = Collage.outlined (Collage.solid Color.black) bgShape
64 | in Collage.group [background, blocks, outline]
65 |
66 | testBoard : Board
67 | testBoard = new [ ( (0, 0), Block Color.yellow )
68 | , ( (0, 1), Block Color.red )
69 | , ( (1, 0), Block Color.blue )
70 | ]
71 |
72 | main : Element
73 | main = Collage.collage 800 600 [toForm testBoard]
74 |
--------------------------------------------------------------------------------
/TetrisElm/Part4/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | {- Converts a Tetromino to a Form that can be rendered -}
45 | toForm : Tetromino -> Form
46 | toForm { shape, block } =
47 | let form = Block.toForm block
48 | translate (row, col) = move ((toFloat col) * Block.size,
49 | (toFloat row) * Block.size) form
50 | forms = List.map translate shape
51 | in group forms
52 |
53 | {- Takes a Tetromino and produces a dot at its pivot point -}
54 | drawPivot : Tetromino -> Form
55 | drawPivot { pivot } =
56 | let dot = circle 5 |> filled Color.black
57 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
58 | in translate dot
59 |
60 | {- Given a Location, rotates it around a pivot some number of degrees. -}
61 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
62 | rotateLocation pivot angle (row, col) =
63 | let rowOrigin = (toFloat row) - pivot.r
64 | colOrigin = (toFloat col) - pivot.c
65 | (s, c) = (sin(angle), cos(angle))
66 | rowRotated = rowOrigin * c - colOrigin * s
67 | colRotated = rowOrigin * s + colOrigin * c
68 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
69 |
70 | {- Rotates a Tetromino 90 degrees -}
71 | rotate : Tetromino -> Tetromino
72 | rotate tetromino =
73 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
74 | newShape = List.map rotateHelper tetromino.shape
75 | in { tetromino | shape = newShape
76 | , rows = tetromino.cols
77 | , cols = tetromino.rows
78 | }
79 |
80 | tetromino = rotate i
81 |
82 | main : Element
83 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
84 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Generated Documentation (Untitled)
7 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | JavaScript is disabled on your browser.
67 |
68 | Frame Alert
69 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version .
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Generated Documentation (Untitled)
7 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | JavaScript is disabled on your browser.
67 |
68 | Frame Alert
69 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version .
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/WeatherApp/complete/app.js:
--------------------------------------------------------------------------------
1 | var APPID = "d2ace650b4df41f6d5f1ea94fc08da75";
2 | var temp;
3 | var loc;
4 | var icon;
5 | var humidity;
6 | var wind;
7 | var direction;
8 |
9 | function update(weather) {
10 | icon.src = "imgs/codes/" + weather.code + ".png"
11 | humidity.innerHTML = weather.humidity;
12 | wind.innerHtml = weather.wind;
13 | direction.innerHTML = weather.direction;
14 | loc.innerHTML = weather.location;
15 | temp.innerHTML = weather.temp;
16 | }
17 |
18 | window.onload = function () {
19 | temp = document.getElementById("temperature");
20 | loc = document.getElementById("location");
21 | icon = document.getElementById("icon");
22 | humidity = document.getElementById("humidity");
23 | wind = document.getElementById("wind");
24 | direction = document.getElementById("direction");
25 |
26 | /* NEW */
27 | if(navigator.geolocation){
28 | var showPosition = function(position){
29 | updateByGeo(position.coords.latitude, position.coords.longitude);
30 | }
31 | navigator.geolocation.getCurrentPosition(showPosition);
32 | } else {
33 | var zip = window.prompt("Could not discover your location. What is your zip code?");
34 | updateByZip(zip);
35 | }
36 |
37 | }
38 |
39 | /* NEW */
40 |
41 | function updateByGeo(lat, lon){
42 | var url = "http://api.openweathermap.org/data/2.5/weather?" +
43 | "lat=" + lat +
44 | "&lon=" + lon +
45 | "&APPID=" + APPID;
46 | sendRequest(url);
47 | }
48 |
49 |
50 | function updateByZip(zip){
51 | var url = "http://api.openweathermap.org/data/2.5/weather?" +
52 | "zip=" + zip +
53 | "&APPID=" + APPID;
54 | sendRequest(url);
55 | }
56 |
57 |
58 | function sendRequest(url){
59 | var xmlhttp = new XMLHttpRequest();
60 | xmlhttp.onreadystatechange = function() {
61 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
62 | var data = JSON.parse(xmlhttp.responseText);
63 | var weather = {};
64 | weather.code = data.weather[0].id;
65 | weather.humidity = data.main.humidity;
66 | weather.wind = data.wind.speed;
67 | /* NEW */
68 | weather.direction = degreesToDirection(data.wind.deg)
69 | weather.location = data.name;
70 | /* NEW */
71 | weather.temp = K2F(data.main.temp);
72 | update(weather);
73 | }
74 | };
75 |
76 | xmlhttp.open("GET", url, true);
77 | xmlhttp.send();
78 | }
79 |
80 | function degreesToDirection(degrees){
81 | var range = 360/16;
82 | var low = 360 - range/2;
83 | var high = (low + range) % 360;
84 | var angles = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"];
85 | for( i in angles ) {
86 | if(degrees >= low && degrees < high){
87 | console.log(angles[i]);
88 | return angles[i];
89 | console.log("derp");
90 | }
91 | low = (low + range) % 360;
92 | high = (high + range) % 360;
93 | }
94 | return "N";
95 |
96 | }
97 |
98 | function K2F(k){
99 | return Math.round(k*(9/5)-459.67);
100 | }
101 |
102 | function K2C(k){
103 | return Math.round(k - 273.15);
104 | }
105 |
106 |
--------------------------------------------------------------------------------
/TetrisElm/Part11/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (show)
8 | import Tetromino exposing (Tetromino, Location)
9 |
10 | type alias Board = Dict Location Block
11 |
12 | new : List (Location, Block) -> Board
13 | new = Dict.fromList
14 |
15 | {- A standard Tetris Board is 10 columns wide -}
16 | cols : Int
17 | cols = 10
18 |
19 | {- A standard Tetris Board is 20 rows tall -}
20 | rows : Int
21 | rows = 20
22 |
23 | {- A black background for our Blocks to rest on -}
24 | background : Form
25 | background =
26 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
27 | border = outlined (solid Color.black) shape --Added later
28 | in group [border, filled Color.black shape]
29 |
30 | {- Adds a block at the specified location to a form -}
31 | addBlock : Location -> Block -> Form -> Form
32 | addBlock (row, col) block form =
33 | let
34 | offSetX = -(toFloat (cols - 1) * Block.size)/2
35 | offSetY = -(toFloat (rows - 1) * Block.size)/2
36 | x = toFloat col * Block.size
37 | y = toFloat row * Block.size
38 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
39 | in group [form, blockForm]
40 |
41 | {- Given a Board, produce a form of that board on a black background -}
42 | toForm : Board -> Form
43 | toForm board = Dict.foldr addBlock background board
44 |
45 |
46 | {- Given a List, returns a List of equal length that is
47 | the cumulative sum of the values in the list.
48 | -}
49 | cumulativeSum : List Int -> List Int
50 | cumulativeSum = List.scanl (+) 0
51 |
52 | iota : Int -> List Int
53 | iota n = List.repeat (n - 1) 1 |> cumulativeSum
54 |
55 | {- Given a List, returns a List of equal length that is
56 | the cumulative sum of the values in the list.
57 | -}
58 | fillRow : Int -> Block -> Board -> Board
59 | fillRow row block board =
60 | let columns = iota cols
61 | rows = List.repeat cols row
62 | locations = List.map2 (,) rows columns
63 | blocks = List.repeat cols block
64 | filledRow = List.map2 (,) locations blocks |> new
65 | in Dict.union filledRow board
66 |
67 | {- True if the specified row is completely filled with blocks
68 | and False otherwise.
69 | -}
70 | checkRow : Int -> Board -> Bool
71 | checkRow row board =
72 | let blocks = Dict.filter (\(r,_) _ -> r == row) board
73 | in Dict.size blocks == cols
74 |
75 | {- Given a row and a board, shifts all rows above the
76 | specified row down 1 row.
77 | -}
78 | clearRow : Int -> Board -> Board
79 | clearRow row board =
80 | let shift (r, c) block newBoard =
81 | if (r < row) then (Dict.insert (r, c) block newBoard)
82 | else if (r > row) then (Dict.insert (r - 1, c) block newBoard)
83 | else newBoard
84 | in Dict.foldr shift Dict.empty board
85 |
86 | {- Given a board, produces a pair where the first value
87 | is the number of rows which were complete in that board
88 | and the second value is a new board with each of those rows
89 | cleared
90 | -}
91 | clearLines : Board -> (Int, Board)
92 | clearLines =
93 | let clearLines' row lines board =
94 | if (row >= rows) then (lines, board)
95 | else if (checkRow row board) then clearLines' row (lines + 1) (clearRow row board)
96 | else clearLines' (row + 1) lines board
97 | in clearLines' 0 0
98 |
99 | test = new [] |>
100 | fillRow 0 (Block Color.red) |>
101 | fillRow 1 (Block Color.yellow) |>
102 | fillRow 2 (Block Color.blue) |>
103 | Dict.remove (1, 0) |>
104 | clearLines |> snd
105 |
106 | main = collage 600 600 [toForm test]
107 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/deprecated-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Deprecated List
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/deprecated-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Deprecated List
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/constant-values.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Constant Field Values
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/constant-values.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Constant Field Values
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/TetrisElm/Part13/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Board exposing (Board)
5 | import Controller exposing (..)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (Element)
8 | import Signal
9 | import Tetromino exposing (Tetromino)
10 | import Time exposing (Time)
11 |
12 |
13 | {- A Record describing the state of our game -}
14 | type alias State = { falling : Tetromino
15 | , board : Board
16 | , time : Time
17 | , nextShift : Time
18 | , shiftDelay : Time
19 | }
20 | {- Spot to shift new pieces to -}
21 | startingShift : (Int, Int)
22 | startingShift = (20, 5)
23 |
24 | {- Our default starting state -}
25 | defaultState : State
26 | defaultState = { falling = Tetromino.shift startingShift Tetromino.j
27 | , board = Board.new []
28 | , time = 0
29 | , nextShift = Time.second
30 | , shiftDelay = Time.second
31 | }
32 |
33 | {- Given a state, create an Element that can be rendered to the screen. -}
34 | view : State -> Element
35 | view state =
36 | let
37 | screenWidth = 800
38 | screenHeight = 600
39 | boardForm = Board.addTetromino state.falling state.board |> Board.toForm
40 | in collage screenWidth screenHeight [boardForm]
41 |
42 | {- Checks to see if it is time to move the Tetromino down. -}
43 | checkTick : State -> State
44 | checkTick state =
45 | if (state.time < state.nextShift) then state
46 | else { state | falling = Tetromino.shift (-1, 0) state.falling
47 | , nextShift = state.time + state.shiftDelay
48 | }
49 |
50 | {- Given a current and new state, checks to see if the new state
51 | is valid. If it is, the new state is returned otherwise
52 | the current state is returned.
53 | -}
54 | useIfValid : State -> State -> State
55 | useIfValid current new =
56 | if Board.isValid new.falling new.board then new
57 | else current
58 |
59 | {- Tries to kick the nextState by the shifted amounts. The
60 | first shift that produces a valid state, is returned.
61 | If no shifts produce a valid state, the current state
62 | is returned
63 | -}
64 | tryKicks : List (Int, Int) -> State -> State -> State
65 | tryKicks shifts current nextState =
66 | case shifts of
67 | [] -> current
68 | (s :: rest) ->
69 | let shifted = Tetromino.shift s nextState.falling
70 | in if Board.isValid shifted nextState.board then { nextState | falling = shifted }
71 | else tryKicks rest current nextState
72 |
73 | {- If possible, wall kicks the nextState. Otherwise, returns
74 | the current state
75 | -}
76 | wallKick : State -> State -> State
77 | wallKick current nextState =
78 | let range = nextState.falling.cols // 2
79 | shifts = [1 .. range] |> List.concatMap (\n -> [(0, n), (0, -n)])
80 | in tryKicks shifts current nextState
81 |
82 |
83 | {- If possible, floor kicks the nextState. Otherwise, returns
84 | the current state
85 | -}
86 | floorKick : State -> State -> State
87 | floorKick current nextState =
88 | let range = nextState.falling.rows // 2
89 | shifts = [1 .. range] |> List.map (\n -> (n, 0))
90 | in tryKicks shifts current nextState
91 |
92 | {- Given an Input and a State, produce the State that is a result of
93 | the input on the previous state. -}
94 | update : Input -> State -> State
95 | update input state =
96 | let useIfValid' = useIfValid state
97 | in case input of
98 | Rotate ->
99 | let rotated = { state | falling = Tetromino.rotate state.falling }
100 | nextState = useIfValid' rotated
101 | nextState' =
102 | if nextState == state then wallKick state rotated else nextState
103 | nextState'' =
104 | if nextState' == state then floorKick state rotated else nextState'
105 | in nextState''
106 | Shift amount -> useIfValid' { state | falling = Tetromino.shift amount state.falling }
107 | Tick delta -> useIfValid' <| checkTick { state | time = state.time + delta }
108 |
109 | {- A Signal of states for our Game -}
110 | states : Signal State
111 | states = Signal.foldp update defaultState inputs
112 |
113 | main : Signal Element
114 | main = Signal.map view states
115 |
--------------------------------------------------------------------------------
/TetrisElm/Part14/State.elm:
--------------------------------------------------------------------------------
1 | module State where
2 |
3 | import Basics exposing (..)
4 | import Board exposing (Board)
5 | import Controller exposing (..)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (Element)
8 | import Signal
9 | import Tetromino exposing (Tetromino)
10 | import Time exposing (Time)
11 |
12 |
13 | {- A Record describing the state of our game -}
14 | type alias State = { falling : Tetromino
15 | , board : Board
16 | , time : Time
17 | , nextShift : Time
18 | , shiftDelay : Time
19 | }
20 | {- Spot to shift new pieces to -}
21 | startingShift : (Int, Int)
22 | startingShift = (20, 5)
23 |
24 | {- Our default starting state -}
25 | defaultState : State
26 | defaultState = { falling = Tetromino.shift startingShift Tetromino.j
27 | , board = Board.new []
28 | , time = 0
29 | , nextShift = Time.second
30 | , shiftDelay = Time.second
31 | }
32 |
33 | {- Given a state, create an Element that can be rendered to the screen. -}
34 | view : State -> Element
35 | view state =
36 | let
37 | screenWidth = 800
38 | screenHeight = 600
39 | boardForm = Board.addTetromino state.falling state.board |> Board.toForm
40 | in collage screenWidth screenHeight [boardForm]
41 |
42 | {- Checks to see if it is time to move the Tetromino down. -}
43 | checkTick : State -> State
44 | checkTick state =
45 | if (state.time < state.nextShift) then state
46 | else { state | falling = Tetromino.shift (-1, 0) state.falling
47 | , nextShift = state.time + state.shiftDelay
48 | }
49 |
50 | {- Given a current and new state, checks to see if the new state
51 | is valid. If it is, the new state is returned otherwise
52 | the current state is returned.
53 | -}
54 | useIfValid : State -> State -> State
55 | useIfValid current new =
56 | if Board.isValid new.falling new.board then new
57 | else current
58 |
59 | {- Tries to kick the nextState by the shifted amounts. The
60 | first shift that produces a valid state, is returned.
61 | If no shifts produce a valid state, the current state
62 | is returned
63 | -}
64 | tryKicks : List (Int, Int) -> State -> State -> State
65 | tryKicks shifts current nextState =
66 | case shifts of
67 | [] -> current
68 | (s :: rest) ->
69 | let shifted = Tetromino.shift s nextState.falling
70 | in if Board.isValid shifted nextState.board then { nextState | falling = shifted }
71 | else tryKicks rest current nextState
72 |
73 | {- If possible, wall kicks the nextState. Otherwise, returns
74 | the current state
75 | -}
76 | wallKick : State -> State -> State
77 | wallKick current nextState =
78 | let range = nextState.falling.cols // 2
79 | shifts = [1 .. range] |> List.concatMap (\n -> [(0, n), (0, -n)])
80 | in tryKicks shifts current nextState
81 |
82 |
83 | {- If possible, floor kicks the nextState. Otherwise, returns
84 | the current state
85 | -}
86 | floorKick : State -> State -> State
87 | floorKick current nextState =
88 | let range = nextState.falling.rows // 2
89 | shifts = [1 .. range] |> List.map (\n -> (n, 0))
90 | in tryKicks shifts current nextState
91 |
92 | {- Given an Input and a State, produce the State that is a result of
93 | the input on the previous state. -}
94 | update : Input -> State -> State
95 | update input state =
96 | let useIfValid' = useIfValid state
97 | in case input of
98 | Rotate ->
99 | let rotated = { state | falling = Tetromino.rotate state.falling }
100 | nextState = useIfValid' rotated
101 | nextState' =
102 | if nextState == state then wallKick state rotated else nextState
103 | nextState'' =
104 | if nextState' == state then floorKick state rotated else nextState'
105 | in nextState''
106 | Shift amount -> useIfValid' { state | falling = Tetromino.shift amount state.falling }
107 | Tick delta -> useIfValid' <| checkTick { state | time = state.time + delta }
108 |
109 | {- A Signal of states for our Game -}
110 | states : Signal State
111 | states = Signal.foldp update defaultState inputs
112 |
113 | main : Signal Element
114 | main = Signal.map view states
115 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/application/class-use/Main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class application.Main
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 | No usage of application.Main
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/application/class-use/Main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class application.Main
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 | No usage of application.Main
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/Java/sudoku-javafx/docs/application/class-use/Controller.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class application.Controller
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 | No usage of application.Controller
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/docs/Java/sudoku-javafx/docs/application/class-use/Controller.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class application.Controller
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 | No usage of application.Controller
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/TetrisElm/Part12/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (down, flow, show)
8 | import Tetromino exposing (Tetromino, Location)
9 |
10 | type alias Board = Dict Location Block
11 |
12 | new : List (Location, Block) -> Board
13 | new = Dict.fromList
14 |
15 | {- A standard Tetris Board is 10 columns wide -}
16 | cols : Int
17 | cols = 10
18 |
19 | {- A standard Tetris Board is 20 rows tall -}
20 | rows : Int
21 | rows = 20
22 |
23 | {- A black background for our Blocks to rest on -}
24 | background : Form
25 | background =
26 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
27 | border = outlined (solid Color.black) shape --Added later
28 | in group [border, filled Color.black shape]
29 |
30 | {- Adds a block at the specified location to a form -}
31 | addBlock : Location -> Block -> Form -> Form
32 | addBlock (row, col) block form =
33 | let
34 | offSetX = -(toFloat (cols - 1) * Block.size)/2
35 | offSetY = -(toFloat (rows - 1) * Block.size)/2
36 | x = toFloat col * Block.size
37 | y = toFloat row * Block.size
38 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
39 | in group [form, blockForm]
40 |
41 | {- Given a Board, produce a form of that board on a black background -}
42 | toForm : Board -> Form
43 | toForm board = Dict.foldr addBlock background board
44 |
45 |
46 | {- Given a List, returns a List of equal length that is
47 | the cumulative sum of the values in the list.
48 | -}
49 | cumulativeSum : List Int -> List Int
50 | cumulativeSum = List.scanl (+) 0
51 |
52 | iota : Int -> List Int
53 | iota n = List.repeat (n - 1) 1 |> cumulativeSum
54 |
55 | {- Given a List, returns a List of equal length that is
56 | the cumulative sum of the values in the list.
57 | -}
58 | fillRow : Int -> Block -> Board -> Board
59 | fillRow row block board =
60 | let columns = iota cols
61 | rows = List.repeat cols row
62 | locations = List.map2 (,) rows columns
63 | blocks = List.repeat cols block
64 | filledRow = List.map2 (,) locations blocks |> new
65 | in Dict.union filledRow board
66 |
67 | {- True if the specified row is completely filled with blocks
68 | and False otherwise.
69 | -}
70 | checkRow : Int -> Board -> Bool
71 | checkRow row board =
72 | let blocks = Dict.filter (\(r,_) _ -> r == row) board
73 | in Dict.size blocks == cols
74 |
75 | {- Given a row and a board, shifts all rows above the
76 | specified row down 1 row.
77 | -}
78 | clearRow : Int -> Board -> Board
79 | clearRow row board =
80 | let shift (r, c) block newBoard =
81 | if (r < row) then (Dict.insert (r, c) block newBoard)
82 | else if (r > row) then (Dict.insert (r - 1, c) block newBoard)
83 | else newBoard
84 | in Dict.foldr shift Dict.empty board
85 |
86 | {- Given a board, produces a pair where the first value
87 | is the number of rows which were complete in that board
88 | and the second value is a new board with each of those rows
89 | cleared
90 | -}
91 | clearLines : Board -> (Int, Board)
92 | clearLines =
93 | let clearLines' row lines board =
94 | if (row >= rows) then (lines, board)
95 | else if (checkRow row board) then clearLines' row (lines + 1) (clearRow row board)
96 | else clearLines' (row + 1) lines board
97 | in clearLines' 0 0
98 |
99 | {- Adds the specified Tetromino to a Board -}
100 | addTetromino : Tetromino -> Board -> Board
101 | addTetromino { shape, block } board =
102 | let asBoard = List.map2 (,) shape (List.repeat 4 block) |> new
103 | in Dict.union asBoard board
104 |
105 | {- Checks to see if the Tetromino is within the bounds of a board -}
106 | inBounds : Tetromino -> Bool
107 | inBounds { shape } =
108 | let checkLocation (r, c) = r >= 0 && c >= 0 && c < cols
109 | in List.all checkLocation shape
110 |
111 | {- Checks to see if the specified Tetromino intersects with any of
112 | the pieces on the Board
113 | -}
114 | isIntersecting : Tetromino -> Board -> Bool
115 | isIntersecting { shape } board =
116 | let checkLocation location = Dict.member location board
117 | in List.any checkLocation shape
118 |
119 | {- Checks to see if the Tetromino and Board are valid in a game -}
120 | isValid : Tetromino -> Board -> Bool
121 | isValid tetromino board =
122 | (inBounds tetromino) && not (isIntersecting tetromino board)
123 |
124 | tetromino = Tetromino.shift (0, 5) Tetromino.j
125 |
126 | test = new []
127 |
128 |
129 | main =
130 | flow down [ collage 600 600 [toForm (addTetromino tetromino test)]
131 | , show <| isValid tetromino test
132 | ]
133 |
--------------------------------------------------------------------------------
/TetrisElm/Part13/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (down, flow, show)
8 | import Tetromino exposing (Tetromino, Location)
9 |
10 | type alias Board = Dict Location Block
11 |
12 | new : List (Location, Block) -> Board
13 | new = Dict.fromList
14 |
15 | {- A standard Tetris Board is 10 columns wide -}
16 | cols : Int
17 | cols = 10
18 |
19 | {- A standard Tetris Board is 20 rows tall -}
20 | rows : Int
21 | rows = 20
22 |
23 | {- A black background for our Blocks to rest on -}
24 | background : Form
25 | background =
26 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
27 | border = outlined (solid Color.black) shape --Added later
28 | in group [border, filled Color.black shape]
29 |
30 | {- Adds a block at the specified location to a form -}
31 | addBlock : Location -> Block -> Form -> Form
32 | addBlock (row, col) block form =
33 | let
34 | offSetX = -(toFloat (cols - 1) * Block.size)/2
35 | offSetY = -(toFloat (rows - 1) * Block.size)/2
36 | x = toFloat col * Block.size
37 | y = toFloat row * Block.size
38 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
39 | in group [form, blockForm]
40 |
41 | {- Given a Board, produce a form of that board on a black background -}
42 | toForm : Board -> Form
43 | toForm board = Dict.foldr addBlock background board
44 |
45 |
46 | {- Given a List, returns a List of equal length that is
47 | the cumulative sum of the values in the list.
48 | -}
49 | cumulativeSum : List Int -> List Int
50 | cumulativeSum = List.scanl (+) 0
51 |
52 | iota : Int -> List Int
53 | iota n = List.repeat (n - 1) 1 |> cumulativeSum
54 |
55 | {- Given a List, returns a List of equal length that is
56 | the cumulative sum of the values in the list.
57 | -}
58 | fillRow : Int -> Block -> Board -> Board
59 | fillRow row block board =
60 | let columns = iota cols
61 | rows = List.repeat cols row
62 | locations = List.map2 (,) rows columns
63 | blocks = List.repeat cols block
64 | filledRow = List.map2 (,) locations blocks |> new
65 | in Dict.union filledRow board
66 |
67 | {- True if the specified row is completely filled with blocks
68 | and False otherwise.
69 | -}
70 | checkRow : Int -> Board -> Bool
71 | checkRow row board =
72 | let blocks = Dict.filter (\(r,_) _ -> r == row) board
73 | in Dict.size blocks == cols
74 |
75 | {- Given a row and a board, shifts all rows above the
76 | specified row down 1 row.
77 | -}
78 | clearRow : Int -> Board -> Board
79 | clearRow row board =
80 | let shift (r, c) block newBoard =
81 | if (r < row) then (Dict.insert (r, c) block newBoard)
82 | else if (r > row) then (Dict.insert (r - 1, c) block newBoard)
83 | else newBoard
84 | in Dict.foldr shift Dict.empty board
85 |
86 | {- Given a board, produces a pair where the first value
87 | is the number of rows which were complete in that board
88 | and the second value is a new board with each of those rows
89 | cleared
90 | -}
91 | clearLines : Board -> (Int, Board)
92 | clearLines =
93 | let clearLines' row lines board =
94 | if (row >= rows) then (lines, board)
95 | else if (checkRow row board) then clearLines' row (lines + 1) (clearRow row board)
96 | else clearLines' (row + 1) lines board
97 | in clearLines' 0 0
98 |
99 | {- Adds the specified Tetromino to a Board -}
100 | addTetromino : Tetromino -> Board -> Board
101 | addTetromino { shape, block } board =
102 | let asBoard = List.map2 (,) shape (List.repeat 4 block) |> new
103 | in Dict.union asBoard board
104 |
105 | {- Checks to see if the Tetromino is within the bounds of a board -}
106 | inBounds : Tetromino -> Bool
107 | inBounds { shape } =
108 | let checkLocation (r, c) = r >= 0 && c >= 0 && c < cols
109 | in List.all checkLocation shape
110 |
111 | {- Checks to see if the specified Tetromino intersects with any of
112 | the pieces on the Board
113 | -}
114 | isIntersecting : Tetromino -> Board -> Bool
115 | isIntersecting { shape } board =
116 | let checkLocation location = Dict.member location board
117 | in List.any checkLocation shape
118 |
119 | {- Checks to see if the Tetromino and Board are valid in a game -}
120 | isValid : Tetromino -> Board -> Bool
121 | isValid tetromino board =
122 | (inBounds tetromino) && not (isIntersecting tetromino board)
123 |
124 | tetromino = Tetromino.shift (0, 5) Tetromino.j
125 |
126 | test = new []
127 |
128 |
129 | main =
130 | flow down [ collage 600 600 [toForm (addTetromino tetromino test)]
131 | , show <| isValid tetromino test
132 | ]
133 |
--------------------------------------------------------------------------------
/TetrisElm/Part14/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (down, flow, show)
8 | import Tetromino exposing (Tetromino, Location)
9 |
10 | type alias Board = Dict Location Block
11 |
12 | new : List (Location, Block) -> Board
13 | new = Dict.fromList
14 |
15 | {- A standard Tetris Board is 10 columns wide -}
16 | cols : Int
17 | cols = 10
18 |
19 | {- A standard Tetris Board is 20 rows tall -}
20 | rows : Int
21 | rows = 20
22 |
23 | {- A black background for our Blocks to rest on -}
24 | background : Form
25 | background =
26 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
27 | border = outlined (solid Color.black) shape --Added later
28 | in group [border, filled Color.black shape]
29 |
30 | {- Adds a block at the specified location to a form -}
31 | addBlock : Location -> Block -> Form -> Form
32 | addBlock (row, col) block form =
33 | let
34 | offSetX = -(toFloat (cols - 1) * Block.size)/2
35 | offSetY = -(toFloat (rows - 1) * Block.size)/2
36 | x = toFloat col * Block.size
37 | y = toFloat row * Block.size
38 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
39 | in group [form, blockForm]
40 |
41 | {- Given a Board, produce a form of that board on a black background -}
42 | toForm : Board -> Form
43 | toForm board = Dict.foldr addBlock background board
44 |
45 |
46 | {- Given a List, returns a List of equal length that is
47 | the cumulative sum of the values in the list.
48 | -}
49 | cumulativeSum : List Int -> List Int
50 | cumulativeSum = List.scanl (+) 0
51 |
52 | iota : Int -> List Int
53 | iota n = List.repeat (n - 1) 1 |> cumulativeSum
54 |
55 | {- Given a List, returns a List of equal length that is
56 | the cumulative sum of the values in the list.
57 | -}
58 | fillRow : Int -> Block -> Board -> Board
59 | fillRow row block board =
60 | let columns = iota cols
61 | rows = List.repeat cols row
62 | locations = List.map2 (,) rows columns
63 | blocks = List.repeat cols block
64 | filledRow = List.map2 (,) locations blocks |> new
65 | in Dict.union filledRow board
66 |
67 | {- True if the specified row is completely filled with blocks
68 | and False otherwise.
69 | -}
70 | checkRow : Int -> Board -> Bool
71 | checkRow row board =
72 | let blocks = Dict.filter (\(r,_) _ -> r == row) board
73 | in Dict.size blocks == cols
74 |
75 | {- Given a row and a board, shifts all rows above the
76 | specified row down 1 row.
77 | -}
78 | clearRow : Int -> Board -> Board
79 | clearRow row board =
80 | let shift (r, c) block newBoard =
81 | if (r < row) then (Dict.insert (r, c) block newBoard)
82 | else if (r > row) then (Dict.insert (r - 1, c) block newBoard)
83 | else newBoard
84 | in Dict.foldr shift Dict.empty board
85 |
86 | {- Given a board, produces a pair where the first value
87 | is the number of rows which were complete in that board
88 | and the second value is a new board with each of those rows
89 | cleared
90 | -}
91 | clearLines : Board -> (Int, Board)
92 | clearLines =
93 | let clearLines' row lines board =
94 | if (row >= rows) then (lines, board)
95 | else if (checkRow row board) then clearLines' row (lines + 1) (clearRow row board)
96 | else clearLines' (row + 1) lines board
97 | in clearLines' 0 0
98 |
99 | {- Adds the specified Tetromino to a Board -}
100 | addTetromino : Tetromino -> Board -> Board
101 | addTetromino { shape, block } board =
102 | let asBoard = List.map2 (,) shape (List.repeat 4 block) |> new
103 | in Dict.union asBoard board
104 |
105 | {- Checks to see if the Tetromino is within the bounds of a board -}
106 | inBounds : Tetromino -> Bool
107 | inBounds { shape } =
108 | let checkLocation (r, c) = r >= 0 && c >= 0 && c < cols
109 | in List.all checkLocation shape
110 |
111 | {- Checks to see if the specified Tetromino intersects with any of
112 | the pieces on the Board
113 | -}
114 | isIntersecting : Tetromino -> Board -> Bool
115 | isIntersecting { shape } board =
116 | let checkLocation location = Dict.member location board
117 | in List.any checkLocation shape
118 |
119 | {- Checks to see if the Tetromino and Board are valid in a game -}
120 | isValid : Tetromino -> Board -> Bool
121 | isValid tetromino board =
122 | (inBounds tetromino) && not (isIntersecting tetromino board)
123 |
124 | tetromino = Tetromino.shift (0, 5) Tetromino.j
125 |
126 | test = new []
127 |
128 |
129 | main =
130 | flow down [ collage 600 600 [toForm (addTetromino tetromino test)]
131 | , show <| isValid tetromino test
132 | ]
133 |
--------------------------------------------------------------------------------
/TetrisElm/Part15/Board.elm:
--------------------------------------------------------------------------------
1 | module Board where
2 |
3 | import Block exposing (Block)
4 | import Color
5 | import Dict exposing (Dict)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (down, flow, show)
8 | import Tetromino exposing (Tetromino, Location)
9 |
10 | type alias Board = Dict Location Block
11 |
12 | new : List (Location, Block) -> Board
13 | new = Dict.fromList
14 |
15 | {- A standard Tetris Board is 10 columns wide -}
16 | cols : Int
17 | cols = 10
18 |
19 | {- A standard Tetris Board is 20 rows tall -}
20 | rows : Int
21 | rows = 20
22 |
23 | {- A black background for our Blocks to rest on -}
24 | background : Form
25 | background =
26 | let shape = rect ((toFloat cols) * Block.size) ((toFloat rows) * Block.size)
27 | border = outlined (solid Color.black) shape --Added later
28 | in group [border, filled Color.black shape]
29 |
30 | {- Adds a block at the specified location to a form -}
31 | addBlock : Location -> Block -> Form -> Form
32 | addBlock (row, col) block form =
33 | let
34 | offSetX = -(toFloat (cols - 1) * Block.size)/2
35 | offSetY = -(toFloat (rows - 1) * Block.size)/2
36 | x = toFloat col * Block.size
37 | y = toFloat row * Block.size
38 | blockForm = Block.toForm block |> move (offSetX + x, offSetY + y)
39 | in group [form, blockForm]
40 |
41 | {- Given a Board, produce a form of that board on a black background -}
42 | toForm : Board -> Form
43 | toForm board = Dict.foldr addBlock background board
44 |
45 |
46 | {- Given a List, returns a List of equal length that is
47 | the cumulative sum of the values in the list.
48 | -}
49 | cumulativeSum : List Int -> List Int
50 | cumulativeSum = List.scanl (+) 0
51 |
52 | iota : Int -> List Int
53 | iota n = List.repeat (n - 1) 1 |> cumulativeSum
54 |
55 | {- Given a List, returns a List of equal length that is
56 | the cumulative sum of the values in the list.
57 | -}
58 | fillRow : Int -> Block -> Board -> Board
59 | fillRow row block board =
60 | let columns = iota cols
61 | rows = List.repeat cols row
62 | locations = List.map2 (,) rows columns
63 | blocks = List.repeat cols block
64 | filledRow = List.map2 (,) locations blocks |> new
65 | in Dict.union filledRow board
66 |
67 | {- True if the specified row is completely filled with blocks
68 | and False otherwise.
69 | -}
70 | checkRow : Int -> Board -> Bool
71 | checkRow row board =
72 | let blocks = Dict.filter (\(r,_) _ -> r == row) board
73 | in Dict.size blocks == cols
74 |
75 | {- Given a row and a board, shifts all rows above the
76 | specified row down 1 row.
77 | -}
78 | clearRow : Int -> Board -> Board
79 | clearRow row board =
80 | let shift (r, c) block newBoard =
81 | if (r < row) then (Dict.insert (r, c) block newBoard)
82 | else if (r > row) then (Dict.insert (r - 1, c) block newBoard)
83 | else newBoard
84 | in Dict.foldr shift Dict.empty board
85 |
86 | {- Given a board, produces a pair where the first value
87 | is the number of rows which were complete in that board
88 | and the second value is a new board with each of those rows
89 | cleared
90 | -}
91 | clearLines : Board -> (Int, Board)
92 | clearLines =
93 | let clearLines' row lines board =
94 | if (row >= rows) then (lines, board)
95 | else if (checkRow row board) then clearLines' row (lines + 1) (clearRow row board)
96 | else clearLines' (row + 1) lines board
97 | in clearLines' 0 0
98 |
99 | {- Adds the specified Tetromino to a Board -}
100 | addTetromino : Tetromino -> Board -> Board
101 | addTetromino { shape, block } board =
102 | let asBoard = List.map2 (,) shape (List.repeat 4 block) |> new
103 | in Dict.union asBoard board
104 |
105 | {- Checks to see if the Tetromino is within the bounds of a board -}
106 | inBounds : Tetromino -> Bool
107 | inBounds { shape } =
108 | let checkLocation (r, c) = r >= 0 && c >= 0 && c < cols
109 | in List.all checkLocation shape
110 |
111 | {- Checks to see if the specified Tetromino intersects with any of
112 | the pieces on the Board
113 | -}
114 | isIntersecting : Tetromino -> Board -> Bool
115 | isIntersecting { shape } board =
116 | let checkLocation location = Dict.member location board
117 | in List.any checkLocation shape
118 |
119 | {- Checks to see if the Tetromino and Board are valid in a game -}
120 | isValid : Tetromino -> Board -> Bool
121 | isValid tetromino board =
122 | (inBounds tetromino) && not (isIntersecting tetromino board)
123 |
124 | tetromino = Tetromino.shift (0, 5) Tetromino.j
125 |
126 | test = new []
127 |
128 |
129 | main =
130 | flow down [ collage 600 600 [toForm (addTetromino tetromino test)]
131 | , show <| isValid tetromino test
132 | ]
133 |
--------------------------------------------------------------------------------
/TetrisElm/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 |
5 | import Block exposing (Block)
6 | import Block as Block
7 |
8 | import Color exposing (Color)
9 | import Color as Color
10 |
11 | import Graphics.Element exposing (Element)
12 | import Graphics.Element as Element
13 |
14 | import Graphics.Collage exposing (Form)
15 | import Graphics.Collage as Collage
16 |
17 | import List as List
18 |
19 | import Mouse as Mouse
20 |
21 | import Signal exposing (Signal)
22 | import Signal as Signal
23 |
24 | type alias Location = (Int, Int)
25 | type alias Tetromino = { shape : List Location
26 | , pivot : (Float, Float)
27 | , block : Block
28 | , width : Int
29 | , height : Int
30 | }
31 |
32 | i : Tetromino
33 | i = { block = { color = Color.lightBlue }
34 | , shape = [ (-1, 0), (0, 0), (1, 0), (2, 0) ]
35 | , pivot = (0.5, 0.5)
36 | , width = 4
37 | , height = 1
38 | }
39 |
40 | z : Tetromino
41 | z = { block = { color = Color.red }
42 | , shape = [ (-1, 1), (0, 1),
43 | (0, 0), (1, 0) ]
44 | , pivot = (0, 0)
45 | , width = 3
46 | , height = 2
47 | }
48 |
49 | s : Tetromino
50 | s = { block = { color = Color.green }
51 | , shape = [ (0, 1), (1, 1),
52 | (-1, 0), (0, 0)
53 | ]
54 | , pivot = (0, 0)
55 | , width = 3
56 | , height = 2
57 | }
58 |
59 | t : Tetromino
60 | t = { block = { color = Color.purple }
61 | , shape = [ (-1, 1), (0, 1), (1, 1),
62 | (0, 0)
63 | ]
64 | , pivot = (0, 1)
65 | , width = 3
66 | , height = 2
67 | }
68 |
69 | l : Tetromino
70 | l = { block = { color = Color.orange }
71 | , shape = [ (0, 1),
72 | (0, 0),
73 | (0, -1), (1, -1)
74 | ]
75 | , pivot = (0, 0)
76 | , width = 3
77 | , height = 2
78 | }
79 |
80 | j : Tetromino
81 | j = { block = { color = Color.blue }
82 | , shape = [ (1, 1),
83 | (1, 0),
84 | (0, -1), (1, -1)
85 | ]
86 | , pivot = (1, 0)
87 | , width = 2
88 | , height = 2
89 | }
90 |
91 | o : Tetromino
92 | o = { block = { color = Color.yellow }
93 | , shape = [ (0, 1), (1, 1)
94 | , (0, 0), (1, 0)
95 | ]
96 | , pivot = (0.5, 0.5)
97 | , width = 2
98 | , height = 2
99 | }
100 |
101 | rotatePoint : (Float, Float) -> Float -> Location -> Location
102 | rotatePoint (pivotR, pivotC) angle (row, col) =
103 | let rowF = toFloat row
104 | colF = toFloat col
105 | s = sin(angle)
106 | c = cos(angle)
107 | rowOrigin = rowF - pivotR
108 | colOrigin = colF - pivotC
109 | rowRotated = rowOrigin * c - colOrigin * s
110 | colRotated = rowOrigin * s + colOrigin * c
111 | newRow = round (rowRotated + pivotR)
112 | newCol = round (colRotated + pivotC)
113 | in (newRow, newCol)
114 |
115 | rotate : Tetromino -> Tetromino
116 | rotate tetromino =
117 | let rotate' = rotatePoint tetromino.pivot (degrees -90)
118 | newShape = List.map rotate' tetromino.shape
119 | in { tetromino | shape = newShape
120 | , width = tetromino.height
121 | , height = tetromino.width
122 | }
123 |
124 | shift : (Int, Int) -> Tetromino -> Tetromino
125 | shift (rows, cols) tetromino =
126 | let shifted = List.map (\(row, col) -> (row + rows, col + cols)) tetromino.shape
127 | (pivotR, pivotC) = tetromino.pivot
128 | in { tetromino | shape = shifted
129 | , pivot = ((toFloat rows) + pivotR, (toFloat cols) + pivotC)
130 | }
131 |
132 |
133 | toForm : Tetromino -> Form
134 | toForm { shape, block } =
135 | let form = Block.toForm block
136 | translate (row, col) = Collage.move ((toFloat row) * Block.width
137 | ,(toFloat col) * Block.height)
138 | form
139 | forms = List.map translate shape
140 | in Collage.group forms
141 |
142 |
143 | drawPivot : Tetromino -> Form
144 | drawPivot {pivot} =
145 | let (x, y) = pivot
146 | in Collage.filled Color.black (Collage.circle 5) |> Collage.move (x*25, y*25)
147 |
148 |
149 | controller : () -> Tetromino -> Tetromino
150 | controller () tetromino = rotate tetromino
151 |
152 | view : Tetromino -> Element
153 | view tetromino =
154 | Collage.collage 400 400 [toForm tetromino, drawPivot tetromino]
155 |
156 | main : Signal Element
157 | main = Signal.map view (Signal.foldp controller t Mouse.clicks)
158 |
--------------------------------------------------------------------------------
/TetrisElm/Part10/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part11/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part12/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part13/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part5/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part6/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part7/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------
/TetrisElm/Part8/Tetromino.elm:
--------------------------------------------------------------------------------
1 | module Tetromino where
2 |
3 | import Basics exposing (..)
4 | import Block exposing (Block)
5 | import Color exposing (Color)
6 | import Graphics.Collage exposing (..)
7 | import Graphics.Element exposing (..)
8 | import List
9 |
10 | {- A Location is the row, col position on the Board -}
11 | type alias Location = (Int, Int)
12 | {- A Tetromino is a list of locations where a particular
13 | block is placed.
14 | -}
15 | type alias Tetromino = { shape : List Location
16 | , block : Block
17 | , pivot : { r : Float, c : Float }
18 | , rows : Int
19 | , cols : Int
20 | }
21 |
22 | i : Tetromino
23 | i = { shape = [ ( 1, 0)
24 | , ( 0, 0)
25 | , (-1, 0)
26 | , (-2, 0)]
27 | , block = Block Color.lightBlue
28 | , pivot = { r = -0.5, c = 0.5 }
29 | , rows = 4
30 | , cols = 1
31 | }
32 |
33 | j : Tetromino
34 | j = { shape = [ ( 1, 0),
35 | ( 0, 0),
36 | (-1, -1), (-1, 0)
37 | ]
38 | , block = Block Color.blue
39 | , pivot = { r = 0.0, c = 0.0 }
40 | , rows = 3
41 | , cols = 2
42 | }
43 |
44 | l : Tetromino
45 | l = { shape = [ ( 1, 0),
46 | ( 0, 0),
47 | (-1, 0), (-1, 1)
48 | ]
49 | , block = Block Color.orange
50 | , pivot = { r = 0.0, c = 0.0 }
51 | , rows = 3
52 | , cols = 2
53 | }
54 |
55 | z : Tetromino
56 | z = { shape = [ ( 1,-1), ( 1, 0),
57 | ( 0, 0), ( 0, 1)
58 | ]
59 | , block = Block Color.red
60 | , pivot = { r = 0.0, c = 0.0 }
61 | , rows = 2
62 | , cols = 3
63 | }
64 |
65 | s : Tetromino
66 | s = { shape = [ ( 0, 0), ( 0, 1),
67 | (-1,-1), (-1, 0)
68 | ]
69 | , block = Block Color.green
70 | , pivot = { r = 0.0, c = 0.0 }
71 | , rows = 2
72 | , cols = 3
73 | }
74 |
75 | t : Tetromino
76 | t = { shape = [ ( 0,-1), ( 0, 0), ( 0, 1),
77 | (-1, 0)
78 | ]
79 | , block = Block Color.purple
80 | , pivot = { r = 0.0, c = 0.0 }
81 | , rows = 2
82 | , cols = 3
83 | }
84 |
85 | o : Tetromino
86 | o = { shape = [ ( 0, 0), ( 0, 1),
87 | (-1, 0), (-1, 1)
88 | ]
89 | , block = Block Color.yellow
90 | , pivot = { r = -0.5, c = 0.5 }
91 | , rows = 2
92 | , cols = 2
93 | }
94 |
95 |
96 | {- Converts a Tetromino to a Form that can be rendered -}
97 | toForm : Tetromino -> Form
98 | toForm { shape, block } =
99 | let form = Block.toForm block
100 | translate (row, col) = move ((toFloat col) * Block.size,
101 | (toFloat row) * Block.size) form
102 | forms = List.map translate shape
103 | in group forms
104 |
105 | {- Takes a Tetromino and produces a dot at its pivot point -}
106 | drawPivot : Tetromino -> Form
107 | drawPivot { pivot } =
108 | let dot = circle 5 |> filled Color.black
109 | translate = move (pivot.c * Block.size, pivot.r * Block.size)
110 | in translate dot
111 |
112 | {- Given a Location, rotates it around a pivot some number of degrees. -}
113 | rotateLocation : { r : Float, c : Float } -> Float -> Location -> Location
114 | rotateLocation pivot angle (row, col) =
115 | let rowOrigin = (toFloat row) - pivot.r
116 | colOrigin = (toFloat col) - pivot.c
117 | (s, c) = (sin(angle), cos(angle))
118 | rowRotated = rowOrigin * c - colOrigin * s
119 | colRotated = rowOrigin * s + colOrigin * c
120 | in (round <| rowRotated + pivot.r, round <| colRotated + pivot.c)
121 |
122 | {- Rotates a Tetromino 90 degrees -}
123 | rotate : Tetromino -> Tetromino
124 | rotate tetromino =
125 | let rotateHelper = rotateLocation tetromino.pivot (degrees 90)
126 | newShape = List.map rotateHelper tetromino.shape
127 | in { tetromino | shape = newShape
128 | , rows = tetromino.cols
129 | , cols = tetromino.rows
130 | }
131 |
132 | {- Shifts a Tetromino the specified number of rows and columns -}
133 | shift : (Int, Int) -> Tetromino -> Tetromino
134 | shift (rows, cols) tetromino =
135 | let
136 | shiftHelper (row, col) = (row + rows, col + cols)
137 | newShape = List.map shiftHelper tetromino.shape
138 | pivot' = { r = tetromino.pivot.r + (toFloat rows)
139 | , c = tetromino.pivot.c + (toFloat cols)
140 | }
141 | in { tetromino | shape = newShape
142 | , pivot = pivot'
143 | }
144 |
145 | tetromino = shift (1, 5) o
146 |
147 | main : Element
148 | main = collage 400 400 [toForm tetromino, drawPivot tetromino]
149 |
--------------------------------------------------------------------------------