//The class is the blueprint for a complex variable that con store multiple variables and execute multiple //functions (called methods) class NPC{ int x,y, speed, colour, size; //Declaration for the attribute variables for my NPC characters NPC (int a, int b){//Constructor that gives values to all the attribute variables this.x = a; //In this case I used inputs for the function this.y = b; this.speed = 2; //I just made these default values for now, I could redesign it later but for now this is fine. this.colour = 150; this.size = 20; } void dialog(String input){ } //'this' refers to the attribute variable so things don't get confused with any global variables you might have void render(){ fill(this.colour); //Which colour? this colour. rect(this.x, this.y, this.size, this.size); } void move(){ this.x += this.speed; if(this.x > 400) this.speed = -2; else if(this.x < 0) this.speed = 2; } } NPC ah = new NPC(100, 200); //A single instace for the NPC class, notice my random number sof rhte x & y for the constructor NPC orc = new NPC(300,300); //Look! Another example! NPC[] goons = new NPC[20]; //A quick array of them because why not? void setup(){ size(400,400); for(int i = 0; i < 20; i++) goons[i] = new NPC(int(random(400)), int(random(400))); //Filling in the array } void draw(){ fill(255); rect(0,0,400,400); //ah is the OBJECT instance of type NPC ah.move(); //Running the move method ah.render(); //Running my redner mthod to draw the NPC orc.move(); //Doing it again for another NPC orc.render(); //Using a loop to run ALOT of NPCs for(int i=0; i < goons.length; i++){ goons[i].move(); goons[i].render(); } } /* Make a fresh sketch make a class with a: Consturctor- Same name as you class 2 integer variables x & y and a draw / render method Create a few objects and make them show up. */