/********************************************************************************************
Step2.cpp
Jim Millard
for CO311/Spring 2000
Simple program that displays a 4x4 blue/red checkerboard
Uses the ezwin API
********************************************************************************************/
#include <iostream>
#include <string>
using namespace std;
#include "ezwin.h"
#include "rect.h"
void DrawCheckerboard(SimpleWindow& W); //required prototype
int ApiMain()
{
//create the primary window
SimpleWindow W("Exercise 3.22, Step 2");
W.Open();
DrawCheckerboard(W);
//wait for input prior to quitting
char ch;
cout << "Enter a character to continue";
cin >> ch;
Terminate();
return 0;
}
void DrawCheckerboard(SimpleWindow& W)
{
const float height=2., //static height of all blocks
width =2., //static width of all blocks
xCenter =width/2., //horizontal center of each block
yCenter =height/2.; //vertical center of each block
const color BaseColor = Blue, //static color of first block
AltColor = Red; //static color of alternate block
//Draw the rectangles
//first row
RectangleShape R11(W, xCenter /* + width * 0 */, yCenter /* + height * (row-1) */, BaseColor, width, height);
R11.Draw();
RectangleShape R12(W, xCenter + width, yCenter, AltColor, width, height);
R12.Draw();
RectangleShape R13(W, xCenter + width*2, yCenter, BaseColor, width, height);
R13.Draw();
RectangleShape R14(W, xCenter + width*3, yCenter, AltColor, width, height);
R14.Draw();
//second row
RectangleShape R21(W, xCenter, yCenter + height, AltColor, width, height);
R21.Draw();
RectangleShape R22(W, xCenter + width, yCenter + height, BaseColor, width, height);
R22.Draw();
RectangleShape R23(W, xCenter + width*2, yCenter + height, AltColor, width, height);
R23.Draw();
RectangleShape R24(W, xCenter + width*3, yCenter + height, BaseColor, width, height);
R24.Draw();
//third row
RectangleShape R31(W, xCenter, yCenter + height*2, BaseColor, width, height);
R31.Draw();
RectangleShape R32(W, xCenter + width, yCenter + height*2, AltColor, width, height);
R32.Draw();
RectangleShape R33(W, xCenter + width*2, yCenter + height*2, BaseColor, width, height);
R33.Draw();
RectangleShape R34(W, xCenter + width*3, yCenter + height*2, AltColor, width, height);
R34.Draw();
//fourth row
RectangleShape R41(W, xCenter, yCenter + height*3,AltColor,width,height);
R41.Draw();
RectangleShape R42(W, xCenter + width, yCenter + height*3,BaseColor, width, height);
R42.Draw();
RectangleShape R43(W, xCenter + width*2, yCenter + height*3,AltColor, width, height);
R43.Draw();
RectangleShape R44(W, xCenter + width*3, yCenter + height*3, BaseColor, width, height);
R44.Draw();
return;
}//DrawCheckerboard