CSC112 Spring 2016 Examples
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 2016.03.17.16.01.01; author pngwen; state Exp;
branches;
next ;
desc
@@
1.1
log
@Initial revision
@
text
@// This is a class which implements those notorious little golf-tee puzzles
// found at certain country-themed restaraunts.
// Revision: $Revision$
// Change Log
// $Log$
#ifndef TRIANGLEPUZZLE_H
#define TRIANGLEPUZZLE_H
#include <vector>
#include "widget.h"
#include "peg.h"
class TrianglePuzzle : public Widget
{
public:
//Construct a triangle puzzle with a x, y coordinate for the upper
//left hand corner. (As laid out on a 9x27 grid)
TrianglePuzzle(int _x, int _y);
//Construct a triangle puzzle in the center of the screen
TrianglePuzzle();
//Volguus Zildrohar the traveler has come!
~TrianglePuzzle();
//display the puzzle
virtual void display();
//select a given peg
virtual void selectPeg(int px, int py);
//move the selection up a row
virtual void up();
//move the selection down a row
virtual void down();
//move the selection right a column
virtual void right();
//move the selection left a column
virtual void left();
//perform a part of a move. Returns true if valid, false if invalid
virtual bool move();
//reset the puzzle back to its starting state
virtual void reset();
private:
std::vector<std::vector<Peg *> > pegs; //the pegs in the puzzle (of course)
int cx, cy; //cursor position
int mx, my; //position of the selected peg for the move
};
#endif
@