Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:49:53+00:00 2026-06-15T13:49:53+00:00

i have a bit of problem which i have run into, im trying to

  • 0

i have a bit of problem which i have run into, im trying to shorten my code for a game and i got the idea to import all the dialogue from a text file instead of hardcoding it into the code itself. however it would work if every screen only had one line to display but somescreens have more than one

if (screenCount==1)
   g.drawString("Hi there!", 25,515);
if (screenCount==2)
   g.drawString("Welcome to the world of Pok\u00E9mon!", 25,515);
if (screenCount==3){
   g.drawString("My name is Professor BLANK!", 25,515);
   g.drawString("Everyone calls me the Pok\u00E9mon Professor!", 25,540);
  }

As you can see for screen one and two i could easily put the dialogue in a text file like so:

1:Hi there!

2:Welcome to the world of Pok\u00E9mon!

But for the third screen I couldnt figure out how to import it/ write it in a text file and import it

3:My name is Professor Shinwa!
  Everyone calls me the Pok\u00E9mon Professor!

MORE INFO: The game only displays two lines at a time at

   g.drawString("", 25,515); //the first line x and y values
   g.drawString("", 25,540); // the second line x and y values

I have around 37 screens and around half or more are two lines.
Thanks for any help, much apreciated 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:49:54+00:00Added an answer on June 15, 2026 at 1:49 pm

    You can use the escape sequence \n in your String as pointed in the JavaDocs:

    Insert a newline in the text at this point.

    Your String could look like:

    3:My name is Professor Shinwa!\nEveryone calls me the Pok\u00E9mon Professor!
    

    BUT I think a better solution is to put each screen text in a separate textfile. You can then read the file until no more lines are remaining and print them on the screen. The textfiles should be named with screen#, e.g. screen1, screen2 … so you don’t need this big amount of if-blocks in your code. Just concatenate the screen with your current screennumber and read this file, done. What if you need dialogues with response from the user? How would you handle this case?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a bit of a tricky problem in some C++ code,
I am pretty new to OpenGL and have run into a problem trying to
I am working on bit shifts, and I've run into this problem. I have
I have a bit of problem when trying to validate my page as HTML5.
I have a bit of a problem that I can't seem to code my
I have a bit of a problem. I am trying to do the following
So, I have a bit of a problem. I'm trying to convert an array
Apparently many people have run into this problem, but I have yet to be
I have run into a problem attempting to redispatch mouse events in ActionScript 3,
I got a bit of a problem. I have a running application for android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.