Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
Clementina
Vectores - insertar ordenado e imprimir
good triplet
Listas enlazadas - eliminar ocurrencias
const example
Tubee c++
generating all valid parenthesis
codechef
code
string probe