Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int xInput;
- int speed;
- color carColor;
- color back;
- int i;
- int sped;
- boolean Forward;
- Car(int big, int yKey, color car, color nice, int speed, boolean direction){
- size = big;
- yInput = yKey;
- carColor = car;
- back = nice;
- sped = speed;
- Forward = direction;
- if (Forward) {
- xInput = size * -1;
- }
- else {
- xInput = size + width;
- }
- }
- void display() {
- for(int i = 0; i < sped; i++){
- background(back);
- if(Forward) {
- xInput++;
- }
- else {
- xInput--;
- }
- carBody();
- }
- }
- void carBody() {
- rectMode(CENTER);
- stroke(0, 0, 0);
- fill(carColor);
- rect(xInput, yInput + size/4, size * 2, size/2);
- quad(xInput - size/2, yInput, xInput - size/4, yInput - size/2, xInput + size/4, yInput - size/2, xInput + size/2, yInput);
- fill(0, 0, 0);
- ellipse(xInput - size * 2/3, yInput + size/2, size/2, size/2);
- ellipse(xInput + size * 2/3, yInput + size/2, size/2, size/2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement