openGPMP
Open Source Mathematics Package
Public Member Functions | Private Attributes | List of all members
Ball Class Reference

Public Member Functions

 Ball (double r, GLfloat *c, double h, double x, double z)
 
void update ()
 

Private Attributes

double radius
 
GLfloat * color
 
double maximumHeight
 
double x
 
double y
 
double z
 
int direction
 

Detailed Description

Definition at line 63 of file openGL_bounce.c.

Constructor & Destructor Documentation

◆ Ball()

Ball::Ball ( double  r,
GLfloat *  c,
double  h,
double  x,
double  z 
)
inline

Definition at line 73 of file openGL_bounce.c.

74  : radius(r), color(c), maximumHeight(h), direction(-1), y(h), x(x),
75  z(z) {
76  }
double y
Definition: openGL_bounce.c:68
double maximumHeight
Definition: openGL_bounce.c:66
double x
Definition: openGL_bounce.c:67
GLfloat * color
Definition: openGL_bounce.c:65
int direction
Definition: openGL_bounce.c:70
double z
Definition: openGL_bounce.c:69
double radius
Definition: openGL_bounce.c:64

Member Function Documentation

◆ update()

void Ball::update ( )
inline

Definition at line 78 of file openGL_bounce.c.

78  {
79  y += direction * 0.05;
80 
81  if (y > maximumHeight) {
82  y = maximumHeight;
83  direction = -1;
84  }
85 
86  else if (y < radius) {
87  y = radius;
88  direction = 1;
89  }
90 
91  glPushMatrix();
92  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
93  glTranslated(x, y, z);
94  glutSolidSphere(radius, 30, 30);
95  glPopMatrix();
96  }

References color, direction, maximumHeight, radius, x, y, and z.

Referenced by display().

Member Data Documentation

◆ color

GLfloat* Ball::color
private

Definition at line 65 of file openGL_bounce.c.

Referenced by update().

◆ direction

int Ball::direction
private

Definition at line 70 of file openGL_bounce.c.

Referenced by update().

◆ maximumHeight

double Ball::maximumHeight
private

Definition at line 66 of file openGL_bounce.c.

Referenced by update().

◆ radius

double Ball::radius
private

Definition at line 64 of file openGL_bounce.c.

Referenced by update().

◆ x

double Ball::x
private

Definition at line 67 of file openGL_bounce.c.

Referenced by update().

◆ y

double Ball::y
private

Definition at line 68 of file openGL_bounce.c.

Referenced by update().

◆ z

double Ball::z
private

Definition at line 69 of file openGL_bounce.c.

Referenced by update().


The documentation for this class was generated from the following file: