Skip to content

Instantly share code, notes, and snippets.

@pvsousalima
Created January 30, 2015 20:05
Show Gist options
  • Save pvsousalima/566a7dbf188acda8f370 to your computer and use it in GitHub Desktop.
Save pvsousalima/566a7dbf188acda8f370 to your computer and use it in GitHub Desktop.
Funny C++ code of a comic of tank's race where all tanks win the race
/*
This program was built under the Mac OS X Yosemite version 10.10.1
and g++ compiler described as follows:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
It was tested, compiled and fully functional on Mac by command line.
*/
/* Import modules */
#include <iostream>
#include <unistd.h>
#include <sstream>
#include <string>
/* Standard namespace */
using namespace std;
/* Ends the animation */
int END = -1;
/* Defines the operator on string */
string operator*(const string& s, unsigned int n) {
stringstream out;
while (n--)
out << s;
return out.str();
}
/* Operator */
string operator*(unsigned int n, const string& s) { return s * n; }
/* Introduction for the animation */
void Introduction(){
cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
cout << "==================================" << endl;
cout << "|| WORLD'S FIRST TANK'S RACING! ||" << endl;
cout << "==================================" << endl;
sleep(2);
system("tput reset");
}
/* Ending for the animation */
void Ending() {
cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
cout << "==================================" << endl;
cout << "|| ALL THE TANKS WON THE RACE! ||" << endl;
cout << "==================================" << endl;
sleep(2);
}
/*Controls animations' speed */
int animations(int *i){
usleep(70000);
system("tput reset");
if (*i==100) {
return END;
}
return 0;
}
int main(){
/* Clean the screen*/
system("tput reset");
/* Variables */
char top[] = " _||======";
char body1[] = "_| 1 |__";
char body2[] = "_| 2 |__";
char body3[] = "_| 3 |__";
char bottom[] = "\\oooooo/";
/* Spaces Used to move */
string s = " ";
// Calls the introduction
Introduction();
for (int i = 0; 100; ++i){
cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
cout << "START FINISH" << endl;
cout << "=============================================================================================================" << endl;
cout << "|||" << s * i << top << "\n|||" << s * i << body1 << "\n|||" << s * i << bottom << endl;
cout << "=============================================================================================================" << endl;
cout << "\n\n\n\n\n" << endl;
cout << "START FINISH" << endl;
cout << "=============================================================================================================" << endl;
cout << "|||" << s * i << top << "\n|||" << s * i << body2 << "\n|||" << s * i << bottom << endl;
cout << "=============================================================================================================" << endl;
cout << "\n\n\n\n\n" << endl;
cout << "START FINISH" << endl;
cout << "=============================================================================================================" << endl;
cout << "|||" << s * i << top << "\n|||" << s * i << body3 << "\n|||" << s * i << bottom << endl;
cout << "=============================================================================================================" << endl;
/*Get result to finish animation*/
int result = animations(&i);
if (result == END){
Ending();
break;
}
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment