Car Race Game
This is a simple C++ program to make a car race game. It uses object oriented approach to generate different objects in the game such as using Car, Obstacle and Timer classes.
This is a simple C++ program to make a car race game. It uses object oriented approach to generate different objects in the game such as using Car, Obstacle and Timer classes.
This is a very basic C++ program that demonstrates data protection in a very simple way. Data protection in Object Oriented Programming is controlling access to all attributes is one of the most important concepts of object-oriented design
“describe a problem which occurs over and over again in our environment, and then describe the core of the solution
This is a special console based utility which will calculate the Message Digest, Base 64 Encoding and Decoding, Checks the
This C++ program is tour of knight on 64 square of chess board. Â The goal is to place a knight on an empty chess board and then move the knight to each of the remaining 63 squares while only visiting each square once. Â If on visiting the last square the knight is able to hop to the square on which it first started it is known as a closed tour (and so the knight could resume the exact same sequence of moves to complete another tour) while if the knight is unable to hop to the original square, it is known as an open tour.Â
This is a C++ implementation of various sorting algorithms. The list of algorithms include Bubble Sort, Heap Sort, Selection Sort, Insertion Sort, Quick Sort, Merge Sort and Shell Sort. A brief description of each sorting algorithm is listed below along with their complexity.
This is graphic C program that can be used to store personal information of people such as name, telephone, mobile, fax, city and country.
The Birthday Reminder program is a simple console-based application written in C++. Its purpose is to help users keep track of important dates, such as birthdays, by allowing them to add, delete, and view reminders associated with individuals.
This is another one of my numerical analysis university assignments. It is an extension of binary to decimal conversion code.
This is a C++ class which has a member function that takes 3 arguments and converts the number from first base to second base. It takes the following arguments. – std::string thestlstring – int base – int base2
This is an enhanced version of Tic-Tac-Toe (TTT) game by adding one more row and column. Actually I have played this newer version of Tic-Tac-Toe (TTT) game on a video game. So, when I learnt C/C++ programming, it was my wish to program this game myself using C/C++.
SWAT GAME
|
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
/******************************************************* * MYCPLUS Sample Code - https://www.mycplus.com * * * * This code is made available as a service to our * * visitors and is provided strictly for the * * purpose of illustration. * * * * Please direct all inquiries to saqib at mycplus.com * *******************************************************/ #include <graphics.h> #include <conio.h> #include <stdlib.h> #include <dos.h> class swat{ public: void draw_swat( int x ){ setcolor( LIGHTCYAN ); setlinestyle( SOLID_LINE,0,3 ); line( x,470,x,275); setfillstyle( XHATCH_FILL, LIGHTCYAN ); rectangle( x-80,50,x+80,275); floodfill( x,200, LIGHTCYAN ); } } swats; int final_x, final_y; class fly{ private: int move_x, move_y, current_x, current_y; public: void draw_fly( int& ); void show_fly(){ setcolor( WHITE ); setfillstyle( SOLID_FILL, getcolor() ); circle( final_x, final_y, 4 ); floodfill( final_x, final_y, getcolor() ); } } fly; void fly :: draw_fly( int &time ) { randomize(); current_x = random(600); current_y = random(275); for( int i=0; i<10; i++ ){ setcolor( WHITE ); setfillstyle( SOLID_FILL, getcolor() ); circle( current_x, current_y, 4 ); floodfill( current_x, current_y, getcolor() ); sound(200); delay( time ); setcolor( BLACK ); setfillstyle( SOLID_FILL, getcolor() ); circle( current_x, current_y, 4 ); floodfill( current_x, current_y, getcolor() ); nosound(); final_x = current_x; final_y = current_y; move_x = random(300); move_y = random(175); if ( current_x + move_x > 600 ) current_x -= 1.25 * move_x; else current_x += move_x; if ( current_x <= 0 ) current_x += 0.75 * move_x; if ( current_y + move_y > 275 ) current_y -= move_y; else if( current_y + move_y < 50 ) current_y += 2 * move_y; else current_y += move_y; } } void main() { int pos; int swat_number; int time = 700; enum state{ WIN,LOSE }; state user; int driver=DETECT; int mode=DETECT; initgraph(&driver,&mode,"\\borlandc\\bgi <file://\\borlandc\\bgi>"); highvideo(); do{ user = LOSE; pos = 120; cleardevice(); fly.draw_fly( time ); time-= 50; for( int i=0; i<3; i++ ){ swats.draw_swat( pos ); pos+=200; } settextstyle(DEFAULT_FONT,HORIZ_DIR,2); outtextxy( 10,5, "Enter swat number?" ); swat_number = getch(); cleardevice(); switch ( swat_number ){ case '1' : if( ( final_x < 220 && final_x > 0 )) user = WIN; break; case '2' : if( ( final_x < 420 && final_x > 220 ) ) user = WIN; break; case '3' : if( ( final_x < 620 && final_x > 420 ) ) user = WIN; break; } cleardevice(); if( time <= 70 && user == WIN ){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,11); for( int i=1; i<15; i++ ){ setcolor(i); outtextxy( 180,10,"FLY" ); outtextxy( 30,150,"SWATTING" ); outtextxy( 10,300,"CHAMPION" ); delay(1000); } exit( EXIT_SUCCESS ); } fly.show_fly(); settextstyle(TRIPLEX_FONT,HORIZ_DIR,9); if( user == WIN ){ setcolor(LIGHTGREEN); outtextxy( 40,350,"YOU WON !!!!" ); } else{ setcolor(LIGHTRED); outtextxy( 40,350,"YOU LOSE !!!!" ); } getch(); }while( user == WIN ); } |