02.08.2020»»воскресенье

Dev C++ Flappy Bird

02.08.2020
Dev C++ Flappy Bird Average ratng: 9,5/10 3069 votes
  1. Flappy Bird Html Code
  2. Program Flappy Bird
  1. #include <string>
  2. #include <fstream>
  3. #include <ctime>
  4. public:
  5. bird_x =100;
  6. bird[0].setFillColor(sf::Color::Red);
  7. bird[1].setFillColor(sf::Color::Yellow);
  8. bird[1].setPosition(bird_x +71, bird_y +20);
  9. bird.push_back(sf::CircleShape(3.f));
  10. bird[2].setPosition(bird_x +20, bird_y +10);
  11. void getPosition(float*x, float*y){
  12. *y = bird_y +15;
  13. void moveVertically(float mov){
  14. for(unsignedint i =0; i < bird.size(); i++){
  15. }
  16. std::vector<sf::CircleShape> getBirdVector(){
  17. }
  18. std::vector<sf::CircleShape> bird;
  19. float bird_y;
  20. public:
  21. Pipe(unsignedint space, unsignedint window_width, unsignedint window_height){
  22. printf('Spawning new pipe with gap from %u to %un', space -100, space +100);
  23. upper_pipe =new sf::RectangleShape(sf::Vector2f(100, space -100));
  24. lower_pipe =new sf::RectangleShape(sf::Vector2f(100, window_height - space -100));
  25. upper_pipe->setFillColor(sf::Color::Green);
  26. controlled_space = space;
  27. upper_pipe->setPosition(current_x, 0);
  28. }
  29. bool checkIfCollision(float colliding_x, float colliding_y){
  30. if(colliding_x > current_x +50 colliding_x < current_x -50)returnfalse;
  31. if(colliding_y < controlled_space +100&& colliding_y > controlled_space -100)returnfalse;
  32. }
  33. if(current_x <-100)returntrue;
  34. upper_pipe->move(-1, 0);
  35. returnfalse;
  36. void drawSelf(sf::RenderWindow*to_draw_to){
  37. to_draw_to->draw(*lower_pipe);
  38. }
  39. delete upper_pipe;
  40. }
  41. private:
  42. sf::RectangleShape*lower_pipe;
  43. unsignedint controlled_space;
  44. char*name =(char*)calloc(1, 1);
  45. printf('Enter your name: ');
  46. scanf('%c', &buf);
  47. name =(char*)realloc(name, strlen(name)+2);
  48. }
  49. savefile.open('.flappy_bird_save', std::ios::out std::ios::app);
  50. savefile <<':';
  51. savefile.write((char*)(void*)(&score), sizeof(unsignedint));
  52. savefile.close();
  53. printf('LEADERBOARDn');
  54. unsignedint score;
  55. };
  56. char buf =0;
  57. while(savefile.good()){
  58. players.resize(players.size()+1);
  59. players[players.size()-1].name=(char*)calloc(1, 1);
  60. buf = savefile.get();
  61. players[players.size()-1].name=(char*)realloc(players[players.size()-1].name, strlen(players[players.size()-1].name)+2);
  62. players[players.size()-1].name[strlen(players[players.size()-1].name)]= buf;
  63. savefile.read((char*)(void*)&(players[players.size()-1].score), sizeof(unsignedint));
  64. }
  65. if(players.size()<3)return;//don't bother
  66. for(unsignedint i =0; i < players.size(); i++){
  67. if(players[pivot_pos].score0) pivot_pos -=1;
  68. if(players[i].score< players[pivot_pos].score){
  69. players.erase(players.begin()+ i);
  70. }
  71. for(unsignedint i =0; i < players.size()-2; i++){
  72. is_sorted =false;
  73. }
  74. if(is_sorted)break;
  75. if(players[i].score0)break;
  76. printf('%s:t%8un', players[i].name, players[i].score);
  77. }
  78. if(argc <2)return1;
  79. std::default_random_engine rand_generator;
  80. printf('Insert quarter to playn');
  81. unsignedint window_width =(argc <3)?1000:atoi(argv[2]);//we have to do it this way because SFML team is too lazy to let you
  82. unsignedint window_height =(argc <4)?800:atoi(argv[3]);//actually get the size of the window.
  83. sf::RenderWindow window(sf::VideoMode(window_width, window_height), argv[1]);//damn kids..
  84. std::uniform_int_distribution<int> pipe_pos_spawn(100, window_height -100);
  85. Bird protagonist;
  86. std::vector<Pipe> pipes;
  87. float protagonist_x;
  88. char*score_text =(char*)calloc(1, 11);
  89. sf::Time check_time;
  90. sf::RectangleShape*current_upper_pipe;
  91. if(!font.loadFromFile('Hack-Regular.ttf'))return1;
  92. score_view.setCharacterSize(32);
  93. score_view.setFillColor(sf::Color::White);
  94. score_view.setString('Score: '+ std::string(score_text));
  95. printf('Scoreview is currently %sn', score_view.getString().toAnsiString().c_str());
  96. pipe_pos_spawn(rand_generator);//throwaway first value
  97. protagonist.moveVertically(window_height /2);
  98. while(window.isOpen()){
  99. while(window.pollEvent(event)){
  100. if(event.type sf::Event::Closed) window.close();
  101. protagonist.getPosition(&protagonist_x, &protagonist_y);
  102. current_gravity_pull =(current_gravity_pull *2<16)? current_gravity_pull :16;
  103. if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)&& protagonist_y >0){
  104. protagonist.moveVertically(-2);
  105. protagonist.moveVertically(current_gravity_pull);
  106. if(check_time.asMilliseconds()%10000){
  107. pipes.push_back(Pipe(pipe_pos_spawn(rand_generator), window_width, window_height));
  108. for(unsignedint i =0; i < protagonist_parts.size(); i++){//draw the bird
  109. }
  110. pipes[i].drawSelf(&window);
  111. printf('Update returned truen');
  112. pipes[i].~Pipe();
  113. score +=1;
  114. score_view.setString(std::string(score_text));
  115. printf('Scoreview is currently %sn', score_view.getString().toAnsiString().c_str());
  116. }elseif(pipes[i].checkIfCollision(protagonist_x, protagonist_y) protagonist_y >= window_height){
  117. window.close();
  118. return0;
  119. }
  120. window.display();
  121. return0;

Flappy Bird Html Code

  • Simple flappy bird clone written in C and SFML. Contribute to Gear-Code/Flappy-Bird development by creating an account on GitHub.
  • Application: Flappy Bird Category: Games License: MIT Language: English Description: A multi-resolution supported and StrobeAPI integrated clone of Flappy Bird - utilizing 'Deep Learning', written in C and made with Qt. Download Flappy Bird Portable 1.5.2 Development Test 1 16.1MB download / 53.4MB installed (MD5.
  • Flappy Bird Clone - The Complete Cocos2d-x C Game Course Udemy Free Download The Ultimate Cocos2d-x Game Development. Learn how to make cross platform games using the immensely successful and addictive Flappy Bird as an example.
Permalink

Mar 20, 2014  The popular game Flappy Bird is now ported to form a new Flappy bird game based on FLASH which can be played on Windows, Linux, MAC OS and does not need internet / any other extra software to run:) NOTE:: This is a ported version and in no way presents any copyright infringement to its original publisher. Jun 23, 2019  A couple of days ago, I had a random idea & couldn't get rid of it until I built it so here you go, I made a Flappy Bird game you play w/ browser windows!🐦🎮 Now I can move on! 😂🎉 flappy-windows.netlify.com #javascript.

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Songs

Sign up
Branch:master
Bird
Find file Copy path
Fetching contributors…
#include<SFML/Graphics.hpp>
#include<SFMLAudio.hpp>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include'Pipes.h'
#include'GameOver.h'
Pipes::Pipes(int PositionX, int PositionY, int PipeDistance, int PipeAbove)
{
std::cout << 'hello!' << std::endl;
if (!PipeUp.loadFromFile('images/FlappyBird.png', sf::IntRect(84, 323, 26, 160)))
{
}
if (!PipeDown.loadFromFile('images/FlappyBird.png', sf::IntRect(56, 323, 26, 160)))
{
}
PipeSpriteUp.setTexture(PipeUp);
PipeSpriteUp.setScale(4,4);
PipeSpriteDown.setTexture(PipeDown);
PipeSpriteDown.setScale(4, 4);
PipeSpriteUp.setPosition(PositionX + PipeDistance, PositionY*1.4 );
PipeSpriteDown.setPosition(PositionX + PipeDistance, PositionY - PipeAbove + 160);
PipeGap = PipeAbove;
}
Pipes::~Pipes()
{
}
voidPipes::draw(sf::RenderWindow &window)
{
//srand((unsigned)time(NULL));
PipeSpriteUp.move(Speed, 0);
PipeSpriteDown.move(Speed, 0);
if (PipeSpriteUp.getPosition().x <= -100 && PipeSpriteDown.getPosition().x <= -100)
{
int Up = rand() % (600 + 1 - 300) + 300;
int Down = Up - PipeGap;
PipeSpriteUp.setPosition(800, Up);
PipeSpriteDown.setPosition(800, Down);
}
window.draw(PipeSpriteUp);
window.draw(PipeSpriteDown);
}
intPipes::OverlapTest(float FlappyBirdX, float FlappyBirdY)
{
constint left_box0 = FlappyBirdX;
constint right_box0 = FlappyBirdX + 17 * 3;
constint top_box0 = FlappyBirdY;
constint bottom_box0 = FlappyBirdY + 12 * 3;
constint left_box1 = PipeSpriteUp.getPosition().x;
constint right_box1 = PipeSpriteUp.getPosition().x + 26 * 4;
constint top_box1 = PipeSpriteUp.getPosition().y;
constint bottom_box1 = PipeSpriteUp.getPosition().y + 160 * 4;
constint left_box2 = PipeSpriteDown.getPosition().x;
constint right_box2 = PipeSpriteDown.getPosition().x + 26 * 4;
constint top_box2 = PipeSpriteDown.getPosition().y;
constint bottom_box2 = PipeSpriteDown.getPosition().y + 160 * 4;
return ((right_box0 >= left_box1 && left_box0 <= right_box1 && top_box0 <= bottom_box1 && bottom_box0 >= top_box1) (right_box0 >= left_box2 && left_box0 <= right_box2 && top_box0 <= bottom_box2 && bottom_box0 >= top_box2));
}
intPipes::Points(float FlappyBirdX)
{
int left_box0 = FlappyBirdX;
int right_box0 = FlappyBirdX + 17 * 2;
int left_box1 = PipeSpriteDown.getPosition().x + 25;
int right_box1 = PipeSpriteDown.getPosition().x + 26;
int left_box2 = PipeSpriteUp.getPosition().x + 29;
int right_box2 = PipeSpriteUp.getPosition().x + 30;
return ((right_box0 >= left_box1 && left_box0 <= right_box1) (right_box0 >= left_box2 && left_box0 <= right_box2));
}

Program Flappy Bird

  • Copy lines
  • Copy permalink