I have the player's car with his own speed N.
N goes from 1 to 15(15 = max). So I create another car with a T speed(the max speed of T is 8). Then...
if (n==0) t+=something;
if (n==1) t+=something less;
if (n==15)t-= something.
So I have this other car in the screen with his own speed.
And the Crash:
if ( (x,y+n,..) of the first car == (x,y+h,..) of the second) )
crash; // (this is not the real code, this is the way it works)
So, that car has own speed and can crash with the main car from any side.
the (x,y,x,y) coordinates of the car in the screen.
//it sould be at the begining
I want to put many cars in the screen, and I dont want to repeat all that code for each of them. T has a relation with N
so I cant use it again, (if I use it, all the cars will move the same). And if I use a new variable for each car I should type this code 1000 times.(or maybe not?)
So, How can I reuse this code with other cars?
Sorry about my prehistorik english
0 · ·