Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C++ Car Racing game framework
#include <iostream> #include <iomanip> using namespace std; const int height = 10; const int width = 10; int m=0; int x; int y; int obx ; int oby; bool over; void Draw(); void status(); void setup(); void logic(); int main() { setup(); while(!over) { Draw(); status(); logic(); } return 0; } void Draw() { for(int i=0; i<height; i++) { for(int j=0; j <width; j++) { if(j ==0) cout<<"¤"; if(i ==y && j ==x) cout<<"O"; else if(i ==oby && j== obx) cout<<"€"; else cout<<" "; if(j==width-1) cout<<"¤"; } cout<<endl; } for(int i =0; i<8;i++) cout<<"¤ "; cout<<endl; cout<<endl; } void status() { if(oby==y&&obx==x) { cout<<"GAME OVER"; over =true; }} void logic() { y++; m++; if(m == 10) { y =0; x =rand()%10; m=0;}} void setup() { bool over =false; obx = rand()%width; oby = rand()%height; x =0 ; y =0; }
run
|
edit
|
history
|
help
0
Filtering a vector attribute with template UnaryPredicate
BST to DLL
Kth smallest element
Test 9(2020)
RegexReplace
Array Subset of another array
Preference List
005#
HashConPar
BinTraversal v2