class Car extends Sprite { int direction = 1; int speed = 2; Car(String i, int ix, int iy) { super(i, ix, iy); } // alternate constructor with default x, y Car(String i) { super(i); } void update() { x += direction * speed; if (x > (width + img.width/2)) { x = 0 - + img.width/2; } if (x < -1*(img.width/2) ) { x = width + img.width/2; } update_edges(); } } class Player extends Sprite { PImage dead_img; int respawn_timer = 0; boolean dead; Player(String i, String d_img, int ix, int iy) { super(i, ix, iy); dead_img = loadImage(d_img); } // alternate constructor with default x, y Player(String i, String d_img) { super(i); dead_img = loadImage(d_img); } void update() { if (dead) { img = dead_img; respawn_timer += 1; } if (respawn_timer > 100) { respawn_timer = 0; dead = false; generate_level(level); } update_edges(); } } class Road extends Sprite { Car[] cars; Road(String i, int ix, int iy) { super(i, ix, iy); } // alternate constructor with default x, y Road(String i) { super(i); } } class Finish extends Sprite { Finish(String i, int ix, int iy) { super(i, ix, iy); } // alternate constructor with default x, y Finish(String i) { super(i); } }