Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
C++ Car Racing game framework 2
#include <iostream> 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<<"€"; else if(i ==oby && j== obx) cout<<"0"; 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; y =0; x = 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Dar
Próba
Handling new types without using RTTI
without HLD range Quey can be handled by just using segment tree on the FLATTENED TREE (euler tour)
Scope guarding
ugly quick sort
String match with test
Stock buy/sell, maximum subarray problem
Network UVa
Exploring the Transform Function and Operator Classes
Please log in to post a comment.