Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", " "];
- textsize = 30;
- var typing = [];
- function setup() {
- createCanvas(900, 200);
- textSize(textsize);
- sent = new Sentence("to be or not to be");
- sent.placePhraseInArray();
- }
- function draw() {
- background(0);
- sent.getLetter();
- sent.render();
- }
- function Sentence(phrase) {
- this.phrase = String(phrase);
- this.phraseLen = phrase.length;
- this.sentLen = typing.length;
- this.switchLetter = random(2, 25);
- this.getLetter = function() {
- randomLetter = random(alphabet);
- }
- this.letterFuck = function() {
- this.letter = text(randomLetter, 25, 100);
- }
- this.placePhraseInArray = function() {
- arrayPrompt = this.phrase.split('');
- for (i = 0; i < arrayPrompt.length; i++) {
- typing.push(arrayPrompt[i]);
- }
- }
- this.render = function() {
- fill(255);
- b = 0;
- print(this.letter);
- print(typing[0]);
- if (this.letter == typing[b]) {
- this.letter = text(randomLetter, 25 + textsize, 100);
- b += 1;
- } else {
- this.letterFuck();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement