Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-a-simple-hud #17

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

Waffelhunter
Copy link

wrote a new documentation on how to implement a HUD with an Healthbar as an example

Copy link
Member

@nightm4re94 nightm4re94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestions!
Except for the individual comments in your markdown file, please make the following changes:

  • Provide metainformation. Not all of our docs pages have these already, I know.
    For example, see this site.
  • name your image files in lowercased letters.
  • name your markdown files in lowercased letters without spacing and special characters. Use create-a-simple-hud.md instead.

user-interface/# Create a simple HUD.md Outdated Show resolved Hide resolved
user-interface/# Create a simple HUD.md Outdated Show resolved Hide resolved
import de.gurkenlabs.litiengine.util.Imaging;

import javax.tools.Tool;
import java.awt.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No wildcard imports, please.


public class HUD extends GuiComponent {
//create variables for our images that we want to render later, and scale them to the desired size
private static final BufferedImage HEART = Imaging.scale(Resources.images().get("src/main/resources/hud/life.png"), 5.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the resources folder is configured correctly for your project, you only need to specify the file name, not the entire relative path.

private static final BufferedImage HEARTEMPTY = Imaging.scale(Resources.images().get("src/main/resources/hud/herzleer.png"), 5.0);

//optional / intialize a Padding variable, to change positioning easier later on
private static final int PADDING = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could also use values that are relative to the screen resolution in order to make the UI more dynamic.

user-interface/# Create a simple HUD.md Outdated Show resolved Hide resolved

import de.gurkenlabs.litiengine.Game;
import de.gurkenlabs.litiengine.gui.screens.GameScreen;
import java.awt.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wildcard import.

}
@Override
public void render(Graphics2D g) {
super.render(g);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to override the render method here.
This is exactly what the parent render method in the GameScreen class does.

user-interface/# Create a simple HUD.md Outdated Show resolved Hide resolved
user-interface/# Create a simple HUD.md Outdated Show resolved Hide resolved
@Waffelhunter Waffelhunter changed the title Create a simple HUD documentation create-a-simple-hud Jun 14, 2022
@nightm4re94
Copy link
Member

Just checking in whether you're planning to implement my suggestions :)
Also, you've not actually renamed the files, but the Pull Request itself. Please make sure the file names follow our usual schema.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants