Friday, June 27, 2014

Sinking Ship

Namratha and sweekruthi worked on this existing project. The modification done to the sinking ship project that has been done is the ice berg becomes two pieces... both the pieces move down and sink.

Here are the snaps:
Moving....
 Collison....

 Pieces of iceberg and ship sinking....


I just want to add something to explain how this pieces of ice cube and their rotation was achieved.

Here is the code which does the trick.
/* TO DRAW ICEBERG */
void ice()
{
    glPushMatrix();
    glTranslated(450,50,0.0);
    glScaled(10,10,0);
    glColor3f(0.0,1.0,1.0);
    if(c>0)                          // This flag is used to indicate if ice berg is
    {glPushMatrix();          // intact or split into two after collision
    glTranslated(0,x,0);      //move the ice bergs down all the while rotating them.
    glPushMatrix();
    glTranslated(7,2,0.0);
    glRotated(-x,0,0,1);      // clockwise for the right piece.
    glTranslated(-7,-2,0.0);
    glBegin(GL_POLYGON);
        glVertex2f(7,2);
        glVertex2f(8,3);
        glVertex2f(11,18);
        glVertex2f(12,19);
        glVertex2f(12,3);
        glEnd();
        glPopMatrix();
        glPushMatrix();

        glTranslated(12,3,0.0);
        glRotated(x,0,0,1);           // anti clock wise for the left piece.
        glTranslated(-12,-3,0.0);
        glBegin(GL_POLYGON);
        glVertex2f(12,3);
        glVertex2f(12,19);
        glVertex2f(17,18);
        glVertex2f(18,3);
        glVertex2f(19,3);
        glEnd();
        glPopMatrix();
        glPopMatrix();
    }
    else                                 // if ice berg is intact draw one piece
    {                                     // without any transformations
        glBegin(GL_POLYGON);
            glVertex2f(7,2);
            glVertex2f(8,3);
            glVertex2f(11,18);
            glVertex2f(12,19);
            glVertex2f(12,3);
            glEnd();
            glBegin(GL_POLYGON);
            glVertex2f(12,3);
            glVertex2f(12,19);
            glVertex2f(17,18);
            glVertex2f(18,3);
            glVertex2f(19,3);
            glEnd();
    }
    glPopMatrix();
}
The variable c is global and it is set in the display function
like this...
    if(b>250)
    {

        c+=10;
        display3();

    }
Here is the complete code.

30 comments:

  1. hello sir...could u please send me the project reports of this sinking ship project to d mail id 'sushmitha.b16@gmail.com'?

    ReplyDelete
    Replies
    1. Could u send me project report of sinking ship to dis email ID :amilineniniveditha@gmail.com.. Plz bro 🙏

      Delete
    2. Send me sinking ship project report plzz

      Delete
  2. Please could u send me the report sir ??of thinking ship to poorna929@gmail.
    Com

    ReplyDelete
  3. Sir could you please send the report to mohankumari.venugopal@gmail.com

    ReplyDelete
  4. ship.c:49:8: warning: implicit declaration of function ‘nanosleep’ [-Wimplicit-function-declaration]
    nanosleep(&tim , &tim2);

    ReplyDelete
  5. can anyone send me the flow chart diagram of this project?
    send me the same to abhimanyurex@gmail.com

    ReplyDelete
  6. Can you please send me the project report for this?
    My email ID: faran.baig.95@gmail.com
    Thank you!

    ReplyDelete
  7. Can you please send me the project report for this?
    My email ID: faran.baig.95@gmail.com
    Thank you!

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. sir plz send me the report of this project sir...plzz sir
    vishweshwarayya.hiremath17@gmail.com

    ReplyDelete
  10. Bro you have source code if there send to chethup98@gmail.com plz

    ReplyDelete
  11. Can you please send me project report for this my email id yasmeentaj40@gmail.com

    ReplyDelete
    Replies
    1. Could you please send me project report to dis email :amilineniniveditha@gmail.com

      Delete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Sir can you please send the report pdf to my mail

    ReplyDelete
    Replies
    1. Sir if u hv report pdf plzz forward to my mail id kmanasa199@gmail.com

      Delete
  14. Sir could you please send me the report of this project to rakshashetty659@icloud.com

    ReplyDelete
  15. Sir can you plzz send me the report of this project to mamathark9@gmail.com

    ReplyDelete
  16. sir can u plz send me full code to ishrathaysha111@gmail.com

    ReplyDelete
  17. Sir.. Could u please send me the project report of sinking ship project to the mail mahalakshmishetty06@gmail.com

    ReplyDelete
  18. Sir please can you send project report on email sir (sagar8910hunashyal@gmail.com) please.

    ReplyDelete
    Replies
    1. Could you please send me a project report plz bro.

      Delete
  19. Sir can u please help me in adding user interaction keys to this progrwm

    ReplyDelete
  20. Could you please send me the project source code and report

    ReplyDelete
  21. Could you please send me a project report plz bro to dis email :amilineniniveditha@gmail.com..🙏🙏

    ReplyDelete
    Replies
    1. Sorry I could not respond as I have lost all backup of reports due to hard disk crash. If not for my gdrive I would have lost the code too.

      Delete
  22. Send me report of sinking ship

    ReplyDelete