We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm making typewriter and I have no idea where to start to fix.... And I'm not that good at processing even in english.... What I want to make is typewriting with trees.... Thank you very much in advanced for your attempts and assistance.
String text1 = " ";
PFont font;
boolean randomizer = false;
int rectWidth;
int maxParticles = 800; // the maximum number of active particles
ArrayList <Particle> particles = new ArrayList <Particle> (); // the list of particles
int drawMode = 0; // cycle through the drawing modes by clicking the mouse
color BACKGROUND_COLOR = color(255);
color PGRAPHICS_COLOR = color(0);
color BGRAPHICS_COLOR = color(128);
float fc001;
PGraphics pg,bg;
String texttype = "Start";
void setup() {
size(1280, 720, P2D);
smooth(16); // higher smooth setting = higher quality rendering
font = loadFont("Arial-Black-48.vlw");
textFont(font, 20);
pg = createGraphics(width, height, JAVA2D);
pg.beginDraw();
pg.textSize(500);
pg.textAlign(CENTER, CENTER);
pg.fill(PGRAPHICS_COLOR);
pg.text(texttype, pg.width/2, pg.height/2);
pg.endDraw();
background(BACKGROUND_COLOR);
}
void addRemoveParticles() {
// remove particles with no life left
for (int i=particles.size()-1; i>=0; i--) {
Particle p = particles.get(i);
if (p.life <= 0) {
particles.remove(i);
}
}
// add particles until the maximum
while (particles.size () < maxParticles) {
particles.add(new Particle());
}
}
void draw() {
fc001 = frameCount * 0.1;
addRemoveParticles();
// update and display each particle in the list
for (Particle p : particles) {
p.update();
p.display();
}
}
void keyPressed() {
if (key == BACKSPACE) {
if(text1.length() > 0) {
text1 = text1.substring(0, text1.length() - 1);
}
}
else if (key == '1') {
randomizer = false;
}
else {
text1 += key;
fc001=0;
pg.background(255);
pg.clear();
pg.text(text1,width/2,height/2);
}
}
Answers
Your code is hard to read because it is not formatted properly. Edit your post, select your code, and press Ctrl+o.
Even when I do fix it and add what seems like the proper line breaks:
Now I am missing your Particle class. Obviously this is an important part of your sketch - why leave it out?
For that matter, why does a typewriter - which displays letters - have particles?
Oh, I'm sorry. This is a Particle class. This particle makes like a alphabet tree. And When you type it shows trees instead of letters. And exactly I am just mixing examples that's why I have no enough understanding about codes.
I've made this msg box once for a tic tac toe board, it includes a typewriter effect, if you want to have a look... It's simple. This is just the class, no instance built cause the full code is much more complex, and the instantiation is done inside another bigger class, but it is functional and commented.
edit: I added a simple instantiation :)