🔍

1fps racing game


var traces = [5];
traces[0] = [0,0];
traces[1] = [0,0];
traces[2] = [0,0];
traces[3] = [0,0];
traces[4] = [0,0];

let steer_x = 0;
let forward_a = .5;
 
function pushTraces(  _x,  _y ){
 
  for(let i=traces.length-1;i>0;i--){
    
    traces[i][0] = traces[i-1][0];
    traces[i][1] = traces[i-1][1];
    
  }
  
  traces[0][0] = _x;
  traces[0][1] = _y;
 
}


let cx = 122;
let cy = 122;

let cxa = 1;
let cya = 1;

function drawTraces(){
  
  stroke(2);
  strokeWeight(3);
  
  line(traces[0][0],traces[0][1], cx,cy );
  
  for(let i=1;i<traces.length;i++){
    
    stroke(i*50);
    line(traces[i-1][0],traces[i-1][1], traces[i][0],traces[i][1] );
    
  }
  
}

function setup() {
  createCanvas(300, 400);
  frameRate(5);
  textAlign(CENTER);
  textSize(33);
}

function draw() {
  
  
  
  
  background(240);
  
  
  
  
  steer_x = map(mouseX,0,width,-PI,PI);
  
  fill(0);
  push();
  translate(cx,cy);
  rotate(steer_x);
  text("*|*",0,0);
  
  
  pop();
  
  
  //cx += cxa*10;
 // cy += cya*10;
  
  //cx += random(-10,10)*.7;
  // cy += random(-10,10)*.7;
  
  
  
 // drawTraces();
  stroke(0);
  ellipse( cx,cy,12,12);
  
  pushTraces(cx,cy);
}