Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "Sphere.h"
//We can either hard code the values in GameObject (like in Sphere())
//or
//We can use the GameEngine constructors to fill the values ( like in Sphere(x, y, z, radius, speed))
Sphere::Sphere()
{
x = 0.0f;
y = 0.0f;
z = 0.0f;
r = 1.0f;
g = 0.0f;
b = 1.0f;
radius = 1.0f;
moveSpeed = 5.0f;
}
Sphere::Sphere(float _x, float _y, float _z, float _radius, float _moveSpeed)
:GameObject(_x, _y, _z) //note the use of GameObject constructor
{
radius = _radius;
moveSpeed = _moveSpeed;
}
Sphere::Sphere(float _x, float _y, float _z,
float _r, float _g, float _b,
float _radius, float _moveSpeed):
GameObject(_x, _y, _z, _r, _g, _b) //note the use of GameObject constructor
{
radius = _radius;
moveSpeed = _moveSpeed;
}
void Sphere::Draw()
{
glPushMatrix();
glTranslatef(x, y, z);
glColor3f(r, g, b);
//glutSolidSphere(radius, 10, 10); //if you'd rather it shows solid
glutWireSphere(radius, 10, 10);
glPopMatrix();
}
void Sphere::Update(float deltaTime)
{
//This uses only special keys at the moment - aka the arrow keys
//You can use normal keys via
//GameObject::keys['a'] for the a key for example
if (GameObject::specialKeys[GLUT_KEY_UP] == true)
y += moveSpeed * deltaTime;
if (GameObject::specialKeys[GLUT_KEY_DOWN] == true)
y -= moveSpeed * deltaTime;
}