How To Incorporate The Typewriter Effect Into My Game

For my AP Computer Science class we are doing our College Board Projects. I honestly don't have a solid idea for my game, however for the beginning I want a storyline to show. Kind of like on Mario. When the user clicks a button the words will show (letters one by one) with a typewriter effect. I tried to look at other people's explanations of using this effect, however I couldn't get mine to work. I apologize if my code is hard to read. Thank You.

This is my code(processing is what i use):

because it was already answered. I removed it.

Tagged:

Answers

  • edited February 2018 Answer ✓
    PFont title;
    int menu;
    int substr_cnt;
    
    void setup () {
      size(700, 700);
      title = createFont ("font", 28, true);
      menu = 1;
      background(0, 0, 30);
    }
    
    void draw () {
    
      if (menu == 1) {
        ellipse (random (width), random (height), random (4), random (4));
        textAlign(CENTER); 
        textSize(112);
        text ("SEPTUA", 350, 300);
        textSize(30);
        text("press any key to start", 350, 325);
      }
      if (menu == 2) {
        background (0, 0, 30);
        fill(0, 0, 60);
        rect (0, 500, 700, 700);
        textSize(17);
        fill(255, 255, 255);
        String msg = "In the year 3064, Earth has been consumed by a plague..";
        text (msg.substring(0,constrain(int(substr_cnt/5),0,msg.length())), 250, 560);
        substr_cnt++;
        if( substr_cnt == 15*msg.length() ){
          menu = 3;
        }
      }
      if ( menu == 3 ) {
        background(255, 0, 255);
        fill(0);
        text("GAME RUN STATE", width/2, height/2);
      }
    }
    
    void keyPressed() {
      if (menu == 1) {
        menu = 2;
        substr_cnt = 0;
      }
    }
    
  • Thank youuuuuu

  • In AP Computer Science - what‘s AP please...?

  • In the USA, an "AP" class is "Advanced Placement". Basically it's a harder class that might count for more or better school credits.

  • "Advanced Placement" AP courses have a linked exam. High school / secondary school students can sometimes use their exam scores for college credits, and/or use them to skip specific college distribution requirements or skip over required introductory coursework towards a major.

    https://en.wikipedia.org/wiki/Advanced_Placement

  • Thanks! Very interesting!

  • Basically it's a harder class

    not if you keep spoonfeeding them the answers

Sign In or Register to comment.