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 8828505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:37:16+00:00 2026-06-14T07:37:16+00:00

Probably missing something basic, but I have a for-loop in my program that’s supposed

  • 0

Probably missing something basic, but I have a for-loop in my program that’s supposed to iterate over an array (lines[]) and draw them onscreen (using LWJGL/Slick).
Instead of the lines being shown on separate lines (at (i*16 + 7, 5)), they all appear at (7, 5).

for(int i = 0; i < lines.length; i++) {
  if(lines[i] != null) {
    f.drawString((i * 16) + 7, 5, lines[i]);
  }
}

I have seen answers on other questions suggesting to define a final variable in the loop to avoid the value being changed before the called function uses it. So I have changed the code to:

for(int i = 0; i < lines.length; i++) {
  if(lines[i] != null) {
    final int i2 = i;
    f.drawString((i2 * 16) + 7, 5, lines[i]);
  }
}

But it doesn’t fix it (didn’t really expect it to, as I’m not getting stuck on the last value of i and Slick shouldn’t be storing the value of i, but tried it to make sure).


The header of drawString is as follows:

public void drawString(float x, float y, String whatchars)
  • 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-14T07:37:17+00:00Added an answer on June 14, 2026 at 7:37 am

    I guess my comment supplied the answer so I’ll post for others to help.

    The correct call is to put the offset in the y parameter of the function:

    f.drawString(7, (i * 16)+5, lines[i]);
    

    As the function definition is:

    public void drawString(float x, float y, String whatchars)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I'm probably missing something easy, but I have a foreach loop and
I'm probably missing something very basic but I cannot figure out why I get
I'm probably missing something pretty basic here, but if the n-body problem yields chaotic
I know I am probably missing something pretty basic here, but I am trying
I'm sure I'm missing something pretty basic, but I have just started to get
I am probably missing something very simple, but here is the situation: I have
I appreciate I'm probably missing something basic here, but... My iPad app will only
I'm probably missing something quite basic, but I'm getting very confused (and frustrated) with
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
I'm probably missing something obvious here but here's what I'm trying to do. From

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.