Saturday, February 22, 2014

Helicopter - A Game

This is a helicopter project. Very simple. A copter moves up if you hold the mouse button down. If not it keeps going down. An obstacle appears from the right and the task is to jump over it.

Snapshot:



Here is the source.

On request i am posting a crude algo of this program as i understand it...
display function has the following steps:
1) Check if the helicopter comes in contact with the wall. If so end the game and display appropriate message.
2) If wflag==1 that means start of the game so display messages indicating the way to start the game ie by clicking the mouse.
3) If its not start of the game and the game has not ended then in the second else part do the following
i) Increment the score and if the score overflows increment level
ii) Translate the helicopter by hm in the y direction and draw it.
iii) move the position of the wall to the left by bspd(block speed)... If it has already gone out of the window reinitialize its bx to 50 and by to any random value between 20-44.(width of the block is always 5 and height 35. So a block can range from 20 to 55 minimum to 44 to 79 maximum leaving 20-20 distance at the top and bottom)
iv) Draw the block at position bx,by by drawing a rectangle(red polygon)
Mouse function steps are:
1) If left mouse button is pressed or unpressed
   i) if the left mouse button was pressed
       initialize the idle function to moveHeliU
   ii) if the left mouse button was unpressed
       initialize the idle function to moveHeliD
Idle functions simply increment or decrement the hm value to move the helicopter up or down
Keyboard function can also be used to control the helicopter...
1) if 'w' key is pressed initialize the idle function to moveHeliU
2) if 'm' key is pressed initialize the idle function to moveHeliD
Init function
Initializes the window size by calling glOrtho with left=0,right=100,bottom=0,top=100

You might have guessed that moveHeliU and moveHeliD move the helicopter up and down respectively while also moving it to the right.

17 comments:

  1. Can you please post the algorithm of the game!!

    ReplyDelete
    Replies
    1. Just see if the algo i have posted meets the requirements...

      Delete
  2. Can you tell me how I can keep changing the background color after each level?

    ReplyDelete
  3. Send me source code
    Sudha.biradar001@gmail.com

    ReplyDelete
  4. Sir pls send me the source code for this project my email I'd
    Sudha.biradar001@gmail.com

    ReplyDelete
  5. Sir pls send full source code for this project my email I'd is
    Sudha.biradar001@gmail.com

    ReplyDelete
  6. Sir i got the source code and output also plz send me the detail explanation of the program to my email
    Sudha.biradar001@gmail.com

    ReplyDelete
  7. Sir can u please send me algorithm and flowchart to emailed: poojabr650@gmail.com

    ReplyDelete
  8. Sir I have executed the code and it runs properly. Kindly send me the detailed explanation of the code

    ReplyDelete
  9. Sir I have executed the code and it runs properly. Kindly send me the detailed explanation of the code to my mail:- divishathreddyadidala@gmail.com

    ReplyDelete
  10. have any source code for helicopter game in c++/oop
    plz send it to me

    ReplyDelete
  11. Sir send me source code of this sir plz

    ReplyDelete
  12. not so interface when open the game directly open heli game

    ReplyDelete
  13. you can gave me source code, please ?
    my email ducdinh16021999@gmail.com

    ReplyDelete
  14. Sir, I request you to please send me the source code of this game to my email asusdatta2135@gmail.com

    ReplyDelete