Thursday, 4 June 2020

Chapter 14 // Exercise 9 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 14 // Exercise 9

Define a Group to be a container of Shapes with suitable operations applied to the various members of the Group. Hint: Vector_ref. Use a Group to define a checkers (droughts) board where pieces can be moved under program control.

Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2014/Exercise%209


This is pretty basic and it's all hardcoded so there's no full draughts game going on (yet...). I know he said to use a Vector_ref however I decided to use 3 Fl_Images for the board and pieces. There is actually only 1 light piece and 1 dark piece but they're just set to draw in multiple places to save on objects. 

The move location is stored in vectors of Rectangles which can easily be deleted and changed when a piece is overtaken. The move system works off directions like NorthWest. 

I don't think this is entirely what he meant in the exercise. I think maybe he wanted a group that contained a way to make a board, draw an image, draw a circle. I think that's kind of unnecessary considering you have everything you need grouped together anyway in Graph.h.



No comments:

Post a Comment