fastjengine / FastJ

An open-source, Java-based 2D game engine.
https://fastj.tech
MIT License
82 stars 22 forks source link

[Bug] Stretched display #62

Closed lines-of-codes closed 3 years ago

lines-of-codes commented 3 years ago

Platform Info

Place an x in the box(es) [x] that the issue occurs on (or that you've found the issue on)

Describe the Bug

A clear and concise description of what the bug is. I tried running FastJ in 800x600 resolution, Then I found out that the Text is stretched and smaller than it should compare to running at 1280x720 resolution.

Expected Behavior

A clear and concise description of what you expected to happen. I expect the Text to display properly, With the same size when displayed on 1280x720 resolution.

How to Reproduce the Bug

Steps to reproduce the behavior:

  1. Use the following code to initialize FastJ:
    FastJEngine.init(gameName, this);
    FastJEngine.configureViewerResolution(new Point(800, 600));
    FastJEngine.run();
  2. Add a Text in the SimpleManager init method.
  3. Run the code.
  4. See the stretched text.

Media Aid

If applicable, add screenshots/GIFs/videos to help explain your problem.

java_p6OxTgQ5ft

Additional context

Additional context not provided above. I use a Custom class to create the Text. The code for the class:

package ga.susite.StablerCharacter;

import java.awt.Color;
import java.awt.Font;

import tech.fastj.graphics.game.Text2D;

public class TextInfo {
    Color color;
    Font font;

    TextInfo(Color nColor, Font nFont) {
        color = nColor;
        font = nFont;
    }

    public Text2D build(String message) {
        return Text2D.create(message).withFont(font).withFill(color).build();
    }
}
lucasstarsz commented 3 years ago

This is not a bug. FastJ uses two resolution modifiers: viewer (window) resolution and internal (game) resolution.

The viewer resolution represents the size of the game window -- changing this does not affect the game content screen size. The game content will be stetched or shrunk to fit the size of the game window.

On the other hand, internal resolution is the resolution of the game itself. The internal resolution's default size is 1280*720 -- switching the window's resolution to 800*600 will make the game shrink down to fit it. For more information, please look at FastJEngine#configureInternalResolution and FastJEngine#configureViewerResolution.