Programming a Chess Game in C# | Part 2 - Positions & Directions

Опубликовано: 30 Май 2026
на канале: OttoBotCode
29,718
434

Learn how to program a Chess game in C#!

Welcome to part 2 of my C# Chess tutorial.
In this part we add a few simple classes to the ChessLogic project:
A Player enum for storing which players turn it is, the winning player and also the color of the chess pieces.
A Position class which represents a position (or square) on the board.
A Direction class which will be very useful for implementing how each piece moves.

Assets:
https://ottobotcode.com/chess/ChessAs...

Source code is available here:
  / 78701  

Chapters:
0:00 - Plan
0:29 - Player Enum
1:25 - Find Opponent
3:39 - Position Class
5:07 - Find Square Color
6:10 - Override Equals & GetHashCode
6:58 - Direction Class
8:22 - Combine Directions
9:28 - Scale Directions
10:10 - Predefine Directions
12:22 - Translate Position
13:53 - Usage Example