C++ console game!
- C++ Articles
http://www.cplusplus.com/articles/3Cpk4iN6/
Search: Articles C++
Information Tutorials Reference Articles Forum
Go
Not logged in
C++ console game!
register
log in
Published by Foxefde
Oct 30, 2013
C++ console game!
Score: 3.5/5 (134 votes)
Hello guys, Articles This is very simple and one of my old projects I've created.It's probably the best one,as it really looks like a game,mind you the code is not very complicated.It has 11 levels you can try, every level the speed and the amount of "birds" is increasing.The controls are arrow keys for moving and 1 / 2 for shooting. Have fun ! Foxefde 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 #include #include #include #include #include <iostream> <conio.h> <windows.h> <ctime> <vector>
Algorithms C++ 11 Graphics and multimedia How-To Language Features Unix/Linux programming Source Code Standard Library Tips and Tricks Tools and Libraries Visual C++ Windows API
class game { private: std::vector <int> fake; char map[1800]; int x;//COORDINATES int c; int speed; int points ; int CurrentLevel; bool check; public: game() { x = 1940; speed = 215; check = 0; points = 0; } void PrepareGraphics(); void graphics(); void LevelMenu(); void Levels(); void LOGIC(); void gameover(); friend void cls(); friend void sp(); friend void s(); }; void cls() { HANDLE hOut; COORD Position; hOut = GetStdHandle(STD_OUTPUT_HANDLE); Position.X = 0; Position.Y = 0; SetConsoleCursorPosition(hOut, Position); } void game::Levels() //Just minimize this function ////////////////////////////////////////////////////////////////////////////*// { speed-=20; for(int a = 0;a < 1800;a++) { map[a] = ' '; //CLEAN IT FIRST } switch(CurrentLevel) { case 1://///////////////////////////////////////////////////////////////*// for(int b = 0;b < 26;b++) { map[b + 7] = char(253); } for(int b = 0;b < 26;b++) { map[b + 47] = char(253); } for(int b = 0;b < 26;b++) { map[b + 87] = char(253); } for(int b = 0;b < 26;b++) { map[b + 127] = char(253); } for(int b = 0;b < 26;b++) { map[b + 167] = char(253); }
1 of 2
4/21/2014 9:25 PM
C++ console game! - C++ Articles
http://www.cplusplus.com/articles/3Cpk4iN6/
Rate this Please, choose stars to award:
(hover mouse and click) Home page | Privacy policy cplusplus.com, 2000-2014 - All rights reserved - v3.1 Spotted an error? contact us
2 of 2
4/21/2014 9:25 PM