# About steering force,I'm studying The Nature of Code by Daniel Shiffman.Why does the code run with nothing?

**URL:** <https://discourse.processing.org/t/about-steering-force-im-studying-the-nature-of-code-by-daniel-shiffman-why-does-the-code-run-with-nothing/41823>\
**Category:** Coding Questions\
**Created:** [April 25, 2023, 8:36am UTC](https://discourse.processing.org/t/about-steering-force-im-studying-the-nature-of-code-by-daniel-shiffman-why-does-the-code-run-with-nothing/41823 "2023-04-25T08:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiajia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jiajia/32/16099_2.png) [@jiajia](https://discourse.processing.org/u/jiajia)\
**Post date:** [April 25, 2023, 8:36am UTC](https://discourse.processing.org/t/about-steering-force-im-studying-the-nature-of-code-by-daniel-shiffman-why-does-the-code-run-with-nothing/41823/1 "2023-04-25T08:36:32Z")

</div>

```auto
class Vehicle{
  PVector location;
  PVector velocity;
  PVector acceleration;
  float r;
  
  float maxforce;
  float maxspeed;
  
  Vehicle(float x,float y){
    acceleration = new PVector(0,0);
    velocity = new PVector(0,0);
    location = new PVector(x,y);
    r = 3.0;
    maxspeed = 4;
    maxforce = 0.1;
  }
  
  void update(){
    velocity.add(acceleration);
    velocity.limit(maxspeed);
    location.add(velocity);
    acceleration.mult(0);
  }
  
  void applyForce(PVector force){
    acceleration.add(force);
  }
  
  void seek(PVector target){
    PVector desired = PVector.sub(target,location);
    desired.normalize();
    desired.mult(maxspeed);
    PVector steer = PVector.sub(desired,velocity);
    steer.limit(maxforce);
    applyForce(steer);
  }

  
  void display(){
    float theta = velocity.heading2D()+ PI/2;
    fill(175);
    stroke(0);
    pushMatrix();
    translate(location.x,location.y);
    rotate(theta);
    beginShape();
    vertex(0,-r*2);
    vertex(-r,r*2);
    vertex(r,r*2);
    endShape(CLOSE);
    popMatrix();
  }
}

```

 ![code](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/8/684a9752e38c3264f446328a7ed75ed502023cd3.png)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 25, 2023, 8:48am UTC](https://discourse.processing.org/t/about-steering-force-im-studying-the-nature-of-code-by-daniel-shiffman-why-does-the-code-run-with-nothing/41823/2 "2023-04-25T08:48:46Z")

</div>

> **[setup() / Reference](https://processing.org/reference/setup_.html)**
>
> The setup() function is run once, when the program starts. It's used to define initial environment properties such as screen size and to load media such as images and fonts as the program start…

> **[draw() / Reference](https://processing.org/reference/draw_.html)**
>
> Called directly after setup(), the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. draw()…

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 25, 2023, 10:32am UTC](https://discourse.processing.org/t/about-steering-force-im-studying-the-nature-of-code-by-daniel-shiffman-why-does-the-code-run-with-nothing/41823/3 "2023-04-25T10:32:40Z")

</div>

Hell @jiajia,

When you compile a blank sketch this is what you get and it will run once:

```auto
/* autogenerated by Processing revision 1292 on 2023-04-25 */
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;

import java.util.HashMap;
import java.util.ArrayList;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;

public class sketch_230425a extends PApplet {

 public void setup() {

   noLoop();
 }

 static public void main(String[] passedArgs) {
   String[] appletArgs = new String[] { "sketch_230425a" };
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
}

```

You can find the above in the `%temp%/processing` folder on W10.

When you compile a sketch with only a class it will put your class inside of the _setup()_ and compile that.

This may provide some insight:

> **[Java - Inner classes](https://www.tutorialspoint.com/java/java_innerclasses.htm)**
>
> Java Inner classes - This Java tutorial covers basic to advanced concepts related to Java Programming including What is Java, Java Environment Setup, Java Objects and Classes, Datatypes, Variable Types, Modifiers, Operators, Loops, Decision Making...

You should be using a class in Processing with _setup()_ and _draw()_ in most cases:

> **[class / Reference](https://processing.org/reference/class.html)**
>
> Keyword used to indicate the declaration of a class. A class is a composite of fields (data) and methods (functions that are a part of the class) which may be instantiated as objects. The first lette…

`:)`
