home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / POINT2.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  1KB  |  52 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. /* POINT2.CPP--Example from Getting Started */
  4.  
  5. // POINT2.CPP contains the definitions for the Point and Location
  6. // classes that are declared in the file point.h
  7.  
  8. #include "point.h"
  9. #include <graphics.h>
  10.  
  11. // member functions for the Location class
  12. Location::Location(int InitX, int InitY) {
  13.    X = InitX;
  14.    Y = InitY;
  15. };
  16.  
  17. int Location::GetX(void) {
  18.    return X;
  19. };
  20.  
  21. int Location::GetY(void) {
  22.    return Y;
  23. };
  24.  
  25. // member functions for the Point class: These assume
  26. // the main program has initialized the graphics system
  27.  
  28. Point::Point(int InitX, int InitY) : Location(InitX,InitY) {
  29.    Visible = false;                  // make invisible by default
  30. };
  31.  
  32. void Point::Show(void) {
  33.    Visible = true;
  34.    putpixel(X, Y, getcolor());       // uses default color
  35. };
  36.  
  37. void Point::Hide(void) {
  38.    Visible = false;
  39.    putpixel(X, Y, getbkcolor()); // uses background color to erase
  40. };
  41.  
  42. Boolean Point::IsVisible(void) {
  43.    return Visible;
  44. };
  45.  
  46. void Point::MoveTo(int NewX, int NewY) {
  47.    Hide();         // make current point invisible
  48.    X = NewX;       // change X and Y coordinates to new location
  49.    Y = NewY;
  50.    Show();         // show point at new location
  51. };
  52.