[C++] Dodgers3D

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
Latest creation so far for my Basic Programming subject. Did it in 3 days of on off coding. Comments are welcome.

Total line count:969 (Yow)

Press W,S,A,D to move.

Avoid all spheres and destroy the final boss to win.
Code:
#include <stdio.h>

#include <glut.h>

 

void Scene();

void changeSize(int w, int h);

void SpecialKeys(int key, int x, int y);

void Keys(unsigned char Key,int x,int y);

void Lighting(float fLightPos[], bool blnSwitch, bool blnRotate, float fltAngle);

//

//light values//

float fLightPos[4] = {1.0f, 7.0f, 5.0f, 8.0f};

float fLightPos1[4] = {1.0f, 7.0f, 5.0f, 8.0f};

float Red[4] = {1.0f, 0.0f, 0.0f, 1.0f};

//

float mcolor[] = { 1.0f, 1.0f, 1.0f, 1.0f };

float mcolor1[] = { 1.0f, 1.0f, 0.25f, 0.5f };

float mcolor2[] = { 1.0f, 0.213f, 0.25f, 0.5f };

//

//

//Boundaries

//

//

float startX = 3.5, startY = 6.0, startY2 = 6.0;

float endX = -3.5, endY = -6.0, endZ = 0.0;

//

//vectors//

//

float obj1vX = -0.04;

float obj1vY = 0.04;

///

float obj2vX = 0.04;

float obj2vY = -0.04;

///

float obj4vX = 0.0;

float obj4vY = 0.0;

///

float obj5vY = 0.0;

float bossmovespeed = 0.055;

float bossprojectilemove = -0.03;

///

//mass/radius/etc.//

int timeset = 1;

float radius = 0.3;

float radius2 = 0.4;

float radius3 = 0.5;

float radius4 = 0.1;

float radius5 = 0.1;

float time = 0.0;

float blength = 1.0,bwidth = 0.2,bheight = 0.25;

float clength = 1.0,cwidth = 0.2,cheight = 0.5;

float blength2 = 1.0,bwidth2 = 0.2,bheight2 = 1.8;

float WlengthL = 0.5,WwidthL = 0.2,WheightL = 1.0;

float WlengthR = 0.5,WwidthR = 0.2,WheightR = 1.0;

int bosslife = 20;

//

//

//Object values//

float obj1X = 0.0 + radius;

float obj1Y = 5.0 + radius;

//

float obj2X = 1.0 + radius2;

float obj2Y = 4.0 + radius2;

//

float obj3X1 = 1.0;

float obj3Y1 = 1.0;

float obj3X2 = 1.0;

float obj3Y2 = 1.2;

//

float obj4X =  7.0 + radius3;

float obj4Y =  7.0 + radius3;

//

float obj5Y = obj3Y1;

float obj5X = obj3X1;

//

float obj6Xb = 0.0 + 9.0;

float obj6Yb = 4.0;

float obj6RWx = -0.5 + 9.0;

float obj6LWx = 0.5 + 9.0;

float obj6RWy = 4.4;

float obj6LWy = 4.4;

float obj6cY = 3.0;

float obj6cX = 0.0 + 9.0;

float obj7X = 0.0 + 9.0;

float obj7Y = 4.0;

//

//

int dummyvalue1 = 1.0;

//

//forward references

//

//

void refresh();

void initializescene();

void obj1();

void obj2();

void obj3();

void obj4();

void obj5();//projectile

void obj6();//boss

void obj7();//boss projectile

void drawboundaries();

void setboundaries();

void movement1();

void movement2();

void movement3();

void movement4();//Boss movement

void movement5();//Boss projectile movement

void objcollision1();

void objcollision2();

void objcollision3();

void objcollision4();

void timer();

void levels();

//

//

//booleans

//

//

bool collision();

//

void main(int argc, char **argv)//don't touch

 

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

glutInitWindowPosition(800,0);

glutInitWindowSize(400, 400);

glutCreateWindow("Playing around in C++");

glEnable(GL_DEPTH_TEST);

glutReshapeFunc(changeSize);

glutDisplayFunc(Scene);

glutSpecialFunc(SpecialKeys);

glutKeyboardFunc(Keys);

glutIdleFunc(Scene);

glutMainLoop();

}

 

void Scene()

{

 

initializescene();

//Boundaries//

drawboundaries();

setboundaries();

///Begin///

 

 

//

//flowchart

//

 

///Draw Objects///

obj1();

obj2();

obj3();

obj4();

obj5();

obj6();

obj7();

 

///Forces/vectors///

movement1();

movement2();

movement3();

movement4();

movement5();

 

///Mechanics///

objcollision1();

objcollision2();

objcollision3();

objcollision4();

timer();

levels();

//

///End///

refresh();

 

}

 

void initializescene(){//Prepare for rendering

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Lighting(fLightPos, true, false, 0.0f);

 

glPushAttrib(GL_LIGHTING_BIT | GL_CURRENT_BIT);

glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mcolor);

GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};

glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

 

 

glMaterialfv(GL_BACK, GL_AMBIENT_AND_DIFFUSE, mcolor2);

glMaterialfv(GL_LEFT, GL_AMBIENT_AND_DIFFUSE, mcolor1);

 

 

 

}

void refresh(){//Don't touch,Important

glutSwapBuffers();

}

void obj1(){//Draw Ball1

 

glPushMatrix();

glTranslatef(obj1X, obj1Y,0.0);

glutSolidSphere(radius, 100.0f, 100.0f);

glPopMatrix();

 

}

 

void obj2(){//Draw Ball2

 

glPushMatrix();

glTranslatef(obj2X, obj2Y,0.0);

glutSolidSphere(radius2, 100.0f, 100.0f);

glPopMatrix();

 

}

 

 

void obj3()//Space craft

{

//Body

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj3X1,obj3Y1,0.0f);

glScalef(blength*2,bheight*2,bwidth*2);

glutSolidCube(0.5);

glPopAttrib();

glPopMatrix();

//Cockpit

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj3X2,obj3Y2,0.0f);

glScalef(clength*2,cheight*2,cwidth*2);

glutSolidCube(0.2);

glPopAttrib();

glPopMatrix();

}

void obj4()//Ball3

{

glPushMatrix();

glTranslatef(obj4X, obj4Y,0.0);

glutSolidSphere(radius3, 100.0f, 100.0f);

glPopMatrix();

}

void obj5()//projectile

{

glPushMatrix();

glTranslatef(obj5X, obj5Y,0.0);

glutSolidSphere(radius4, 100.0f, 100.0f);

glPopMatrix();

}

void obj6()

{

//Body2

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj6Xb,obj6Yb,0.0f);

glScalef(blength2*2,bheight2*2,bwidth2*2);

glutSolidCube(0.5);

glPopAttrib();

glPopMatrix();

//Lwing

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj6LWx,obj6LWy,0.0f);

glScalef(WlengthL*2,WheightL*2,WwidthL*2);

glutSolidCube(0.5);

glPopAttrib();

glPopMatrix();

//Rwing

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj6RWx,obj6RWy,0.0f);

glScalef(WlengthR*2,WheightR*2,WwidthR*2);

glutSolidCube(0.5);

glPopAttrib();

glPopMatrix();

//cockpit2

glPushMatrix();

glColor3f(1.0,1.0,1.0);

glTranslatef(obj6cX,obj6cY,0.0f);

glScalef(1.0f,1.0f,0.2f);

glutSolidCube(0.5);

glPopAttrib();

glPopMatrix();

}

void obj7(){//boss projectile

glPushMatrix();

glTranslatef(obj7X, obj7Y,0.0);

glutSolidSphere(radius5, 100.0f, 100.0f);

glPopMatrix();

}

void movement1(){//Ball1 Movement

obj1X += obj1vX;

obj1Y += obj1vY;

obj5Y += obj5vY;

}

 

void movement2(){//Ball2 Movement

obj2X += obj2vX;

obj2Y += obj2vY;

obj5Y += obj5vY;

}

void movement3(){//Ball3 Movement

 

    obj4X += obj4vX;

    obj4Y += obj4vY;

}

void movement4()

{

    if(time >=  5000)

    {

obj6Xb += bossmovespeed;

obj6RWx += bossmovespeed;

obj6LWx += bossmovespeed;

obj6cX += bossmovespeed;

    }

}

void movement5()

{

   if(time >= 5000)

   {

       obj7Y += bossprojectilemove;

       if(obj7Y == 4.0)

       {

           bossprojectilemove = -0.05;

       }

   }

}

void timer()

{

if (timeset == 1){

time++;

}

 

}

void levels(){//Level Triggers

 

if(time == 1000)//Level2

{

obj1vX += 0.08;

obj1vY += -0.08;

 

obj2vX += 0.08;

obj2vY += -0.08;

printf("\nYou have entered Level 2\n");

}

if (time == 2000)

{

obj1vX += 0.09;

obj1vY += -0.09;

 

 

obj2vX += 0.09;

obj2vY += -0.09;

printf("\nYou have entered Level 3\n");

}

 

if (time == 3000)

{

obj1vX += 0.08;

obj1vY += -0.08;

obj2vX += 0.08;

obj2vY += -0.08;

radius += 0.2;

radius2 += 0.2;

printf("\nYou have entered Level 4\n");

printf("\nAbandon all hope now.\n");

}

 

if (time == 4000)

{

obj4X = 0.1;

obj4Y = 1.0;

obj4vX = 0.08;

obj4vY = 0.08;

obj1vX += 0.08;

obj1vY += -0.08;

obj2vX += 0.08;

obj2vY += -0.08;

printf("\nYou have entered Level 5\n");

printf("\nLet's make it a bit more interesting\n");

}

if (time == 5000)

{

    startY2 = 3.0;

    obj1Y = 2.0;

    obj2Y = -2.0;

    obj4X = 0.1;

    obj4Y = 1.0;

    obj4vX = 0.08;

    obj4vY = 0.08;

    obj1vX += 0.08;

    obj1vY += -0.08;

    obj2vX += 0.08;

    obj2vY += -0.08;

    obj6Xb = 0.0;

    obj6Yb = 4.0;

    obj6RWx = -0.5;

    obj6LWx = 0.5;

    obj6RWy = 4.4;

    obj6LWy = 4.4;

    obj6cY = 3.0;

    obj6cX = 0.0;

    obj7X = 0.0;

    obj7Y = 4.0;

    printf("\nIf you want something done right you have to do it yourself.\n");

    printf("\nBoss has appeared!\n");

    printf("\nBoss has 20 life points!\n");

    printf("\nLaser Cannon online.\n");

    printf("\nPress e to shoot laser cannon.\n");

    printf("\nLaser cannon does 5 damage.\n");

    printf("\nDestroy the boss to win!\n");

}

if ((time >= 6000)&&(bosslife = 0))

{

printf("\nGame over\n");

obj1vX = 0.0;

obj1vY = 0.0;

///

obj2vX = 0.0;

obj2vY = 0.0;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.0;

bossprojectilemove = 0.0;

timeset = 0;

printf("\nYou have won. Press r to reset the game.\n");

}

}

void drawboundaries(){//Draw Boundaries

glLineWidth(3);

glBegin(GL_LINES);

 

 

glVertex3f(3.5,6.0,0.0);

glVertex3f(-3.5,6.0,0.0);

 

glVertex3f(3.5,-6.0,0.0);

glVertex3f(-3.5,-6.0,0.0);

 

glVertex3f(-3.5,-6.0,0.0);

glVertex3f(-3.5,6.0,0.0);

 

glVertex3f(3.5,6.0,0.0);

glVertex3f(3.5,-6.0,0.0);

glEnd();

//

}

 

void setboundaries(){//Boundary Conditions

//obj1X+radius >= startX checks for right wall

//obj1Y-radius <= endX checks for left wall

if (((obj1X + radius) >= startX) || ((obj1X - radius) <= endX)){

obj1vX *= -1.0;

}

if (((obj1Y + radius) >= startY2) || ((obj1Y - radius) <= endY)){

obj1vY *= -1.0;

}

if (((obj2X + radius) >= startX) || ((obj2X - radius) <= endX)){

obj2vX *= -1.0;

}

if (((obj2Y + radius2) >= startY2) || ((obj2Y - radius2) <= endY)){

obj2vY *= -1.0;

}

if (((obj4X + radius3) >= startX) || ((obj4X - radius3) <= endX)){

obj4vX *= -1.0;

}

if (((obj4Y + radius3) >= startY2) || ((obj4Y - radius3) <= endY)){

obj4vY *= -1.0;

}

if (((obj5Y + radius4) >= startY) || ((obj5Y - radius4) <= endY)){

obj5vY = 0.0;

obj5Y = obj3Y1;

}

if (((obj7Y + radius5) >= startY) || ((obj7Y - radius5) <= endY)){

obj7Y = 4.0;

obj7X = obj6Xb;

bossprojectilemove = 0.0;

}

if(((obj6Xb + blength2) >= startX)||((obj6Xb - blength2) <= endX)){

bossmovespeed *= -1.0;

}

}

 

void objcollision1()//Ball collision triggers

{

 

if (collision())

{

obj2vX *= -1.0;

obj2vY *= -1.0;

obj1vX *= -1.0;

obj1vY *= -1.0;

}

}

 

void objcollision2()//Game Over conditions

{

if (((((obj2X - radius) - 0.2) <= obj3X1) && (((obj2X + radius)- 0.2) >= (obj3X1 - blength)))) {

if (((obj3Y1 - (bwidth )) <= obj2Y) && ((obj3Y1 + (bwidth )) >= obj2Y)) {

 

printf("\nGame over.Press R to reset\n");

obj1vX = 0.0;

obj1vY = 0.0;

///

obj2vX = 0.0;

obj2vY = 0.0;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.0;

bossprojectilemove = 0.0;

timeset = 0;

time = 0;

obj1X = 0.0 + radius;

obj1Y = 5.0 + radius;

//

obj2X = 1.0 + radius2;

obj2Y = 4.0 + radius2;

//

obj3X1 = 1.0;

obj3Y1 = 1.0;

obj3X2 = 1.0;

obj3Y2 = 1.2;

//

obj4X =  7.0 + radius3;

obj4Y =  7.0 + radius3;

//

obj5Y = obj3Y1;

obj5X = obj3X1;

//

obj6Xb = 0.0 + 9.0;

obj6Yb = 4.0;

obj6RWx = -0.5 + 9.0;

obj6LWx = 0.5 + 9.0;

obj6RWy = 4.4;

obj6LWy = 4.4;

obj6cY = 3.0;

obj6cX = 0.0 + 9.0;

obj7X = 0.0 + 9.0;

obj7Y = 4.0;

}

}

 

if (((((obj1X - radius) - 0.2) <= obj3X1) && (((obj1X + radius)- 0.2) >= (obj3X1 - blength)))) {

if (((obj3Y1 - (bwidth )) <= obj1Y) && ((obj3Y1 + (bwidth )) >= obj1Y)) {

 

printf("\nGame over.Press R to reset\n");

obj1vX = 0.0;

obj1vY = 0.0;

///

obj2vX = 0.0;

obj2vY = 0.0;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.0;

bossprojectilemove = 0.0;

time = 0;

timeset = 0;

obj1X = 0.0 + radius;

obj1Y = 5.0 + radius;

//

obj2X = 1.0 + radius2;

obj2Y = 4.0 + radius2;

//

obj3X1 = 1.0;

obj3Y1 = 1.0;

obj3X2 = 1.0;

obj3Y2 = 1.2;

//

obj4X =  7.0 + radius3;

obj4Y =  7.0 + radius3;

//

obj5Y = obj3Y1;

obj5X = obj3X1;

//

obj6Xb = 0.0 + 9.0;

obj6Yb = 4.0;

obj6RWx = -0.5 + 9.0;

obj6LWx = 0.5 + 9.0;

obj6RWy = 4.4;

obj6LWy = 4.4;

obj6cY = 3.0;

obj6cX = 0.0 + 9.0;

obj7X = 0.0 + 9.0;

obj7Y = 4.0;

 

}

}

 

if (((((obj4X - radius3) - 0.2) <= obj3X1) && (((obj4X + radius3)- 0.2) >= (obj3X1 - blength)))) {

if (((obj3Y1 - (bwidth )) <= obj4Y) && ((obj3Y1 + (bwidth )) >= obj2Y)) {

 

printf("\nGame over.Press R to reset\n");

obj1vX = 0.0;

obj1vY = 0.0;

///

obj2vX = 0.0;

obj2vY = 0.0;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.0;

bossprojectilemove = 0.0;

timeset = 0;

time = 0;

obj1X = 0.0 + radius;

obj1Y = 5.0 + radius;

//

obj2X = 1.0 + radius2;

obj2Y = 4.0 + radius2;

//

obj3X1 = 1.0;

obj3Y1 = 1.0;

obj3X2 = 1.0;

obj3Y2 = 1.2;

//

obj4X =  7.0 + radius3;

obj4Y =  7.0 + radius3;

//

obj5Y = obj3Y1;

obj5X = obj3X1;

//

obj6Xb = 0.0 + 9.0;

obj6Yb = 4.0;

obj6RWx = -0.5 + 9.0;

obj6LWx = 0.5 + 9.0;

obj6RWy = 4.4;

obj6LWy = 4.4;

obj6cY = 3.0;

obj6cX = 0.0 + 9.0;

obj7X = 0.0 + 9.0;

obj7Y = 4.0;

 

}

}

if(((obj3X1 + blength) >= (obj6Xb - (blength2 - 0.1)))&&((obj3Y1 + bheight) >= (obj6Yb - (bheight2 - 0.1))))

{

if(((obj3X1 - blength) <= (obj6Xb + (blength2 - 0.1)))&&((obj3Y1 - bheight) <= (obj6Yb + (bheight2 + 0.1))))

{

printf("\nGame over.Press R to reset\n");

obj1vX = 0.0;

obj1vY = 0.0;

///

obj2vX = 0.0;

obj2vY = 0.0;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.0;

bossprojectilemove = 0.0;

timeset = 0;

time = 0;

obj1X = 0.0 + radius;

obj1Y = 5.0 + radius;

//

obj2X = 1.0 + radius2;

obj2Y = 4.0 + radius2;

//

obj3X1 = 1.0;

obj3Y1 = 1.0;

obj3X2 = 1.0;

obj3Y2 = 1.2;

//

obj4X =  7.0 + radius3;

obj4Y =  7.0 + radius3;

//

obj5Y = obj3Y1;

obj5X = obj3X1;

//

obj6Xb = 0.0 + 9.0;

obj6Yb = 4.0;

obj6RWx = -0.5 + 9.0;

obj6LWx = 0.5 + 9.0;

obj6RWy = 4.4;

obj6LWy = 4.4;

obj6cY = 3.0;

obj6cX = 0.0 + 9.0;

obj7X = 0.0 + 9.0;

obj7Y = 4.0;

}

}

//

}

 

 

void objcollision3(){

    if ((((obj5X + radius4) >= (obj6Xb - blength2))&&((obj5Y + radius4) >= (obj6Yb))))//Left side

    {

        if ((((obj5X - radius4) <= (obj6Xb + blength2)))&&((obj5Y + radius4) >= (obj6Yb)))//right side

    {

        bosslife -= 5;

        printf("\nCurrent Boss life:%d\n",bosslife);

        obj5Y = obj3Y1;

        obj5vY = 0.0;

    }

    }

 

}

void objcollision4(){

    if ((((obj7X + radius5) >= (obj3X1 - blength))&&((obj7Y + radius4) <= (obj3Y1))))//Left side

    {

        if ((((obj7X - radius5) <= (obj3X1 + blength)))&&((obj7Y + radius4) <= (obj3Y1)))//right side

    {

        printf("\nGame Over.Press R to reset\n");

    obj1vY = 0.0;

    obj1vX = 0.0;

    ///

    obj2vX = 0.0;

    obj2vY = 0.0;

    ///

    obj4vX = 0.0;

    obj4vY = 0.0;

    ///

    obj5vY = 0.0;

    bossmovespeed = 0.0;

    bossprojectilemove = 0.0;

    timeset = 0;

    time = 0;

    obj1X = 0.0 + radius;

    obj1Y = 5.0 + radius;

    //

    obj2X = 1.0 + radius2;

    obj2Y = 4.0 + radius2;

    //

    obj3X1 = 1.0;

    obj3Y1 = 1.0;

    obj3X2 = 1.0;

    obj3Y2 = 1.2;

    //

    obj4X =  7.0 + radius3;

    obj4Y =  7.0 + radius3;

    //

    obj5Y = obj3Y1;

    obj5X = obj3X1;

    //

    obj6Xb = 0.0 + 9.0;

    obj6Yb = 4.0;

    obj6RWx = -0.5 + 9.0;

    obj6LWx = 0.5 + 9.0;

    obj6RWy = 4.4;

    obj6LWy = 4.4;

    obj6cY = 3.0;

    obj6cX = 0.0 + 9.0;

    obj7X = 0.0 + 9.0;

    obj7Y = 4.0;

    }

    }

 

}

bool collision() {//Ball to Ball collision1

if ((((obj2X - radius2) <= (obj1X + radius)) && ((obj2X + radius2) >= (obj1X + radius)))) {

if (((((obj2Y + 0.01) - radius2 - 0.1) <= (obj1Y + radius - 0.1)) && (((obj2Y + 0.01) + radius2 + 0.1) >= (obj1Y + radius + 0.1)))){

return true;

}

}

return false;

}

void changeSize(int w, int h)

 

{

float ratio = 1.0 * w / h;

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glViewport(0,0,w,h);

gluPerspective(115.0, ratio, 1, 100);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt(0.0, 0.0f, 4.0,

0.0, 0.0, 0.0,

0.0, 4.0, 0.0);}

 

void SpecialKeys(int key, int x, int y)

 

{

switch(key)

 

{

case GLUT_KEY_LEFT :

glRotatef(0.5f, 0.0, 2.0, 0.0);

break;

case GLUT_KEY_RIGHT :

glRotatef(0.5, 0.0, -2.0, 0.0);

break;

case GLUT_KEY_UP :

glRotatef(0.5, 2.0, 0.0, 0.0);

break;

case GLUT_KEY_DOWN :

glRotatef(0.5, -2.0, 0.0, 0.0);

break;

}

}

 

void Keys(unsigned char Key,int x,int y){

switch (Key)

{

case 'r'://RESET EVERYTHING

startY2 = startY;

obj6Xb = 0.0 + 9.0;

obj6Yb = 4.0;

obj6RWx = -0.5 + 9.0;

obj6LWx = 0.5 + 9.0;

obj6RWy = 4.4;

obj6LWy = 4.4;

obj6cY = 3.0;

obj6cX = 0.0 + 9.0;

obj7X = 0.0 + 9.0;

obj7Y = 4.0;

///

obj1vX = -0.04;

obj1vY = 0.04;

///

obj2vX = 0.04;

obj2vY = -0.04;

///

obj4vX = 0.0;

obj4vY = 0.0;

///

obj5vY = 0.0;

bossmovespeed = 0.004;

bossprojectilemove = -0.3;

///

timeset = 1;

radius = 0.3;

radius2 = 0.4;

radius3 = 0.5;

radius4 = 0.1;

radius5 = 0.1;

time = 0.0;

blength = 1.0;

bwidth = 0.2;

bheight = 0.25;

clength = 1.0;

cwidth = 0.2;

cheight = 0.5;

blength2 = 1.0;

bwidth2 = 0.2;

bheight2 = 1.8;

WlengthL = 0.5;

WwidthL = 0.2;

WheightL = 1.0;

WlengthR = 0.5;

WwidthR = 0.2;

WheightR = 1.0;

bosslife = 100;

//

//

obj1X = 0.0 + radius;

obj1Y = 5.0 + radius;

//

obj2X = 1.0 + radius2;

obj2Y = 4.0 + radius2;

//

obj3X1 = 1.0;

obj3Y1 = 1.0;

obj3X2 = 1.0;

obj3Y2 = 1.2;

//

obj4X =  7.0 + radius3;

obj4Y =  7.0 + radius3;

//

obj5Y = obj3Y1;

obj5X = obj3X1;

//

///

printf("\nValues reset");

printf("\n");

break;

///

//ship movement

case 'w':

///

if ((((obj3Y1) + (bheight + cheight)) >= 4.0))

{

}

else

{

obj3Y1 += 1.0;

obj3Y2 += 1.0;

obj5Y  += 1.0;

}

break;

//

case 's':

//

if (((obj3Y1) - (bheight + cheight)) <= -5.4)

{

}

else

{

obj3Y1 -= 1.0;

obj3Y2 -= 1.0;

obj5Y -= 1.0;

}

break;

case 'd':

if (((obj3X1) + (blength)) >= 3.5)

{

}

else

{

obj3X1 += 1.0;

obj3X2 += 1.0;

obj5X += 1.0;

}

break;

///

case 'a':

if (((obj3X1) - (blength)) <= -3.5)

{

}

else

{

obj3X1 -= 1.0;

obj3X2 -= 1.0;

obj5X -= 1.0;

}

break;

case 'e':

    if (time >= 5000)

    {

    obj5vY = 0.2;

    }

    break;

//

//

}

}

void Lighting(float fLightPos[], bool blnSwitch, bool blnRotate, float fltAngle)

{

glPushMatrix();

glPointSize(5);

glBegin(GL_POINTS);

glColor3f(1.0f, 1.0f, 1.0f);

glVertex3f(fLightPos[0], fLightPos[1], fLightPos[2]);

 

glEnd();

 

float lightDiffuse[] = {1.0f, 0.7f, 1.0f, 1.0f};

float lightAmbient[] = {0.0f, 0.0f, 0.0f, 1.0f};

float *lightPosition = fLightPos;

 

float lightDiffuse1[] = {1.0f, 1.0f, 0.0f, 1.0f};

float lightAmbient1[] = {0.0f, 0.3f, 0.7f, 1.0f};

float *lightPosition1 = fLightPos;

 

glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);

glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);

glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);

glEnable(GL_LIGHT0);

glEnable(GL_LIGHTING);

glEnable(GL_NORMALIZE);

glPopMatrix();

}
 

YourFace

<span style="color:#9C9C9C;"><strong>Runner Up - T
Reaction score
91
It closes right after opening D:.
I can't open it with vs either!
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
i used the glut.h library in making it just a heads up.

Also by any chance can i lessen the number of code lines?
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
Is there a more easier method of collision detection for both spheres and cubes?

(x + 1/2 length of cube1) <= (x + radius of sphere1) isn't very reliable. with X being the object's position in the X axis.
 
General chit-chat
Help Users
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top