Code
- Program.cs
- Board.cs
- Player.cs
Algorithm
- Initialize
- Make first row and column and last row and column to wall
- Make every enum-th row and column to wall
- Side Winder Maze
- Change next row of enum-th to empty randomly
- If next random is wall, choose one of previous empty block
- Make that empty block’s bottom to empty
- Right Hand Rule
- In current direction, go right block if it is empty
- In current direction, go straight if it is empty
- Otherwise, turn left
Timer
- WAIT_TICK
- Excute while loop in every 1000/30 ms
- Calculate
- currentTick: System Timer
- lasTick: last checked Time
- deltaTick: duration of Tick
- Move_TICK
- Move player in every Move_TICK
Property
- Getter
- Return value
- Setter
- Change value
- If value should not be changed in other classes, use private set
List
- Dynamical Array
- Allocate memory 1.5 - 2 times more then real using memory to minimize cost of resizing
- Pros: flexible and continuous
- Cos: cost of resizing
Generic
- List
- To facilitate the reuse of code and algorithms
- Specifies types when classes are used instead of when designing existing classes
Calculate rotation
- Set direction to number
- Turn Right
- For example, if player face up, then player direction must be changed to right
- 0 -> 3, 1 -> 0, 2 -> 1, 3 -> 2
- +4 is for positive number
- Turn Left
- For example, if player face up, then player direction must be changed to left
- 0 -> 1, 1 -> 2, 2 -> 3, 3 -> 0
Calculate position
- Front direction
- If player faces up, decrese row
- If player faces down, increse row
- If player faces left, decrese column
- If player faces right, increse column
- Right direction
- If player faces left, decrese row
- If player faces right, increse row
- If player faces up, increase column
- If player faces down, decrease coloum