[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
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      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